repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
fisharebest/webtrees | app/Module/LifespansChartModule.php | LifespansChartModule.subtitle | protected function subtitle(int $count, Date $start, Date $end, string $placename): string
{
if ($start->isOK() && $end->isOK() && $placename !== '') {
return I18N::plural(
'%s individual with events in %s between %s and %s',
'%s individuals with events in %s between %s and %s',
$count,
I18N::number($count),
$placename,
$start->display(false, '%Y'),
$end->display(false, '%Y')
);
}
if ($placename !== '') {
return I18N::plural(
'%s individual with events in %s',
'%s individuals with events in %s',
$count,
I18N::number($count),
$placename
);
}
if ($start->isOK() && $end->isOK()) {
return I18N::plural(
'%s individual with events between %s and %s',
'%s individuals with events between %s and %s',
$count,
I18N::number($count),
$start->display(false, '%Y'),
$end->display(false, '%Y')
);
}
return I18N::plural('%s individual', '%s individuals', $count, I18N::number($count));
} | php | protected function subtitle(int $count, Date $start, Date $end, string $placename): string
{
if ($start->isOK() && $end->isOK() && $placename !== '') {
return I18N::plural(
'%s individual with events in %s between %s and %s',
'%s individuals with events in %s between %s and %s',
$count,
I18N::number($count),
$placename,
$start->display(false, '%Y'),
$end->display(false, '%Y')
);
}
if ($placename !== '') {
return I18N::plural(
'%s individual with events in %s',
'%s individuals with events in %s',
$count,
I18N::number($count),
$placename
);
}
if ($start->isOK() && $end->isOK()) {
return I18N::plural(
'%s individual with events between %s and %s',
'%s individuals with events between %s and %s',
$count,
I18N::number($count),
$start->display(false, '%Y'),
$end->display(false, '%Y')
);
}
return I18N::plural('%s individual', '%s individuals', $count, I18N::number($count));
} | [
"protected",
"function",
"subtitle",
"(",
"int",
"$",
"count",
",",
"Date",
"$",
"start",
",",
"Date",
"$",
"end",
",",
"string",
"$",
"placename",
")",
":",
"string",
"{",
"if",
"(",
"$",
"start",
"->",
"isOK",
"(",
")",
"&&",
"$",
"end",
"->",
"isOK",
"(",
")",
"&&",
"$",
"placename",
"!==",
"''",
")",
"{",
"return",
"I18N",
"::",
"plural",
"(",
"'%s individual with events in %s between %s and %s'",
",",
"'%s individuals with events in %s between %s and %s'",
",",
"$",
"count",
",",
"I18N",
"::",
"number",
"(",
"$",
"count",
")",
",",
"$",
"placename",
",",
"$",
"start",
"->",
"display",
"(",
"false",
",",
"'%Y'",
")",
",",
"$",
"end",
"->",
"display",
"(",
"false",
",",
"'%Y'",
")",
")",
";",
"}",
"if",
"(",
"$",
"placename",
"!==",
"''",
")",
"{",
"return",
"I18N",
"::",
"plural",
"(",
"'%s individual with events in %s'",
",",
"'%s individuals with events in %s'",
",",
"$",
"count",
",",
"I18N",
"::",
"number",
"(",
"$",
"count",
")",
",",
"$",
"placename",
")",
";",
"}",
"if",
"(",
"$",
"start",
"->",
"isOK",
"(",
")",
"&&",
"$",
"end",
"->",
"isOK",
"(",
")",
")",
"{",
"return",
"I18N",
"::",
"plural",
"(",
"'%s individual with events between %s and %s'",
",",
"'%s individuals with events between %s and %s'",
",",
"$",
"count",
",",
"I18N",
"::",
"number",
"(",
"$",
"count",
")",
",",
"$",
"start",
"->",
"display",
"(",
"false",
",",
"'%Y'",
")",
",",
"$",
"end",
"->",
"display",
"(",
"false",
",",
"'%Y'",
")",
")",
";",
"}",
"return",
"I18N",
"::",
"plural",
"(",
"'%s individual'",
",",
"'%s individuals'",
",",
"$",
"count",
",",
"I18N",
"::",
"number",
"(",
"$",
"count",
")",
")",
";",
"}"
] | Generate a subtitle, based on filter parameters
@param int $count
@param Date $start
@param Date $end
@param string $placename
@return string | [
"Generate",
"a",
"subtitle",
"based",
"on",
"filter",
"parameters"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/LifespansChartModule.php#L426-L462 | train |
fisharebest/webtrees | app/Http/Controllers/Auth/RegisterController.php | RegisterController.registerPage | public function registerPage(ServerRequestInterface $request): ResponseInterface
{
$this->checkRegistrationAllowed();
$comments = $request->get('comments', '');
$email = $request->get('email', '');
$realname = $request->get('realname', '');
$username = $request->get('username', '');
$show_caution = Site::getPreference('SHOW_REGISTER_CAUTION') === '1';
$title = I18N::translate('Request a new user account');
return $this->viewResponse('register-page', [
'comments' => $comments,
'email' => $email,
'realname' => $realname,
'show_caution' => $show_caution,
'title' => $title,
'username' => $username,
]);
} | php | public function registerPage(ServerRequestInterface $request): ResponseInterface
{
$this->checkRegistrationAllowed();
$comments = $request->get('comments', '');
$email = $request->get('email', '');
$realname = $request->get('realname', '');
$username = $request->get('username', '');
$show_caution = Site::getPreference('SHOW_REGISTER_CAUTION') === '1';
$title = I18N::translate('Request a new user account');
return $this->viewResponse('register-page', [
'comments' => $comments,
'email' => $email,
'realname' => $realname,
'show_caution' => $show_caution,
'title' => $title,
'username' => $username,
]);
} | [
"public",
"function",
"registerPage",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"checkRegistrationAllowed",
"(",
")",
";",
"$",
"comments",
"=",
"$",
"request",
"->",
"get",
"(",
"'comments'",
",",
"''",
")",
";",
"$",
"email",
"=",
"$",
"request",
"->",
"get",
"(",
"'email'",
",",
"''",
")",
";",
"$",
"realname",
"=",
"$",
"request",
"->",
"get",
"(",
"'realname'",
",",
"''",
")",
";",
"$",
"username",
"=",
"$",
"request",
"->",
"get",
"(",
"'username'",
",",
"''",
")",
";",
"$",
"show_caution",
"=",
"Site",
"::",
"getPreference",
"(",
"'SHOW_REGISTER_CAUTION'",
")",
"===",
"'1'",
";",
"$",
"title",
"=",
"I18N",
"::",
"translate",
"(",
"'Request a new user account'",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'register-page'",
",",
"[",
"'comments'",
"=>",
"$",
"comments",
",",
"'email'",
"=>",
"$",
"email",
",",
"'realname'",
"=>",
"$",
"realname",
",",
"'show_caution'",
"=>",
"$",
"show_caution",
",",
"'title'",
"=>",
"$",
"title",
",",
"'username'",
"=>",
"$",
"username",
",",
"]",
")",
";",
"}"
] | Show a registration page.
@param ServerRequestInterface $request
@return ResponseInterface | [
"Show",
"a",
"registration",
"page",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Auth/RegisterController.php#L63-L84 | train |
fisharebest/webtrees | app/Http/Controllers/Auth/RegisterController.php | RegisterController.verifyPage | public function verifyPage(): ResponseInterface
{
$this->checkRegistrationAllowed();
$title = I18N::translate('User verification');
return $this->viewResponse('register-page', [
'title' => $title,
]);
} | php | public function verifyPage(): ResponseInterface
{
$this->checkRegistrationAllowed();
$title = I18N::translate('User verification');
return $this->viewResponse('register-page', [
'title' => $title,
]);
} | [
"public",
"function",
"verifyPage",
"(",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"checkRegistrationAllowed",
"(",
")",
";",
"$",
"title",
"=",
"I18N",
"::",
"translate",
"(",
"'User verification'",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'register-page'",
",",
"[",
"'title'",
"=>",
"$",
"title",
",",
"]",
")",
";",
"}"
] | Show an email verification page.
@return ResponseInterface | [
"Show",
"an",
"email",
"verification",
"page",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Auth/RegisterController.php#L223-L232 | train |
fisharebest/webtrees | app/GedcomCode/GedcomCodeTemp.php | GedcomCodeTemp.templeNames | public static function templeNames(): array
{
$temple_names = [];
foreach (self::templeCodes() as $temple_code) {
$temple_names[$temple_code] = self::templeName($temple_code);
}
uasort($temple_names, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $temple_names;
} | php | public static function templeNames(): array
{
$temple_names = [];
foreach (self::templeCodes() as $temple_code) {
$temple_names[$temple_code] = self::templeName($temple_code);
}
uasort($temple_names, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $temple_names;
} | [
"public",
"static",
"function",
"templeNames",
"(",
")",
":",
"array",
"{",
"$",
"temple_names",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"templeCodes",
"(",
")",
"as",
"$",
"temple_code",
")",
"{",
"$",
"temple_names",
"[",
"$",
"temple_code",
"]",
"=",
"self",
"::",
"templeName",
"(",
"$",
"temple_code",
")",
";",
"}",
"uasort",
"(",
"$",
"temple_names",
",",
"'\\Fisharebest\\Webtrees\\I18N::strcasecmp'",
")",
";",
"return",
"$",
"temple_names",
";",
"}"
] | A sorted list of all temple names
@return string[] | [
"A",
"sorted",
"list",
"of",
"all",
"temple",
"names"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomCode/GedcomCodeTemp.php#L696-L705 | train |
fisharebest/webtrees | app/Age.php | Age.asText | public function asText(): string
{
if ($this->keyword === self::KEYWORD_STILLBORN) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn)
return I18N::translate('(stillborn)');
}
if ($this->keyword === self::KEYWORD_INFANT) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy)
return I18N::translate('(in infancy)');
}
if ($this->keyword === self::KEYWORD_CHILD) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood)
return I18N::translate('(in childhood)');
}
$age = [];
// Show a zero age as "0 years", not "0 days"
if ($this->years > 0 || $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s year', '%s years', $this->years, I18N::number($this->years));
}
if ($this->months > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s month', '%s months', $this->months, I18N::number($this->months));
}
if ($this->weeks > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s week', '%s weeks', $this->weeks, I18N::number($this->weeks));
}
if ($this->days > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s day', '%s days', $this->days, I18N::number($this->days));
}
// If an age is just a number of years, only show the number
if ($this->years > 0 && $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
$age = [I18N::number($this->years)];
}
$age_string = implode(I18N::$list_separator, $age);
if ($this->qualifier === self::SYMBOL_LESS_THAN) {
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years)
return I18N::translate('(aged less than %s)', $age_string);
}
if ($this->qualifier === self::SYMBOL_MORE_THAN) {
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years)
return I18N::translate('(aged more than %s)', $age_string);
}
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years)
return I18N::translate('(aged %s)', $age_string);
} | php | public function asText(): string
{
if ($this->keyword === self::KEYWORD_STILLBORN) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn)
return I18N::translate('(stillborn)');
}
if ($this->keyword === self::KEYWORD_INFANT) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy)
return I18N::translate('(in infancy)');
}
if ($this->keyword === self::KEYWORD_CHILD) {
// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood)
return I18N::translate('(in childhood)');
}
$age = [];
// Show a zero age as "0 years", not "0 days"
if ($this->years > 0 || $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s year', '%s years', $this->years, I18N::number($this->years));
}
if ($this->months > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s month', '%s months', $this->months, I18N::number($this->months));
}
if ($this->weeks > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s week', '%s weeks', $this->weeks, I18N::number($this->weeks));
}
if ($this->days > 0) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
$age[] = I18N::plural('%s day', '%s days', $this->days, I18N::number($this->days));
}
// If an age is just a number of years, only show the number
if ($this->years > 0 && $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
$age = [I18N::number($this->years)];
}
$age_string = implode(I18N::$list_separator, $age);
if ($this->qualifier === self::SYMBOL_LESS_THAN) {
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years)
return I18N::translate('(aged less than %s)', $age_string);
}
if ($this->qualifier === self::SYMBOL_MORE_THAN) {
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years)
return I18N::translate('(aged more than %s)', $age_string);
}
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years)
return I18N::translate('(aged %s)', $age_string);
} | [
"public",
"function",
"asText",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"keyword",
"===",
"self",
"::",
"KEYWORD_STILLBORN",
")",
"{",
"// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn)",
"return",
"I18N",
"::",
"translate",
"(",
"'(stillborn)'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"keyword",
"===",
"self",
"::",
"KEYWORD_INFANT",
")",
"{",
"// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy)",
"return",
"I18N",
"::",
"translate",
"(",
"'(in infancy)'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"keyword",
"===",
"self",
"::",
"KEYWORD_CHILD",
")",
"{",
"// I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood)",
"return",
"I18N",
"::",
"translate",
"(",
"'(in childhood)'",
")",
";",
"}",
"$",
"age",
"=",
"[",
"]",
";",
"// Show a zero age as \"0 years\", not \"0 days\"",
"if",
"(",
"$",
"this",
"->",
"years",
">",
"0",
"||",
"$",
"this",
"->",
"months",
"===",
"0",
"&&",
"$",
"this",
"->",
"weeks",
"===",
"0",
"&&",
"$",
"this",
"->",
"days",
"===",
"0",
")",
"{",
"// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days",
"$",
"age",
"[",
"]",
"=",
"I18N",
"::",
"plural",
"(",
"'%s year'",
",",
"'%s years'",
",",
"$",
"this",
"->",
"years",
",",
"I18N",
"::",
"number",
"(",
"$",
"this",
"->",
"years",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"months",
">",
"0",
")",
"{",
"// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days",
"$",
"age",
"[",
"]",
"=",
"I18N",
"::",
"plural",
"(",
"'%s month'",
",",
"'%s months'",
",",
"$",
"this",
"->",
"months",
",",
"I18N",
"::",
"number",
"(",
"$",
"this",
"->",
"months",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"weeks",
">",
"0",
")",
"{",
"// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days",
"$",
"age",
"[",
"]",
"=",
"I18N",
"::",
"plural",
"(",
"'%s week'",
",",
"'%s weeks'",
",",
"$",
"this",
"->",
"weeks",
",",
"I18N",
"::",
"number",
"(",
"$",
"this",
"->",
"weeks",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"days",
">",
"0",
")",
"{",
"// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days",
"$",
"age",
"[",
"]",
"=",
"I18N",
"::",
"plural",
"(",
"'%s day'",
",",
"'%s days'",
",",
"$",
"this",
"->",
"days",
",",
"I18N",
"::",
"number",
"(",
"$",
"this",
"->",
"days",
")",
")",
";",
"}",
"// If an age is just a number of years, only show the number",
"if",
"(",
"$",
"this",
"->",
"years",
">",
"0",
"&&",
"$",
"this",
"->",
"months",
"===",
"0",
"&&",
"$",
"this",
"->",
"weeks",
"===",
"0",
"&&",
"$",
"this",
"->",
"days",
"===",
"0",
")",
"{",
"$",
"age",
"=",
"[",
"I18N",
"::",
"number",
"(",
"$",
"this",
"->",
"years",
")",
"]",
";",
"}",
"$",
"age_string",
"=",
"implode",
"(",
"I18N",
"::",
"$",
"list_separator",
",",
"$",
"age",
")",
";",
"if",
"(",
"$",
"this",
"->",
"qualifier",
"===",
"self",
"::",
"SYMBOL_LESS_THAN",
")",
"{",
"// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years)",
"return",
"I18N",
"::",
"translate",
"(",
"'(aged less than %s)'",
",",
"$",
"age_string",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"qualifier",
"===",
"self",
"::",
"SYMBOL_MORE_THAN",
")",
"{",
"// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years)",
"return",
"I18N",
"::",
"translate",
"(",
"'(aged more than %s)'",
",",
"$",
"age_string",
")",
";",
"}",
"// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years)",
"return",
"I18N",
"::",
"translate",
"(",
"'(aged %s)'",
",",
"$",
"age_string",
")",
";",
"}"
] | Convert an age to localised text. | [
"Convert",
"an",
"age",
"to",
"localised",
"text",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Age.php#L112-L171 | train |
fisharebest/webtrees | app/Report/ReportPdfLine.php | ReportPdfLine.render | public function render($renderer)
{
if ($this->x1 === ReportBaseElement::CURRENT_POSITION) {
$this->x1 = $renderer->GetX();
}
if ($this->y1 === ReportBaseElement::CURRENT_POSITION) {
$this->y1 = $renderer->GetY();
}
if ($this->x2 === ReportBaseElement::CURRENT_POSITION) {
$this->x2 = $renderer->getMaxLineWidth();
}
if ($this->y2 === ReportBaseElement::CURRENT_POSITION) {
$this->y2 = $renderer->GetY();
}
if ($renderer->getRTL()) {
$renderer->Line($renderer->getPageWidth() - $this->x1, $this->y1, $renderer->getPageWidth() - $this->x2, $this->y2);
} else {
$renderer->Line($this->x1, $this->y1, $this->x2, $this->y2);
}
} | php | public function render($renderer)
{
if ($this->x1 === ReportBaseElement::CURRENT_POSITION) {
$this->x1 = $renderer->GetX();
}
if ($this->y1 === ReportBaseElement::CURRENT_POSITION) {
$this->y1 = $renderer->GetY();
}
if ($this->x2 === ReportBaseElement::CURRENT_POSITION) {
$this->x2 = $renderer->getMaxLineWidth();
}
if ($this->y2 === ReportBaseElement::CURRENT_POSITION) {
$this->y2 = $renderer->GetY();
}
if ($renderer->getRTL()) {
$renderer->Line($renderer->getPageWidth() - $this->x1, $this->y1, $renderer->getPageWidth() - $this->x2, $this->y2);
} else {
$renderer->Line($this->x1, $this->y1, $this->x2, $this->y2);
}
} | [
"public",
"function",
"render",
"(",
"$",
"renderer",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"x1",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"$",
"this",
"->",
"x1",
"=",
"$",
"renderer",
"->",
"GetX",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"y1",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"$",
"this",
"->",
"y1",
"=",
"$",
"renderer",
"->",
"GetY",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"x2",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"$",
"this",
"->",
"x2",
"=",
"$",
"renderer",
"->",
"getMaxLineWidth",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"y2",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"$",
"this",
"->",
"y2",
"=",
"$",
"renderer",
"->",
"GetY",
"(",
")",
";",
"}",
"if",
"(",
"$",
"renderer",
"->",
"getRTL",
"(",
")",
")",
"{",
"$",
"renderer",
"->",
"Line",
"(",
"$",
"renderer",
"->",
"getPageWidth",
"(",
")",
"-",
"$",
"this",
"->",
"x1",
",",
"$",
"this",
"->",
"y1",
",",
"$",
"renderer",
"->",
"getPageWidth",
"(",
")",
"-",
"$",
"this",
"->",
"x2",
",",
"$",
"this",
"->",
"y2",
")",
";",
"}",
"else",
"{",
"$",
"renderer",
"->",
"Line",
"(",
"$",
"this",
"->",
"x1",
",",
"$",
"this",
"->",
"y1",
",",
"$",
"this",
"->",
"x2",
",",
"$",
"this",
"->",
"y2",
")",
";",
"}",
"}"
] | PDF line renderer
@param ReportTcpdf $renderer
@return void | [
"PDF",
"line",
"renderer"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportPdfLine.php#L32-L51 | train |
fisharebest/webtrees | app/Report/ReportPdfImage.php | ReportPdfImage.render | public function render($renderer)
{
static $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;
// Check for a pagebreak first
if ($renderer->checkPageBreakPDF($this->height + 5)) {
$this->y = $renderer->GetY();
}
$curx = $renderer->GetX();
// Get the current positions
if ($this->x === ReportBaseElement::CURRENT_POSITION) {
$this->x = $renderer->GetX();
} else {
// For static position add margin
$this->x = $renderer->addMarginX($this->x);
$renderer->SetX($curx);
}
if ($this->y === ReportBaseElement::CURRENT_POSITION) {
//-- first check for a collision with the last picture
if (isset($lastpicbottom)) {
if (($renderer->PageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->GetY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)
) {
$renderer->SetY($lastpicbottom + 5);
}
}
$this->y = $renderer->GetY();
} else {
$renderer->SetY($this->y);
}
if ($renderer->getRTL()) {
$renderer->Image(
$this->file,
$renderer->getPageWidth() - $this->x,
$this->y,
$this->width,
$this->height,
'',
'',
$this->line,
false,
72,
$this->align
);
} else {
$renderer->Image(
$this->file,
$this->x,
$this->y,
$this->width,
$this->height,
'',
'',
$this->line,
false,
72,
$this->align
);
}
$lastpicpage = $renderer->PageNo();
$renderer->lastpicpage = $renderer->getPage();
$lastpicleft = $this->x;
$lastpicright = $this->x + $this->width;
$lastpicbottom = $this->y + $this->height;
// Setup for the next line
if ($this->line === 'N') {
$renderer->SetY($lastpicbottom);
}
} | php | public function render($renderer)
{
static $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;
// Check for a pagebreak first
if ($renderer->checkPageBreakPDF($this->height + 5)) {
$this->y = $renderer->GetY();
}
$curx = $renderer->GetX();
// Get the current positions
if ($this->x === ReportBaseElement::CURRENT_POSITION) {
$this->x = $renderer->GetX();
} else {
// For static position add margin
$this->x = $renderer->addMarginX($this->x);
$renderer->SetX($curx);
}
if ($this->y === ReportBaseElement::CURRENT_POSITION) {
//-- first check for a collision with the last picture
if (isset($lastpicbottom)) {
if (($renderer->PageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->GetY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)
) {
$renderer->SetY($lastpicbottom + 5);
}
}
$this->y = $renderer->GetY();
} else {
$renderer->SetY($this->y);
}
if ($renderer->getRTL()) {
$renderer->Image(
$this->file,
$renderer->getPageWidth() - $this->x,
$this->y,
$this->width,
$this->height,
'',
'',
$this->line,
false,
72,
$this->align
);
} else {
$renderer->Image(
$this->file,
$this->x,
$this->y,
$this->width,
$this->height,
'',
'',
$this->line,
false,
72,
$this->align
);
}
$lastpicpage = $renderer->PageNo();
$renderer->lastpicpage = $renderer->getPage();
$lastpicleft = $this->x;
$lastpicright = $this->x + $this->width;
$lastpicbottom = $this->y + $this->height;
// Setup for the next line
if ($this->line === 'N') {
$renderer->SetY($lastpicbottom);
}
} | [
"public",
"function",
"render",
"(",
"$",
"renderer",
")",
"{",
"static",
"$",
"lastpicbottom",
",",
"$",
"lastpicpage",
",",
"$",
"lastpicleft",
",",
"$",
"lastpicright",
";",
"// Check for a pagebreak first",
"if",
"(",
"$",
"renderer",
"->",
"checkPageBreakPDF",
"(",
"$",
"this",
"->",
"height",
"+",
"5",
")",
")",
"{",
"$",
"this",
"->",
"y",
"=",
"$",
"renderer",
"->",
"GetY",
"(",
")",
";",
"}",
"$",
"curx",
"=",
"$",
"renderer",
"->",
"GetX",
"(",
")",
";",
"// Get the current positions",
"if",
"(",
"$",
"this",
"->",
"x",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"$",
"this",
"->",
"x",
"=",
"$",
"renderer",
"->",
"GetX",
"(",
")",
";",
"}",
"else",
"{",
"// For static position add margin",
"$",
"this",
"->",
"x",
"=",
"$",
"renderer",
"->",
"addMarginX",
"(",
"$",
"this",
"->",
"x",
")",
";",
"$",
"renderer",
"->",
"SetX",
"(",
"$",
"curx",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"y",
"===",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
")",
"{",
"//-- first check for a collision with the last picture",
"if",
"(",
"isset",
"(",
"$",
"lastpicbottom",
")",
")",
"{",
"if",
"(",
"(",
"$",
"renderer",
"->",
"PageNo",
"(",
")",
"==",
"$",
"lastpicpage",
")",
"&&",
"(",
"$",
"lastpicbottom",
">=",
"$",
"renderer",
"->",
"GetY",
"(",
")",
")",
"&&",
"(",
"$",
"this",
"->",
"x",
">=",
"$",
"lastpicleft",
")",
"&&",
"(",
"$",
"this",
"->",
"x",
"<=",
"$",
"lastpicright",
")",
")",
"{",
"$",
"renderer",
"->",
"SetY",
"(",
"$",
"lastpicbottom",
"+",
"5",
")",
";",
"}",
"}",
"$",
"this",
"->",
"y",
"=",
"$",
"renderer",
"->",
"GetY",
"(",
")",
";",
"}",
"else",
"{",
"$",
"renderer",
"->",
"SetY",
"(",
"$",
"this",
"->",
"y",
")",
";",
"}",
"if",
"(",
"$",
"renderer",
"->",
"getRTL",
"(",
")",
")",
"{",
"$",
"renderer",
"->",
"Image",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"renderer",
"->",
"getPageWidth",
"(",
")",
"-",
"$",
"this",
"->",
"x",
",",
"$",
"this",
"->",
"y",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
",",
"''",
",",
"''",
",",
"$",
"this",
"->",
"line",
",",
"false",
",",
"72",
",",
"$",
"this",
"->",
"align",
")",
";",
"}",
"else",
"{",
"$",
"renderer",
"->",
"Image",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"this",
"->",
"x",
",",
"$",
"this",
"->",
"y",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
",",
"''",
",",
"''",
",",
"$",
"this",
"->",
"line",
",",
"false",
",",
"72",
",",
"$",
"this",
"->",
"align",
")",
";",
"}",
"$",
"lastpicpage",
"=",
"$",
"renderer",
"->",
"PageNo",
"(",
")",
";",
"$",
"renderer",
"->",
"lastpicpage",
"=",
"$",
"renderer",
"->",
"getPage",
"(",
")",
";",
"$",
"lastpicleft",
"=",
"$",
"this",
"->",
"x",
";",
"$",
"lastpicright",
"=",
"$",
"this",
"->",
"x",
"+",
"$",
"this",
"->",
"width",
";",
"$",
"lastpicbottom",
"=",
"$",
"this",
"->",
"y",
"+",
"$",
"this",
"->",
"height",
";",
"// Setup for the next line",
"if",
"(",
"$",
"this",
"->",
"line",
"===",
"'N'",
")",
"{",
"$",
"renderer",
"->",
"SetY",
"(",
"$",
"lastpicbottom",
")",
";",
"}",
"}"
] | PDF image renderer
@param ReportTcpdf $renderer
@return void | [
"PDF",
"image",
"renderer"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportPdfImage.php#L32-L101 | train |
fisharebest/webtrees | app/Module/InteractiveTree/TreeView.php | TreeView.getPersons | public function getPersons(Tree $tree, string $request): string
{
$json_requests = explode(';', $request);
$r = [];
foreach ($json_requests as $json_request) {
$firstLetter = substr($json_request, 0, 1);
$json_request = substr($json_request, 1);
switch ($firstLetter) {
case 'c':
$families = Collection::make(explode(',', $json_request))
->map(static function (string $xref) use ($tree): ?Family {
return Family::getInstance($xref, $tree);
})
->filter();
$r[] = $this->drawChildren($families, 1, true);
break;
case 'p':
[$xref, $order] = explode('@', $json_request);
$family = Family::getInstance($xref, $tree);
if ($family instanceof Family) {
// Prefer the paternal line
$parent = $family->husband() ?? $family->wife();
// The family may have no parents (just children).
if ($parent instanceof Individual) {
$r[] = $this->drawPerson($parent, 0, 1, $family, $order, false);
}
}
break;
}
}
return json_encode($r);
} | php | public function getPersons(Tree $tree, string $request): string
{
$json_requests = explode(';', $request);
$r = [];
foreach ($json_requests as $json_request) {
$firstLetter = substr($json_request, 0, 1);
$json_request = substr($json_request, 1);
switch ($firstLetter) {
case 'c':
$families = Collection::make(explode(',', $json_request))
->map(static function (string $xref) use ($tree): ?Family {
return Family::getInstance($xref, $tree);
})
->filter();
$r[] = $this->drawChildren($families, 1, true);
break;
case 'p':
[$xref, $order] = explode('@', $json_request);
$family = Family::getInstance($xref, $tree);
if ($family instanceof Family) {
// Prefer the paternal line
$parent = $family->husband() ?? $family->wife();
// The family may have no parents (just children).
if ($parent instanceof Individual) {
$r[] = $this->drawPerson($parent, 0, 1, $family, $order, false);
}
}
break;
}
}
return json_encode($r);
} | [
"public",
"function",
"getPersons",
"(",
"Tree",
"$",
"tree",
",",
"string",
"$",
"request",
")",
":",
"string",
"{",
"$",
"json_requests",
"=",
"explode",
"(",
"';'",
",",
"$",
"request",
")",
";",
"$",
"r",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"json_requests",
"as",
"$",
"json_request",
")",
"{",
"$",
"firstLetter",
"=",
"substr",
"(",
"$",
"json_request",
",",
"0",
",",
"1",
")",
";",
"$",
"json_request",
"=",
"substr",
"(",
"$",
"json_request",
",",
"1",
")",
";",
"switch",
"(",
"$",
"firstLetter",
")",
"{",
"case",
"'c'",
":",
"$",
"families",
"=",
"Collection",
"::",
"make",
"(",
"explode",
"(",
"','",
",",
"$",
"json_request",
")",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"string",
"$",
"xref",
")",
"use",
"(",
"$",
"tree",
")",
":",
"?",
"Family",
"{",
"return",
"Family",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
";",
"$",
"r",
"[",
"]",
"=",
"$",
"this",
"->",
"drawChildren",
"(",
"$",
"families",
",",
"1",
",",
"true",
")",
";",
"break",
";",
"case",
"'p'",
":",
"[",
"$",
"xref",
",",
"$",
"order",
"]",
"=",
"explode",
"(",
"'@'",
",",
"$",
"json_request",
")",
";",
"$",
"family",
"=",
"Family",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"if",
"(",
"$",
"family",
"instanceof",
"Family",
")",
"{",
"// Prefer the paternal line",
"$",
"parent",
"=",
"$",
"family",
"->",
"husband",
"(",
")",
"??",
"$",
"family",
"->",
"wife",
"(",
")",
";",
"// The family may have no parents (just children).",
"if",
"(",
"$",
"parent",
"instanceof",
"Individual",
")",
"{",
"$",
"r",
"[",
"]",
"=",
"$",
"this",
"->",
"drawPerson",
"(",
"$",
"parent",
",",
"0",
",",
"1",
",",
"$",
"family",
",",
"$",
"order",
",",
"false",
")",
";",
"}",
"}",
"break",
";",
"}",
"}",
"return",
"json_encode",
"(",
"$",
"r",
")",
";",
"}"
] | Return a JSON structure to a JSON request
@param Tree $tree
@param string $request list of JSON requests
@return string | [
"Return",
"a",
"JSON",
"structure",
"to",
"a",
"JSON",
"request"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/InteractiveTree/TreeView.php#L75-L112 | train |
fisharebest/webtrees | app/Module/InteractiveTree/TreeView.php | TreeView.getPersonDetails | private function getPersonDetails(Individual $individual, Family $family = null): string
{
$chart_url = route('module', [
'module' => 'tree',
'action' => 'Chart',
'xref' => $individual->xref(),
'ged' => $individual->tree()->name(),
]);
$hmtl = $this->getThumbnail($individual);
$hmtl .= '<a class="tv_link" href="' . e($individual->url()) . '">' . $individual->fullName() . '</a> <a href="' . e($chart_url) . '" title="' . I18N::translate('Interactive tree of %s', strip_tags($individual->fullName())) . '" class="wt-icon-individual tv_link tv_treelink"></a>';
foreach ($individual->facts(Gedcom::BIRTH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
if ($family) {
foreach ($family->facts(Gedcom::MARRIAGE_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
}
foreach ($individual->facts(Gedcom::DEATH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
return '<div class="tv' . $individual->sex() . ' tv_person_expanded">' . $hmtl . '</div>';
} | php | private function getPersonDetails(Individual $individual, Family $family = null): string
{
$chart_url = route('module', [
'module' => 'tree',
'action' => 'Chart',
'xref' => $individual->xref(),
'ged' => $individual->tree()->name(),
]);
$hmtl = $this->getThumbnail($individual);
$hmtl .= '<a class="tv_link" href="' . e($individual->url()) . '">' . $individual->fullName() . '</a> <a href="' . e($chart_url) . '" title="' . I18N::translate('Interactive tree of %s', strip_tags($individual->fullName())) . '" class="wt-icon-individual tv_link tv_treelink"></a>';
foreach ($individual->facts(Gedcom::BIRTH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
if ($family) {
foreach ($family->facts(Gedcom::MARRIAGE_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
}
foreach ($individual->facts(Gedcom::DEATH_EVENTS, true) as $fact) {
$hmtl .= $fact->summary();
}
return '<div class="tv' . $individual->sex() . ' tv_person_expanded">' . $hmtl . '</div>';
} | [
"private",
"function",
"getPersonDetails",
"(",
"Individual",
"$",
"individual",
",",
"Family",
"$",
"family",
"=",
"null",
")",
":",
"string",
"{",
"$",
"chart_url",
"=",
"route",
"(",
"'module'",
",",
"[",
"'module'",
"=>",
"'tree'",
",",
"'action'",
"=>",
"'Chart'",
",",
"'xref'",
"=>",
"$",
"individual",
"->",
"xref",
"(",
")",
",",
"'ged'",
"=>",
"$",
"individual",
"->",
"tree",
"(",
")",
"->",
"name",
"(",
")",
",",
"]",
")",
";",
"$",
"hmtl",
"=",
"$",
"this",
"->",
"getThumbnail",
"(",
"$",
"individual",
")",
";",
"$",
"hmtl",
".=",
"'<a class=\"tv_link\" href=\"'",
".",
"e",
"(",
"$",
"individual",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"individual",
"->",
"fullName",
"(",
")",
".",
"'</a> <a href=\"'",
".",
"e",
"(",
"$",
"chart_url",
")",
".",
"'\" title=\"'",
".",
"I18N",
"::",
"translate",
"(",
"'Interactive tree of %s'",
",",
"strip_tags",
"(",
"$",
"individual",
"->",
"fullName",
"(",
")",
")",
")",
".",
"'\" class=\"wt-icon-individual tv_link tv_treelink\"></a>'",
";",
"foreach",
"(",
"$",
"individual",
"->",
"facts",
"(",
"Gedcom",
"::",
"BIRTH_EVENTS",
",",
"true",
")",
"as",
"$",
"fact",
")",
"{",
"$",
"hmtl",
".=",
"$",
"fact",
"->",
"summary",
"(",
")",
";",
"}",
"if",
"(",
"$",
"family",
")",
"{",
"foreach",
"(",
"$",
"family",
"->",
"facts",
"(",
"Gedcom",
"::",
"MARRIAGE_EVENTS",
",",
"true",
")",
"as",
"$",
"fact",
")",
"{",
"$",
"hmtl",
".=",
"$",
"fact",
"->",
"summary",
"(",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"individual",
"->",
"facts",
"(",
"Gedcom",
"::",
"DEATH_EVENTS",
",",
"true",
")",
"as",
"$",
"fact",
")",
"{",
"$",
"hmtl",
".=",
"$",
"fact",
"->",
"summary",
"(",
")",
";",
"}",
"return",
"'<div class=\"tv'",
".",
"$",
"individual",
"->",
"sex",
"(",
")",
".",
"' tv_person_expanded\">'",
".",
"$",
"hmtl",
".",
"'</div>'",
";",
"}"
] | Return the details for a person
@param Individual $individual
@param Family|null $family
@return string | [
"Return",
"the",
"details",
"for",
"a",
"person"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/InteractiveTree/TreeView.php#L142-L166 | train |
fisharebest/webtrees | app/Module/InteractiveTree/TreeView.php | TreeView.drawChildren | private function drawChildren(Collection $familyList, int $gen = 1, bool $ajax = false): string
{
$html = '';
$children2draw = [];
$f2load = [];
foreach ($familyList as $f) {
$children = $f->children();
if ($children->isNotEmpty()) {
$f2load[] = $f->xref();
foreach ($children as $child) {
// Eliminate duplicates - e.g. when adopted by a step-parent
$children2draw[$child->xref()] = $child;
}
}
}
$tc = count($children2draw);
if ($tc) {
$f2load = implode(',', $f2load);
$nbc = 0;
foreach ($children2draw as $child) {
$nbc++;
if ($tc == 1) {
$co = 'c'; // unique
} elseif ($nbc == 1) {
$co = 't'; // first
} elseif ($nbc == $tc) {
$co = 'b'; //last
} else {
$co = 'h';
}
$html .= $this->drawPerson($child, $gen - 1, -1, null, $co, false);
}
if (!$ajax) {
$html = '<td align="right"' . ($gen == 0 ? ' abbr="c' . $f2load . '"' : '') . '>' . $html . '</td>' . $this->drawHorizontalLine();
}
}
return $html;
} | php | private function drawChildren(Collection $familyList, int $gen = 1, bool $ajax = false): string
{
$html = '';
$children2draw = [];
$f2load = [];
foreach ($familyList as $f) {
$children = $f->children();
if ($children->isNotEmpty()) {
$f2load[] = $f->xref();
foreach ($children as $child) {
// Eliminate duplicates - e.g. when adopted by a step-parent
$children2draw[$child->xref()] = $child;
}
}
}
$tc = count($children2draw);
if ($tc) {
$f2load = implode(',', $f2load);
$nbc = 0;
foreach ($children2draw as $child) {
$nbc++;
if ($tc == 1) {
$co = 'c'; // unique
} elseif ($nbc == 1) {
$co = 't'; // first
} elseif ($nbc == $tc) {
$co = 'b'; //last
} else {
$co = 'h';
}
$html .= $this->drawPerson($child, $gen - 1, -1, null, $co, false);
}
if (!$ajax) {
$html = '<td align="right"' . ($gen == 0 ? ' abbr="c' . $f2load . '"' : '') . '>' . $html . '</td>' . $this->drawHorizontalLine();
}
}
return $html;
} | [
"private",
"function",
"drawChildren",
"(",
"Collection",
"$",
"familyList",
",",
"int",
"$",
"gen",
"=",
"1",
",",
"bool",
"$",
"ajax",
"=",
"false",
")",
":",
"string",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"children2draw",
"=",
"[",
"]",
";",
"$",
"f2load",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"familyList",
"as",
"$",
"f",
")",
"{",
"$",
"children",
"=",
"$",
"f",
"->",
"children",
"(",
")",
";",
"if",
"(",
"$",
"children",
"->",
"isNotEmpty",
"(",
")",
")",
"{",
"$",
"f2load",
"[",
"]",
"=",
"$",
"f",
"->",
"xref",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"// Eliminate duplicates - e.g. when adopted by a step-parent",
"$",
"children2draw",
"[",
"$",
"child",
"->",
"xref",
"(",
")",
"]",
"=",
"$",
"child",
";",
"}",
"}",
"}",
"$",
"tc",
"=",
"count",
"(",
"$",
"children2draw",
")",
";",
"if",
"(",
"$",
"tc",
")",
"{",
"$",
"f2load",
"=",
"implode",
"(",
"','",
",",
"$",
"f2load",
")",
";",
"$",
"nbc",
"=",
"0",
";",
"foreach",
"(",
"$",
"children2draw",
"as",
"$",
"child",
")",
"{",
"$",
"nbc",
"++",
";",
"if",
"(",
"$",
"tc",
"==",
"1",
")",
"{",
"$",
"co",
"=",
"'c'",
";",
"// unique",
"}",
"elseif",
"(",
"$",
"nbc",
"==",
"1",
")",
"{",
"$",
"co",
"=",
"'t'",
";",
"// first",
"}",
"elseif",
"(",
"$",
"nbc",
"==",
"$",
"tc",
")",
"{",
"$",
"co",
"=",
"'b'",
";",
"//last",
"}",
"else",
"{",
"$",
"co",
"=",
"'h'",
";",
"}",
"$",
"html",
".=",
"$",
"this",
"->",
"drawPerson",
"(",
"$",
"child",
",",
"$",
"gen",
"-",
"1",
",",
"-",
"1",
",",
"null",
",",
"$",
"co",
",",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"ajax",
")",
"{",
"$",
"html",
"=",
"'<td align=\"right\"'",
".",
"(",
"$",
"gen",
"==",
"0",
"?",
"' abbr=\"c'",
".",
"$",
"f2load",
".",
"'\"'",
":",
"''",
")",
".",
"'>'",
".",
"$",
"html",
".",
"'</td>'",
".",
"$",
"this",
"->",
"drawHorizontalLine",
"(",
")",
";",
"}",
"}",
"return",
"$",
"html",
";",
"}"
] | Draw the children for some families
@param Collection $familyList array of families to draw the children for
@param int $gen number of generations to draw
@param bool $ajax true for an ajax call
@return string | [
"Draw",
"the",
"children",
"for",
"some",
"families"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/InteractiveTree/TreeView.php#L177-L216 | train |
fisharebest/webtrees | app/Module/InteractiveTree/TreeView.php | TreeView.drawPersonName | private function drawPersonName(Individual $individual, string $dashed): string
{
$family = $individual->primaryChildFamily();
if ($family) {
$family_name = strip_tags($family->fullName());
} else {
$family_name = I18N::translateContext('unknown family', 'unknown');
}
switch ($individual->sex()) {
case 'M':
/* I18N: e.g. “Son of [father name & mother name]” */
$title = ' title="' . I18N::translate('Son of %s', $family_name) . '"';
break;
case 'F':
/* I18N: e.g. “Daughter of [father name & mother name]” */
$title = ' title="' . I18N::translate('Daughter of %s', $family_name) . '"';
break;
default:
/* I18N: e.g. “Child of [father name & mother name]” */
$title = ' title="' . I18N::translate('Child of %s', $family_name) . '"';
break;
}
$sex = $individual->sex();
return '<div class="tv' . $sex . ' ' . $dashed . '"' . $title . '><a href="' . e($individual->url()) . '"></a>' . $individual->fullName() . ' <span class="dates">' . $individual->getLifeSpan() . '</span></div>';
} | php | private function drawPersonName(Individual $individual, string $dashed): string
{
$family = $individual->primaryChildFamily();
if ($family) {
$family_name = strip_tags($family->fullName());
} else {
$family_name = I18N::translateContext('unknown family', 'unknown');
}
switch ($individual->sex()) {
case 'M':
/* I18N: e.g. “Son of [father name & mother name]” */
$title = ' title="' . I18N::translate('Son of %s', $family_name) . '"';
break;
case 'F':
/* I18N: e.g. “Daughter of [father name & mother name]” */
$title = ' title="' . I18N::translate('Daughter of %s', $family_name) . '"';
break;
default:
/* I18N: e.g. “Child of [father name & mother name]” */
$title = ' title="' . I18N::translate('Child of %s', $family_name) . '"';
break;
}
$sex = $individual->sex();
return '<div class="tv' . $sex . ' ' . $dashed . '"' . $title . '><a href="' . e($individual->url()) . '"></a>' . $individual->fullName() . ' <span class="dates">' . $individual->getLifeSpan() . '</span></div>';
} | [
"private",
"function",
"drawPersonName",
"(",
"Individual",
"$",
"individual",
",",
"string",
"$",
"dashed",
")",
":",
"string",
"{",
"$",
"family",
"=",
"$",
"individual",
"->",
"primaryChildFamily",
"(",
")",
";",
"if",
"(",
"$",
"family",
")",
"{",
"$",
"family_name",
"=",
"strip_tags",
"(",
"$",
"family",
"->",
"fullName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"family_name",
"=",
"I18N",
"::",
"translateContext",
"(",
"'unknown family'",
",",
"'unknown'",
")",
";",
"}",
"switch",
"(",
"$",
"individual",
"->",
"sex",
"(",
")",
")",
"{",
"case",
"'M'",
":",
"/* I18N: e.g. “Son of [father name & mother name]” */",
"$",
"title",
"=",
"' title=\"'",
".",
"I18N",
"::",
"translate",
"(",
"'Son of %s'",
",",
"$",
"family_name",
")",
".",
"'\"'",
";",
"break",
";",
"case",
"'F'",
":",
"/* I18N: e.g. “Daughter of [father name & mother name]” */",
"$",
"title",
"=",
"' title=\"'",
".",
"I18N",
"::",
"translate",
"(",
"'Daughter of %s'",
",",
"$",
"family_name",
")",
".",
"'\"'",
";",
"break",
";",
"default",
":",
"/* I18N: e.g. “Child of [father name & mother name]” */",
"$",
"title",
"=",
"' title=\"'",
".",
"I18N",
"::",
"translate",
"(",
"'Child of %s'",
",",
"$",
"family_name",
")",
".",
"'\"'",
";",
"break",
";",
"}",
"$",
"sex",
"=",
"$",
"individual",
"->",
"sex",
"(",
")",
";",
"return",
"'<div class=\"tv'",
".",
"$",
"sex",
".",
"' '",
".",
"$",
"dashed",
".",
"'\"'",
".",
"$",
"title",
".",
"'><a href=\"'",
".",
"e",
"(",
"$",
"individual",
"->",
"url",
"(",
")",
")",
".",
"'\"></a>'",
".",
"$",
"individual",
"->",
"fullName",
"(",
")",
".",
"' <span class=\"dates\">'",
".",
"$",
"individual",
"->",
"getLifeSpan",
"(",
")",
".",
"'</span></div>'",
";",
"}"
] | Draw a person name preceded by sex icon, with parents as tooltip
@param Individual $individual The individual to draw
@param string $dashed Either "dashed", to print dashed top border to separate multiple spouses, or ""
@return string | [
"Draw",
"a",
"person",
"name",
"preceded",
"by",
"sex",
"icon",
"with",
"parents",
"as",
"tooltip"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/InteractiveTree/TreeView.php#L342-L367 | train |
fisharebest/webtrees | app/Fact.php | Fact.value | public function value(): string
{
if (preg_match('/^1 (?:' . $this->tag . ') ?(.*(?:(?:\n2 CONT ?.*)*))/', $this->gedcom, $match)) {
return preg_replace("/\n2 CONT ?/", "\n", $match[1]);
}
return '';
} | php | public function value(): string
{
if (preg_match('/^1 (?:' . $this->tag . ') ?(.*(?:(?:\n2 CONT ?.*)*))/', $this->gedcom, $match)) {
return preg_replace("/\n2 CONT ?/", "\n", $match[1]);
}
return '';
} | [
"public",
"function",
"value",
"(",
")",
":",
"string",
"{",
"if",
"(",
"preg_match",
"(",
"'/^1 (?:'",
".",
"$",
"this",
"->",
"tag",
".",
"') ?(.*(?:(?:\\n2 CONT ?.*)*))/'",
",",
"$",
"this",
"->",
"gedcom",
",",
"$",
"match",
")",
")",
"{",
"return",
"preg_replace",
"(",
"\"/\\n2 CONT ?/\"",
",",
"\"\\n\"",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Get the value of level 1 data in the fact
Allow for multi-line values
@return string | [
"Get",
"the",
"value",
"of",
"level",
"1",
"data",
"in",
"the",
"fact",
"Allow",
"for",
"multi",
"-",
"line",
"values"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L194-L201 | train |
fisharebest/webtrees | app/Fact.php | Fact.target | public function target()
{
$xref = trim($this->value(), '@');
switch ($this->tag) {
case 'FAMC':
case 'FAMS':
return Family::getInstance($xref, $this->record()->tree());
case 'HUSB':
case 'WIFE':
case 'CHIL':
return Individual::getInstance($xref, $this->record()->tree());
case 'SOUR':
return Source::getInstance($xref, $this->record()->tree());
case 'OBJE':
return Media::getInstance($xref, $this->record()->tree());
case 'REPO':
return Repository::getInstance($xref, $this->record()->tree());
case 'NOTE':
return Note::getInstance($xref, $this->record()->tree());
default:
return GedcomRecord::getInstance($xref, $this->record()->tree());
}
} | php | public function target()
{
$xref = trim($this->value(), '@');
switch ($this->tag) {
case 'FAMC':
case 'FAMS':
return Family::getInstance($xref, $this->record()->tree());
case 'HUSB':
case 'WIFE':
case 'CHIL':
return Individual::getInstance($xref, $this->record()->tree());
case 'SOUR':
return Source::getInstance($xref, $this->record()->tree());
case 'OBJE':
return Media::getInstance($xref, $this->record()->tree());
case 'REPO':
return Repository::getInstance($xref, $this->record()->tree());
case 'NOTE':
return Note::getInstance($xref, $this->record()->tree());
default:
return GedcomRecord::getInstance($xref, $this->record()->tree());
}
} | [
"public",
"function",
"target",
"(",
")",
"{",
"$",
"xref",
"=",
"trim",
"(",
"$",
"this",
"->",
"value",
"(",
")",
",",
"'@'",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"tag",
")",
"{",
"case",
"'FAMC'",
":",
"case",
"'FAMS'",
":",
"return",
"Family",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"case",
"'HUSB'",
":",
"case",
"'WIFE'",
":",
"case",
"'CHIL'",
":",
"return",
"Individual",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"case",
"'SOUR'",
":",
"return",
"Source",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"case",
"'OBJE'",
":",
"return",
"Media",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"case",
"'REPO'",
":",
"return",
"Repository",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"case",
"'NOTE'",
":",
"return",
"Note",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"default",
":",
"return",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"}",
"}"
] | Get the record to which this fact links
@return Individual|Family|Source|Repository|Media|Note|GedcomRecord|null | [
"Get",
"the",
"record",
"to",
"which",
"this",
"fact",
"links"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L208-L230 | train |
fisharebest/webtrees | app/Fact.php | Fact.attribute | public function attribute($tag): string
{
if (preg_match('/\n2 (?:' . $tag . ') ?(.*(?:(?:\n3 CONT ?.*)*)*)/', $this->gedcom, $match)) {
return preg_replace("/\n3 CONT ?/", "\n", $match[1]);
}
return '';
} | php | public function attribute($tag): string
{
if (preg_match('/\n2 (?:' . $tag . ') ?(.*(?:(?:\n3 CONT ?.*)*)*)/', $this->gedcom, $match)) {
return preg_replace("/\n3 CONT ?/", "\n", $match[1]);
}
return '';
} | [
"public",
"function",
"attribute",
"(",
"$",
"tag",
")",
":",
"string",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\n2 (?:'",
".",
"$",
"tag",
".",
"') ?(.*(?:(?:\\n3 CONT ?.*)*)*)/'",
",",
"$",
"this",
"->",
"gedcom",
",",
"$",
"match",
")",
")",
"{",
"return",
"preg_replace",
"(",
"\"/\\n3 CONT ?/\"",
",",
"\"\\n\"",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Get the value of level 2 data in the fact
@param string $tag
@return string | [
"Get",
"the",
"value",
"of",
"level",
"2",
"data",
"in",
"the",
"fact"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L239-L246 | train |
fisharebest/webtrees | app/Fact.php | Fact.canShow | public function canShow(int $access_level = null): bool
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->record()->tree());
}
// Does this record have an explicit RESN?
if (strpos($this->gedcom, "\n2 RESN confidential") !== false) {
return Auth::PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN privacy") !== false) {
return Auth::PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN none") !== false) {
return true;
}
// Does this record have a default RESN?
$xref = $this->record->xref();
$fact_privacy = $this->record->tree()->getFactPrivacy();
$individual_fact_privacy = $this->record->tree()->getIndividualFactPrivacy();
if (isset($individual_fact_privacy[$xref][$this->tag])) {
return $individual_fact_privacy[$xref][$this->tag] >= $access_level;
}
if (isset($fact_privacy[$this->tag])) {
return $fact_privacy[$this->tag] >= $access_level;
}
// No restrictions - it must be public
return true;
} | php | public function canShow(int $access_level = null): bool
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->record()->tree());
}
// Does this record have an explicit RESN?
if (strpos($this->gedcom, "\n2 RESN confidential") !== false) {
return Auth::PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN privacy") !== false) {
return Auth::PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n2 RESN none") !== false) {
return true;
}
// Does this record have a default RESN?
$xref = $this->record->xref();
$fact_privacy = $this->record->tree()->getFactPrivacy();
$individual_fact_privacy = $this->record->tree()->getIndividualFactPrivacy();
if (isset($individual_fact_privacy[$xref][$this->tag])) {
return $individual_fact_privacy[$xref][$this->tag] >= $access_level;
}
if (isset($fact_privacy[$this->tag])) {
return $fact_privacy[$this->tag] >= $access_level;
}
// No restrictions - it must be public
return true;
} | [
"public",
"function",
"canShow",
"(",
"int",
"$",
"access_level",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"access_level",
"===",
"null",
")",
"{",
"$",
"access_level",
"=",
"Auth",
"::",
"accessLevel",
"(",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"}",
"// Does this record have an explicit RESN?",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n2 RESN confidential\"",
")",
"!==",
"false",
")",
"{",
"return",
"Auth",
"::",
"PRIV_NONE",
">=",
"$",
"access_level",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n2 RESN privacy\"",
")",
"!==",
"false",
")",
"{",
"return",
"Auth",
"::",
"PRIV_USER",
">=",
"$",
"access_level",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n2 RESN none\"",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// Does this record have a default RESN?",
"$",
"xref",
"=",
"$",
"this",
"->",
"record",
"->",
"xref",
"(",
")",
";",
"$",
"fact_privacy",
"=",
"$",
"this",
"->",
"record",
"->",
"tree",
"(",
")",
"->",
"getFactPrivacy",
"(",
")",
";",
"$",
"individual_fact_privacy",
"=",
"$",
"this",
"->",
"record",
"->",
"tree",
"(",
")",
"->",
"getIndividualFactPrivacy",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"individual_fact_privacy",
"[",
"$",
"xref",
"]",
"[",
"$",
"this",
"->",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"individual_fact_privacy",
"[",
"$",
"xref",
"]",
"[",
"$",
"this",
"->",
"tag",
"]",
">=",
"$",
"access_level",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"fact_privacy",
"[",
"$",
"this",
"->",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"fact_privacy",
"[",
"$",
"this",
"->",
"tag",
"]",
">=",
"$",
"access_level",
";",
"}",
"// No restrictions - it must be public",
"return",
"true",
";",
"}"
] | Do the privacy rules allow us to display this fact to the current user
@param int|null $access_level
@return bool | [
"Do",
"the",
"privacy",
"rules",
"allow",
"us",
"to",
"display",
"this",
"fact",
"to",
"the",
"current",
"user"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L287-L317 | train |
fisharebest/webtrees | app/Fact.php | Fact.canEdit | public function canEdit(): bool
{
if ($this->isPendingDeletion()) {
return false;
}
if (Auth::isManager($this->record->tree())) {
return true;
}
// Members cannot edit RESN, CHAN and locked records
return Auth::isEditor($this->record->tree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->getTag() !== 'RESN' && $this->getTag() !== 'CHAN';
} | php | public function canEdit(): bool
{
if ($this->isPendingDeletion()) {
return false;
}
if (Auth::isManager($this->record->tree())) {
return true;
}
// Members cannot edit RESN, CHAN and locked records
return Auth::isEditor($this->record->tree()) && strpos($this->gedcom, "\n2 RESN locked") === false && $this->getTag() !== 'RESN' && $this->getTag() !== 'CHAN';
} | [
"public",
"function",
"canEdit",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isPendingDeletion",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Auth",
"::",
"isManager",
"(",
"$",
"this",
"->",
"record",
"->",
"tree",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Members cannot edit RESN, CHAN and locked records",
"return",
"Auth",
"::",
"isEditor",
"(",
"$",
"this",
"->",
"record",
"->",
"tree",
"(",
")",
")",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n2 RESN locked\"",
")",
"===",
"false",
"&&",
"$",
"this",
"->",
"getTag",
"(",
")",
"!==",
"'RESN'",
"&&",
"$",
"this",
"->",
"getTag",
"(",
")",
"!==",
"'CHAN'",
";",
"}"
] | Check whether this fact is protected against edit
@return bool | [
"Check",
"whether",
"this",
"fact",
"is",
"protected",
"against",
"edit"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L324-L336 | train |
fisharebest/webtrees | app/Fact.php | Fact.place | public function place(): Place
{
if ($this->place === null) {
$this->place = new Place($this->attribute('PLAC'), $this->record()->tree());
}
return $this->place;
} | php | public function place(): Place
{
if ($this->place === null) {
$this->place = new Place($this->attribute('PLAC'), $this->record()->tree());
}
return $this->place;
} | [
"public",
"function",
"place",
"(",
")",
":",
"Place",
"{",
"if",
"(",
"$",
"this",
"->",
"place",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"place",
"=",
"new",
"Place",
"(",
"$",
"this",
"->",
"attribute",
"(",
"'PLAC'",
")",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"place",
";",
"}"
] | The place where the event occured.
@return Place | [
"The",
"place",
"where",
"the",
"event",
"occured",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L343-L350 | train |
fisharebest/webtrees | app/Fact.php | Fact.date | public function date(): Date
{
if ($this->date === null) {
$this->date = new Date($this->attribute('DATE'));
}
return $this->date;
} | php | public function date(): Date
{
if ($this->date === null) {
$this->date = new Date($this->attribute('DATE'));
}
return $this->date;
} | [
"public",
"function",
"date",
"(",
")",
":",
"Date",
"{",
"if",
"(",
"$",
"this",
"->",
"date",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"date",
"=",
"new",
"Date",
"(",
"$",
"this",
"->",
"attribute",
"(",
"'DATE'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"date",
";",
"}"
] | Get the date for this fact.
We can call this function many times, especially when sorting,
so keep a copy of the date.
@return Date | [
"Get",
"the",
"date",
"for",
"this",
"fact",
".",
"We",
"can",
"call",
"this",
"function",
"many",
"times",
"especially",
"when",
"sorting",
"so",
"keep",
"a",
"copy",
"of",
"the",
"date",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L359-L366 | train |
fisharebest/webtrees | app/Fact.php | Fact.label | public function label(): string
{
// Custom FACT/EVEN - with a TYPE
if (($this->tag === 'FACT' || $this->tag === 'EVEN') && $this->attribute('TYPE') !== '') {
return I18N::translate(e($this->attribute('TYPE')));
}
return GedcomTag::getLabel($this->tag, $this->record);
} | php | public function label(): string
{
// Custom FACT/EVEN - with a TYPE
if (($this->tag === 'FACT' || $this->tag === 'EVEN') && $this->attribute('TYPE') !== '') {
return I18N::translate(e($this->attribute('TYPE')));
}
return GedcomTag::getLabel($this->tag, $this->record);
} | [
"public",
"function",
"label",
"(",
")",
":",
"string",
"{",
"// Custom FACT/EVEN - with a TYPE",
"if",
"(",
"(",
"$",
"this",
"->",
"tag",
"===",
"'FACT'",
"||",
"$",
"this",
"->",
"tag",
"===",
"'EVEN'",
")",
"&&",
"$",
"this",
"->",
"attribute",
"(",
"'TYPE'",
")",
"!==",
"''",
")",
"{",
"return",
"I18N",
"::",
"translate",
"(",
"e",
"(",
"$",
"this",
"->",
"attribute",
"(",
"'TYPE'",
")",
")",
")",
";",
"}",
"return",
"GedcomTag",
"::",
"getLabel",
"(",
"$",
"this",
"->",
"tag",
",",
"$",
"this",
"->",
"record",
")",
";",
"}"
] | Get the name of this fact type, for use as a label.
@return string | [
"Get",
"the",
"name",
"of",
"this",
"fact",
"type",
"for",
"use",
"as",
"a",
"label",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L425-L433 | train |
fisharebest/webtrees | app/Fact.php | Fact.getCitations | public function getCitations(): array
{
preg_match_all('/\n(2 SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[3-9] .*)*)/', $this->gedcom(), $matches, PREG_SET_ORDER);
$citations = [];
foreach ($matches as $match) {
$source = Source::getInstance($match[2], $this->record()->tree());
if ($source && $source->canShow()) {
$citations[] = $match[1];
}
}
return $citations;
} | php | public function getCitations(): array
{
preg_match_all('/\n(2 SOUR @(' . Gedcom::REGEX_XREF . ')@(?:\n[3-9] .*)*)/', $this->gedcom(), $matches, PREG_SET_ORDER);
$citations = [];
foreach ($matches as $match) {
$source = Source::getInstance($match[2], $this->record()->tree());
if ($source && $source->canShow()) {
$citations[] = $match[1];
}
}
return $citations;
} | [
"public",
"function",
"getCitations",
"(",
")",
":",
"array",
"{",
"preg_match_all",
"(",
"'/\\n(2 SOUR @('",
".",
"Gedcom",
"::",
"REGEX_XREF",
".",
"')@(?:\\n[3-9] .*)*)/'",
",",
"$",
"this",
"->",
"gedcom",
"(",
")",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
";",
"$",
"citations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"{",
"$",
"source",
"=",
"Source",
"::",
"getInstance",
"(",
"$",
"match",
"[",
"2",
"]",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"if",
"(",
"$",
"source",
"&&",
"$",
"source",
"->",
"canShow",
"(",
")",
")",
"{",
"$",
"citations",
"[",
"]",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"}",
"return",
"$",
"citations",
";",
"}"
] | Source citations linked to this fact
@return string[] | [
"Source",
"citations",
"linked",
"to",
"this",
"fact"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L482-L494 | train |
fisharebest/webtrees | app/Fact.php | Fact.getMedia | public function getMedia(): array
{
$media = [];
preg_match_all('/\n2 OBJE @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom(), $matches);
foreach ($matches[1] as $match) {
$obje = Media::getInstance($match, $this->record()->tree());
if ($obje && $obje->canShow()) {
$media[] = $obje;
}
}
return $media;
} | php | public function getMedia(): array
{
$media = [];
preg_match_all('/\n2 OBJE @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom(), $matches);
foreach ($matches[1] as $match) {
$obje = Media::getInstance($match, $this->record()->tree());
if ($obje && $obje->canShow()) {
$media[] = $obje;
}
}
return $media;
} | [
"public",
"function",
"getMedia",
"(",
")",
":",
"array",
"{",
"$",
"media",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"'/\\n2 OBJE @('",
".",
"Gedcom",
"::",
"REGEX_XREF",
".",
"')@/'",
",",
"$",
"this",
"->",
"gedcom",
"(",
")",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"obje",
"=",
"Media",
"::",
"getInstance",
"(",
"$",
"match",
",",
"$",
"this",
"->",
"record",
"(",
")",
"->",
"tree",
"(",
")",
")",
";",
"if",
"(",
"$",
"obje",
"&&",
"$",
"obje",
"->",
"canShow",
"(",
")",
")",
"{",
"$",
"media",
"[",
"]",
"=",
"$",
"obje",
";",
"}",
"}",
"return",
"$",
"media",
";",
"}"
] | Media objects linked to this fact
@return Media[] | [
"Media",
"objects",
"linked",
"to",
"this",
"fact"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L527-L539 | train |
fisharebest/webtrees | app/Fact.php | Fact.dateComparator | private static function dateComparator(): Closure
{
return static function (Fact $a, Fact $b): int {
if ($a->date()->isOK() && $b->date()->isOK()) {
// If both events have dates, compare by date
$ret = Date::compare($a->date(), $b->date());
if ($ret === 0) {
// If dates overlap, compare by fact type
$ret = self::typeComparator()($a, $b);
// If the fact type is also the same, retain the initial order
if ($ret === 0) {
$ret = $a->sortOrder <=> $b->sortOrder;
}
}
return $ret;
}
// One or both events have no date - retain the initial order
return $a->sortOrder <=> $b->sortOrder;
};
} | php | private static function dateComparator(): Closure
{
return static function (Fact $a, Fact $b): int {
if ($a->date()->isOK() && $b->date()->isOK()) {
// If both events have dates, compare by date
$ret = Date::compare($a->date(), $b->date());
if ($ret === 0) {
// If dates overlap, compare by fact type
$ret = self::typeComparator()($a, $b);
// If the fact type is also the same, retain the initial order
if ($ret === 0) {
$ret = $a->sortOrder <=> $b->sortOrder;
}
}
return $ret;
}
// One or both events have no date - retain the initial order
return $a->sortOrder <=> $b->sortOrder;
};
} | [
"private",
"static",
"function",
"dateComparator",
"(",
")",
":",
"Closure",
"{",
"return",
"static",
"function",
"(",
"Fact",
"$",
"a",
",",
"Fact",
"$",
"b",
")",
":",
"int",
"{",
"if",
"(",
"$",
"a",
"->",
"date",
"(",
")",
"->",
"isOK",
"(",
")",
"&&",
"$",
"b",
"->",
"date",
"(",
")",
"->",
"isOK",
"(",
")",
")",
"{",
"// If both events have dates, compare by date",
"$",
"ret",
"=",
"Date",
"::",
"compare",
"(",
"$",
"a",
"->",
"date",
"(",
")",
",",
"$",
"b",
"->",
"date",
"(",
")",
")",
";",
"if",
"(",
"$",
"ret",
"===",
"0",
")",
"{",
"// If dates overlap, compare by fact type",
"$",
"ret",
"=",
"self",
"::",
"typeComparator",
"(",
")",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"// If the fact type is also the same, retain the initial order",
"if",
"(",
"$",
"ret",
"===",
"0",
")",
"{",
"$",
"ret",
"=",
"$",
"a",
"->",
"sortOrder",
"<=>",
"$",
"b",
"->",
"sortOrder",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}",
"// One or both events have no date - retain the initial order",
"return",
"$",
"a",
"->",
"sortOrder",
"<=>",
"$",
"b",
"->",
"sortOrder",
";",
"}",
";",
"}"
] | Helper functions to sort facts
@return Closure | [
"Helper",
"functions",
"to",
"sort",
"facts"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L592-L615 | train |
fisharebest/webtrees | app/Fact.php | Fact.typeComparator | public static function typeComparator(): Closure
{
static $factsort = [];
if (empty($factsort)) {
$factsort = array_flip(self::FACT_ORDER);
}
return static function (Fact $a, Fact $b) use ($factsort): int {
// Facts from same families stay grouped together
// Keep MARR and DIV from the same families from mixing with events from other FAMs
// Use the original order in which the facts were added
if ($a->record instanceof Family && $b->record instanceof Family && $a->record !== $b->record) {
return $a->sortOrder - $b->sortOrder;
}
$atag = $a->getTag();
$btag = $b->getTag();
// Events not in the above list get mapped onto one that is.
if (!array_key_exists($atag, $factsort)) {
if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $atag, $match)) {
$atag = $match[1];
} else {
$atag = '_????_';
}
}
if (!array_key_exists($btag, $factsort)) {
if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $btag, $match)) {
$btag = $match[1];
} else {
$btag = '_????_';
}
}
// - Don't let dated after DEAT/BURI facts sort non-dated facts before DEAT/BURI
// - Treat dated after BURI facts as BURI instead
if ($a->attribute('DATE') !== '' && $factsort[$atag] > $factsort['BURI'] && $factsort[$atag] < $factsort['CHAN']) {
$atag = 'BURI';
}
if ($b->attribute('DATE') !== '' && $factsort[$btag] > $factsort['BURI'] && $factsort[$btag] < $factsort['CHAN']) {
$btag = 'BURI';
}
$ret = $factsort[$atag] - $factsort[$btag];
// If facts are the same then put dated facts before non-dated facts
if ($ret == 0) {
if ($a->attribute('DATE') !== '' && $b->attribute('DATE') === '') {
return -1;
}
if ($b->attribute('DATE') !== '' && $a->attribute('DATE') === '') {
return 1;
}
// If no sorting preference, then keep original ordering
$ret = $a->sortOrder - $b->sortOrder;
}
return $ret;
};
} | php | public static function typeComparator(): Closure
{
static $factsort = [];
if (empty($factsort)) {
$factsort = array_flip(self::FACT_ORDER);
}
return static function (Fact $a, Fact $b) use ($factsort): int {
// Facts from same families stay grouped together
// Keep MARR and DIV from the same families from mixing with events from other FAMs
// Use the original order in which the facts were added
if ($a->record instanceof Family && $b->record instanceof Family && $a->record !== $b->record) {
return $a->sortOrder - $b->sortOrder;
}
$atag = $a->getTag();
$btag = $b->getTag();
// Events not in the above list get mapped onto one that is.
if (!array_key_exists($atag, $factsort)) {
if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $atag, $match)) {
$atag = $match[1];
} else {
$atag = '_????_';
}
}
if (!array_key_exists($btag, $factsort)) {
if (preg_match('/^(_(BIRT|MARR|DEAT|BURI)_)/', $btag, $match)) {
$btag = $match[1];
} else {
$btag = '_????_';
}
}
// - Don't let dated after DEAT/BURI facts sort non-dated facts before DEAT/BURI
// - Treat dated after BURI facts as BURI instead
if ($a->attribute('DATE') !== '' && $factsort[$atag] > $factsort['BURI'] && $factsort[$atag] < $factsort['CHAN']) {
$atag = 'BURI';
}
if ($b->attribute('DATE') !== '' && $factsort[$btag] > $factsort['BURI'] && $factsort[$btag] < $factsort['CHAN']) {
$btag = 'BURI';
}
$ret = $factsort[$atag] - $factsort[$btag];
// If facts are the same then put dated facts before non-dated facts
if ($ret == 0) {
if ($a->attribute('DATE') !== '' && $b->attribute('DATE') === '') {
return -1;
}
if ($b->attribute('DATE') !== '' && $a->attribute('DATE') === '') {
return 1;
}
// If no sorting preference, then keep original ordering
$ret = $a->sortOrder - $b->sortOrder;
}
return $ret;
};
} | [
"public",
"static",
"function",
"typeComparator",
"(",
")",
":",
"Closure",
"{",
"static",
"$",
"factsort",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"factsort",
")",
")",
"{",
"$",
"factsort",
"=",
"array_flip",
"(",
"self",
"::",
"FACT_ORDER",
")",
";",
"}",
"return",
"static",
"function",
"(",
"Fact",
"$",
"a",
",",
"Fact",
"$",
"b",
")",
"use",
"(",
"$",
"factsort",
")",
":",
"int",
"{",
"// Facts from same families stay grouped together",
"// Keep MARR and DIV from the same families from mixing with events from other FAMs",
"// Use the original order in which the facts were added",
"if",
"(",
"$",
"a",
"->",
"record",
"instanceof",
"Family",
"&&",
"$",
"b",
"->",
"record",
"instanceof",
"Family",
"&&",
"$",
"a",
"->",
"record",
"!==",
"$",
"b",
"->",
"record",
")",
"{",
"return",
"$",
"a",
"->",
"sortOrder",
"-",
"$",
"b",
"->",
"sortOrder",
";",
"}",
"$",
"atag",
"=",
"$",
"a",
"->",
"getTag",
"(",
")",
";",
"$",
"btag",
"=",
"$",
"b",
"->",
"getTag",
"(",
")",
";",
"// Events not in the above list get mapped onto one that is.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"atag",
",",
"$",
"factsort",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(_(BIRT|MARR|DEAT|BURI)_)/'",
",",
"$",
"atag",
",",
"$",
"match",
")",
")",
"{",
"$",
"atag",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"atag",
"=",
"'_????_'",
";",
"}",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"btag",
",",
"$",
"factsort",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(_(BIRT|MARR|DEAT|BURI)_)/'",
",",
"$",
"btag",
",",
"$",
"match",
")",
")",
"{",
"$",
"btag",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"btag",
"=",
"'_????_'",
";",
"}",
"}",
"// - Don't let dated after DEAT/BURI facts sort non-dated facts before DEAT/BURI",
"// - Treat dated after BURI facts as BURI instead",
"if",
"(",
"$",
"a",
"->",
"attribute",
"(",
"'DATE'",
")",
"!==",
"''",
"&&",
"$",
"factsort",
"[",
"$",
"atag",
"]",
">",
"$",
"factsort",
"[",
"'BURI'",
"]",
"&&",
"$",
"factsort",
"[",
"$",
"atag",
"]",
"<",
"$",
"factsort",
"[",
"'CHAN'",
"]",
")",
"{",
"$",
"atag",
"=",
"'BURI'",
";",
"}",
"if",
"(",
"$",
"b",
"->",
"attribute",
"(",
"'DATE'",
")",
"!==",
"''",
"&&",
"$",
"factsort",
"[",
"$",
"btag",
"]",
">",
"$",
"factsort",
"[",
"'BURI'",
"]",
"&&",
"$",
"factsort",
"[",
"$",
"btag",
"]",
"<",
"$",
"factsort",
"[",
"'CHAN'",
"]",
")",
"{",
"$",
"btag",
"=",
"'BURI'",
";",
"}",
"$",
"ret",
"=",
"$",
"factsort",
"[",
"$",
"atag",
"]",
"-",
"$",
"factsort",
"[",
"$",
"btag",
"]",
";",
"// If facts are the same then put dated facts before non-dated facts",
"if",
"(",
"$",
"ret",
"==",
"0",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"attribute",
"(",
"'DATE'",
")",
"!==",
"''",
"&&",
"$",
"b",
"->",
"attribute",
"(",
"'DATE'",
")",
"===",
"''",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"b",
"->",
"attribute",
"(",
"'DATE'",
")",
"!==",
"''",
"&&",
"$",
"a",
"->",
"attribute",
"(",
"'DATE'",
")",
"===",
"''",
")",
"{",
"return",
"1",
";",
"}",
"// If no sorting preference, then keep original ordering",
"$",
"ret",
"=",
"$",
"a",
"->",
"sortOrder",
"-",
"$",
"b",
"->",
"sortOrder",
";",
"}",
"return",
"$",
"ret",
";",
"}",
";",
"}"
] | Helper functions to sort facts.
@return Closure | [
"Helper",
"functions",
"to",
"sort",
"facts",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L622-L686 | train |
fisharebest/webtrees | app/Fact.php | Fact.sortFacts | public static function sortFacts(Collection $unsorted): Collection
{
$dated = [];
$nondated = [];
$sorted = [];
// Split the array into dated and non-dated arrays
$order = 0;
foreach ($unsorted as $fact) {
$fact->sortOrder = $order;
$order++;
if ($fact->date()->isOK()) {
$dated[] = $fact;
} else {
$nondated[] = $fact;
}
}
usort($dated, self::dateComparator());
usort($nondated, self::typeComparator());
// Merge the arrays
$dc = count($dated);
$nc = count($nondated);
$i = 0;
$j = 0;
// while there is anything in the dated array continue merging
while ($i < $dc) {
// compare each fact by type to merge them in order
if ($j < $nc && self::typeComparator()($dated[$i], $nondated[$j]) > 0) {
$sorted[] = $nondated[$j];
$j++;
} else {
$sorted[] = $dated[$i];
$i++;
}
}
// get anything that might be left in the nondated array
while ($j < $nc) {
$sorted[] = $nondated[$j];
$j++;
}
return new Collection($sorted);
} | php | public static function sortFacts(Collection $unsorted): Collection
{
$dated = [];
$nondated = [];
$sorted = [];
// Split the array into dated and non-dated arrays
$order = 0;
foreach ($unsorted as $fact) {
$fact->sortOrder = $order;
$order++;
if ($fact->date()->isOK()) {
$dated[] = $fact;
} else {
$nondated[] = $fact;
}
}
usort($dated, self::dateComparator());
usort($nondated, self::typeComparator());
// Merge the arrays
$dc = count($dated);
$nc = count($nondated);
$i = 0;
$j = 0;
// while there is anything in the dated array continue merging
while ($i < $dc) {
// compare each fact by type to merge them in order
if ($j < $nc && self::typeComparator()($dated[$i], $nondated[$j]) > 0) {
$sorted[] = $nondated[$j];
$j++;
} else {
$sorted[] = $dated[$i];
$i++;
}
}
// get anything that might be left in the nondated array
while ($j < $nc) {
$sorted[] = $nondated[$j];
$j++;
}
return new Collection($sorted);
} | [
"public",
"static",
"function",
"sortFacts",
"(",
"Collection",
"$",
"unsorted",
")",
":",
"Collection",
"{",
"$",
"dated",
"=",
"[",
"]",
";",
"$",
"nondated",
"=",
"[",
"]",
";",
"$",
"sorted",
"=",
"[",
"]",
";",
"// Split the array into dated and non-dated arrays",
"$",
"order",
"=",
"0",
";",
"foreach",
"(",
"$",
"unsorted",
"as",
"$",
"fact",
")",
"{",
"$",
"fact",
"->",
"sortOrder",
"=",
"$",
"order",
";",
"$",
"order",
"++",
";",
"if",
"(",
"$",
"fact",
"->",
"date",
"(",
")",
"->",
"isOK",
"(",
")",
")",
"{",
"$",
"dated",
"[",
"]",
"=",
"$",
"fact",
";",
"}",
"else",
"{",
"$",
"nondated",
"[",
"]",
"=",
"$",
"fact",
";",
"}",
"}",
"usort",
"(",
"$",
"dated",
",",
"self",
"::",
"dateComparator",
"(",
")",
")",
";",
"usort",
"(",
"$",
"nondated",
",",
"self",
"::",
"typeComparator",
"(",
")",
")",
";",
"// Merge the arrays",
"$",
"dc",
"=",
"count",
"(",
"$",
"dated",
")",
";",
"$",
"nc",
"=",
"count",
"(",
"$",
"nondated",
")",
";",
"$",
"i",
"=",
"0",
";",
"$",
"j",
"=",
"0",
";",
"// while there is anything in the dated array continue merging",
"while",
"(",
"$",
"i",
"<",
"$",
"dc",
")",
"{",
"// compare each fact by type to merge them in order",
"if",
"(",
"$",
"j",
"<",
"$",
"nc",
"&&",
"self",
"::",
"typeComparator",
"(",
")",
"(",
"$",
"dated",
"[",
"$",
"i",
"]",
",",
"$",
"nondated",
"[",
"$",
"j",
"]",
")",
">",
"0",
")",
"{",
"$",
"sorted",
"[",
"]",
"=",
"$",
"nondated",
"[",
"$",
"j",
"]",
";",
"$",
"j",
"++",
";",
"}",
"else",
"{",
"$",
"sorted",
"[",
"]",
"=",
"$",
"dated",
"[",
"$",
"i",
"]",
";",
"$",
"i",
"++",
";",
"}",
"}",
"// get anything that might be left in the nondated array",
"while",
"(",
"$",
"j",
"<",
"$",
"nc",
")",
"{",
"$",
"sorted",
"[",
"]",
"=",
"$",
"nondated",
"[",
"$",
"j",
"]",
";",
"$",
"j",
"++",
";",
"}",
"return",
"new",
"Collection",
"(",
"$",
"sorted",
")",
";",
"}"
] | A multi-key sort
1. First divide the facts into two arrays one set with dates and one set without dates
2. Sort each of the two new arrays, the date using the compare date function, the non-dated
using the compare type function
3. Then merge the arrays back into the original array using the compare type function
@param Collection $unsorted
@return Collection
@return Fact[] | [
"A",
"multi",
"-",
"key",
"sort",
"1",
".",
"First",
"divide",
"the",
"facts",
"into",
"two",
"arrays",
"one",
"set",
"with",
"dates",
"and",
"one",
"set",
"without",
"dates",
"2",
".",
"Sort",
"each",
"of",
"the",
"two",
"new",
"arrays",
"the",
"date",
"using",
"the",
"compare",
"date",
"function",
"the",
"non",
"-",
"dated",
"using",
"the",
"compare",
"type",
"function",
"3",
".",
"Then",
"merge",
"the",
"arrays",
"back",
"into",
"the",
"original",
"array",
"using",
"the",
"compare",
"type",
"function"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Fact.php#L700-L748 | train |
fisharebest/webtrees | app/Module/FanChartModule.php | FanChartModule.splitAlignText | protected function splitAlignText(string $data, int $maxlen): string
{
$RTLOrd = [
215,
216,
217,
218,
219,
];
$lines = explode("\n", $data);
// more than 1 line : recursive calls
if (count($lines) > 1) {
$text = '';
foreach ($lines as $line) {
$text .= $this->splitAlignText($line, $maxlen) . "\n";
}
return $text;
}
// process current line word by word
$split = explode(' ', $data);
$text = '';
$line = '';
// do not split hebrew line
$found = false;
foreach ($RTLOrd as $ord) {
if (strpos($data, chr($ord)) !== false) {
$found = true;
}
}
if ($found) {
$line = $data;
} else {
foreach ($split as $word) {
$len = strlen($line);
$wlen = strlen($word);
if (($len + $wlen) < $maxlen) {
if (!empty($line)) {
$line .= ' ';
}
$line .= $word;
} else {
$p = max(0, (int) (($maxlen - $len) / 2));
if (!empty($line)) {
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
$text .= $line . "\n";
}
$line = $word;
}
}
}
// last line
if (!empty($line)) {
$len = strlen($line);
if (in_array(ord($line{0}), $RTLOrd, true)) {
$len /= 2;
}
$p = max(0, (int) (($maxlen - $len) / 2));
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
$text .= $line;
}
return $text;
} | php | protected function splitAlignText(string $data, int $maxlen): string
{
$RTLOrd = [
215,
216,
217,
218,
219,
];
$lines = explode("\n", $data);
// more than 1 line : recursive calls
if (count($lines) > 1) {
$text = '';
foreach ($lines as $line) {
$text .= $this->splitAlignText($line, $maxlen) . "\n";
}
return $text;
}
// process current line word by word
$split = explode(' ', $data);
$text = '';
$line = '';
// do not split hebrew line
$found = false;
foreach ($RTLOrd as $ord) {
if (strpos($data, chr($ord)) !== false) {
$found = true;
}
}
if ($found) {
$line = $data;
} else {
foreach ($split as $word) {
$len = strlen($line);
$wlen = strlen($word);
if (($len + $wlen) < $maxlen) {
if (!empty($line)) {
$line .= ' ';
}
$line .= $word;
} else {
$p = max(0, (int) (($maxlen - $len) / 2));
if (!empty($line)) {
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
$text .= $line . "\n";
}
$line = $word;
}
}
}
// last line
if (!empty($line)) {
$len = strlen($line);
if (in_array(ord($line{0}), $RTLOrd, true)) {
$len /= 2;
}
$p = max(0, (int) (($maxlen - $len) / 2));
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
$text .= $line;
}
return $text;
} | [
"protected",
"function",
"splitAlignText",
"(",
"string",
"$",
"data",
",",
"int",
"$",
"maxlen",
")",
":",
"string",
"{",
"$",
"RTLOrd",
"=",
"[",
"215",
",",
"216",
",",
"217",
",",
"218",
",",
"219",
",",
"]",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"data",
")",
";",
"// more than 1 line : recursive calls",
"if",
"(",
"count",
"(",
"$",
"lines",
")",
">",
"1",
")",
"{",
"$",
"text",
"=",
"''",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"text",
".=",
"$",
"this",
"->",
"splitAlignText",
"(",
"$",
"line",
",",
"$",
"maxlen",
")",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"text",
";",
"}",
"// process current line word by word",
"$",
"split",
"=",
"explode",
"(",
"' '",
",",
"$",
"data",
")",
";",
"$",
"text",
"=",
"''",
";",
"$",
"line",
"=",
"''",
";",
"// do not split hebrew line",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"RTLOrd",
"as",
"$",
"ord",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"data",
",",
"chr",
"(",
"$",
"ord",
")",
")",
"!==",
"false",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"found",
")",
"{",
"$",
"line",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"split",
"as",
"$",
"word",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"line",
")",
";",
"$",
"wlen",
"=",
"strlen",
"(",
"$",
"word",
")",
";",
"if",
"(",
"(",
"$",
"len",
"+",
"$",
"wlen",
")",
"<",
"$",
"maxlen",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
")",
")",
"{",
"$",
"line",
".=",
"' '",
";",
"}",
"$",
"line",
".=",
"$",
"word",
";",
"}",
"else",
"{",
"$",
"p",
"=",
"max",
"(",
"0",
",",
"(",
"int",
")",
"(",
"(",
"$",
"maxlen",
"-",
"$",
"len",
")",
"/",
"2",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
")",
")",
"{",
"$",
"line",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"p",
")",
".",
"$",
"line",
";",
"// center alignment using spaces",
"$",
"text",
".=",
"$",
"line",
".",
"\"\\n\"",
";",
"}",
"$",
"line",
"=",
"$",
"word",
";",
"}",
"}",
"}",
"// last line",
"if",
"(",
"!",
"empty",
"(",
"$",
"line",
")",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"line",
")",
";",
"if",
"(",
"in_array",
"(",
"ord",
"(",
"$",
"line",
"{",
"0",
"}",
")",
",",
"$",
"RTLOrd",
",",
"true",
")",
")",
"{",
"$",
"len",
"/=",
"2",
";",
"}",
"$",
"p",
"=",
"max",
"(",
"0",
",",
"(",
"int",
")",
"(",
"(",
"$",
"maxlen",
"-",
"$",
"len",
")",
"/",
"2",
")",
")",
";",
"$",
"line",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"p",
")",
".",
"$",
"line",
";",
"// center alignment using spaces",
"$",
"text",
".=",
"$",
"line",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | split and center text by lines
@param string $data input string
@param int $maxlen max length of each line
@return string $text output string | [
"split",
"and",
"center",
"text",
"by",
"lines"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/FanChartModule.php#L388-L453 | train |
fisharebest/webtrees | app/Module/FanChartModule.php | FanChartModule.imageColor | protected function imageColor($image, string $css_color): int
{
return imagecolorallocate(
$image,
(int) hexdec(substr($css_color, 0, 2)),
(int) hexdec(substr($css_color, 2, 2)),
(int) hexdec(substr($css_color, 4, 2))
);
} | php | protected function imageColor($image, string $css_color): int
{
return imagecolorallocate(
$image,
(int) hexdec(substr($css_color, 0, 2)),
(int) hexdec(substr($css_color, 2, 2)),
(int) hexdec(substr($css_color, 4, 2))
);
} | [
"protected",
"function",
"imageColor",
"(",
"$",
"image",
",",
"string",
"$",
"css_color",
")",
":",
"int",
"{",
"return",
"imagecolorallocate",
"(",
"$",
"image",
",",
"(",
"int",
")",
"hexdec",
"(",
"substr",
"(",
"$",
"css_color",
",",
"0",
",",
"2",
")",
")",
",",
"(",
"int",
")",
"hexdec",
"(",
"substr",
"(",
"$",
"css_color",
",",
"2",
",",
"2",
")",
")",
",",
"(",
"int",
")",
"hexdec",
"(",
"substr",
"(",
"$",
"css_color",
",",
"4",
",",
"2",
")",
")",
")",
";",
"}"
] | Convert a CSS color into a GD color.
@param resource $image
@param string $css_color
@return int | [
"Convert",
"a",
"CSS",
"color",
"into",
"a",
"GD",
"color",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/FanChartModule.php#L463-L471 | train |
fisharebest/webtrees | app/Services/RomanNumeralsService.php | RomanNumeralsService.numberToRomanNumerals | public function numberToRomanNumerals(int $number): string
{
if ($number < 1) {
// Cannot convert zero/negative numbers
return (string) $number;
}
$roman = '';
foreach (self::ROMAN_NUMERALS as $key => $value) {
while ($number >= $key) {
$roman .= $value;
$number -= $key;
}
}
return $roman;
} | php | public function numberToRomanNumerals(int $number): string
{
if ($number < 1) {
// Cannot convert zero/negative numbers
return (string) $number;
}
$roman = '';
foreach (self::ROMAN_NUMERALS as $key => $value) {
while ($number >= $key) {
$roman .= $value;
$number -= $key;
}
}
return $roman;
} | [
"public",
"function",
"numberToRomanNumerals",
"(",
"int",
"$",
"number",
")",
":",
"string",
"{",
"if",
"(",
"$",
"number",
"<",
"1",
")",
"{",
"// Cannot convert zero/negative numbers",
"return",
"(",
"string",
")",
"$",
"number",
";",
"}",
"$",
"roman",
"=",
"''",
";",
"foreach",
"(",
"self",
"::",
"ROMAN_NUMERALS",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"while",
"(",
"$",
"number",
">=",
"$",
"key",
")",
"{",
"$",
"roman",
".=",
"$",
"value",
";",
"$",
"number",
"-=",
"$",
"key",
";",
"}",
"}",
"return",
"$",
"roman",
";",
"}"
] | Convert a decimal number to roman numerals
@param int $number
@return string | [
"Convert",
"a",
"decimal",
"number",
"to",
"roman",
"numerals"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/RomanNumeralsService.php#L49-L64 | train |
fisharebest/webtrees | app/Services/RomanNumeralsService.php | RomanNumeralsService.romanNumeralsToNumber | public function romanNumeralsToNumber(string $roman): int
{
$num = 0;
foreach (self::ROMAN_NUMERALS as $key => $value) {
while (strpos($roman, $value) === 0) {
$num += $key;
$roman = substr($roman, strlen($value));
}
}
return $num;
} | php | public function romanNumeralsToNumber(string $roman): int
{
$num = 0;
foreach (self::ROMAN_NUMERALS as $key => $value) {
while (strpos($roman, $value) === 0) {
$num += $key;
$roman = substr($roman, strlen($value));
}
}
return $num;
} | [
"public",
"function",
"romanNumeralsToNumber",
"(",
"string",
"$",
"roman",
")",
":",
"int",
"{",
"$",
"num",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"ROMAN_NUMERALS",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"while",
"(",
"strpos",
"(",
"$",
"roman",
",",
"$",
"value",
")",
"===",
"0",
")",
"{",
"$",
"num",
"+=",
"$",
"key",
";",
"$",
"roman",
"=",
"substr",
"(",
"$",
"roman",
",",
"strlen",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"return",
"$",
"num",
";",
"}"
] | Convert a roman numeral to decimal
@param string $roman
@return int | [
"Convert",
"a",
"roman",
"numeral",
"to",
"decimal"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/RomanNumeralsService.php#L73-L84 | train |
fisharebest/webtrees | app/Module/FamilyTreeFavoritesModule.php | FamilyTreeFavoritesModule.getFavorites | public function getFavorites(Tree $tree): array
{
return DB::table('favorite')
->where('gedcom_id', '=', $tree->id())
->whereNull('user_id')
->get()
->map(static function (stdClass $row) use ($tree): stdClass {
if ($row->xref !== null) {
$row->record = GedcomRecord::getInstance($row->xref, $tree);
} else {
$row->record = null;
}
return $row;
})
->all();
} | php | public function getFavorites(Tree $tree): array
{
return DB::table('favorite')
->where('gedcom_id', '=', $tree->id())
->whereNull('user_id')
->get()
->map(static function (stdClass $row) use ($tree): stdClass {
if ($row->xref !== null) {
$row->record = GedcomRecord::getInstance($row->xref, $tree);
} else {
$row->record = null;
}
return $row;
})
->all();
} | [
"public",
"function",
"getFavorites",
"(",
"Tree",
"$",
"tree",
")",
":",
"array",
"{",
"return",
"DB",
"::",
"table",
"(",
"'favorite'",
")",
"->",
"where",
"(",
"'gedcom_id'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"whereNull",
"(",
"'user_id'",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"stdClass",
"$",
"row",
")",
"use",
"(",
"$",
"tree",
")",
":",
"stdClass",
"{",
"if",
"(",
"$",
"row",
"->",
"xref",
"!==",
"null",
")",
"{",
"$",
"row",
"->",
"record",
"=",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"row",
"->",
"xref",
",",
"$",
"tree",
")",
";",
"}",
"else",
"{",
"$",
"row",
"->",
"record",
"=",
"null",
";",
"}",
"return",
"$",
"row",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Get the favorites for a family tree
@param Tree $tree
@return stdClass[] | [
"Get",
"the",
"favorites",
"for",
"a",
"family",
"tree"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/FamilyTreeFavoritesModule.php#L161-L177 | train |
fisharebest/webtrees | app/Module/BatchUpdateModule.php | BatchUpdateModule.getPluginList | private function getPluginList(): array
{
$plugins = [];
$files = glob(__DIR__ . '/BatchUpdate/BatchUpdate*Plugin.php', GLOB_NOSORT);
foreach ($files as $file) {
$base_class = basename($file, '.php');
if ($base_class !== 'BatchUpdateBasePlugin') {
$class = __NAMESPACE__ . '\\BatchUpdate\\' . basename($file, '.php');
$plugins[$class] = new $class();
}
}
return $plugins;
} | php | private function getPluginList(): array
{
$plugins = [];
$files = glob(__DIR__ . '/BatchUpdate/BatchUpdate*Plugin.php', GLOB_NOSORT);
foreach ($files as $file) {
$base_class = basename($file, '.php');
if ($base_class !== 'BatchUpdateBasePlugin') {
$class = __NAMESPACE__ . '\\BatchUpdate\\' . basename($file, '.php');
$plugins[$class] = new $class();
}
}
return $plugins;
} | [
"private",
"function",
"getPluginList",
"(",
")",
":",
"array",
"{",
"$",
"plugins",
"=",
"[",
"]",
";",
"$",
"files",
"=",
"glob",
"(",
"__DIR__",
".",
"'/BatchUpdate/BatchUpdate*Plugin.php'",
",",
"GLOB_NOSORT",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"base_class",
"=",
"basename",
"(",
"$",
"file",
",",
"'.php'",
")",
";",
"if",
"(",
"$",
"base_class",
"!==",
"'BatchUpdateBasePlugin'",
")",
"{",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\BatchUpdate\\\\'",
".",
"basename",
"(",
"$",
"file",
",",
"'.php'",
")",
";",
"$",
"plugins",
"[",
"$",
"class",
"]",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"}",
"return",
"$",
"plugins",
";",
"}"
] | Scan the plugin folder for a list of plugins
@return BatchUpdateBasePlugin[] | [
"Scan",
"the",
"plugin",
"folder",
"for",
"a",
"list",
"of",
"plugins"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdateModule.php#L148-L163 | train |
fisharebest/webtrees | app/Module/BatchUpdateModule.php | BatchUpdateModule.allData | private function allData(BatchUpdateBasePlugin $plugin, Tree $tree): array
{
$tmp = [];
foreach ($plugin->getRecordTypesToUpdate() as $type) {
switch ($type) {
case 'INDI':
$rows = DB::table('individuals')
->where('i_file', '=', $tree->id())
->select(['i_id AS xref', DB::raw("'INDI' AS type"), 'i_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'FAM':
$rows = DB::table('families')
->where('f_file', '=', $tree->id())
->select(['f_id AS xref', DB::raw("'FAM' AS type"), 'f_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'SOUR':
$rows = DB::table('sources')
->where('s_file', '=', $tree->id())
->select(['s_id AS xref', DB::raw("'SOUR' AS type"), 's_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'OBJE':
$rows = DB::table('media')
->where('m_file', '=', $tree->id())
->select(['m_id AS xref', DB::raw("'OBJE' AS type"), 'm_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
default:
$rows = DB::table('other')
->where('o_file', '=', $tree->id())
->where('o_type', '=', $type)
->select(['o_id AS xref', 'o_type AS type', 'o_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
}
}
$data = [];
foreach ($tmp as $value) {
$data[$value->xref] = $value;
}
ksort($tmp);
return $data;
} | php | private function allData(BatchUpdateBasePlugin $plugin, Tree $tree): array
{
$tmp = [];
foreach ($plugin->getRecordTypesToUpdate() as $type) {
switch ($type) {
case 'INDI':
$rows = DB::table('individuals')
->where('i_file', '=', $tree->id())
->select(['i_id AS xref', DB::raw("'INDI' AS type"), 'i_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'FAM':
$rows = DB::table('families')
->where('f_file', '=', $tree->id())
->select(['f_id AS xref', DB::raw("'FAM' AS type"), 'f_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'SOUR':
$rows = DB::table('sources')
->where('s_file', '=', $tree->id())
->select(['s_id AS xref', DB::raw("'SOUR' AS type"), 's_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
case 'OBJE':
$rows = DB::table('media')
->where('m_file', '=', $tree->id())
->select(['m_id AS xref', DB::raw("'OBJE' AS type"), 'm_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
default:
$rows = DB::table('other')
->where('o_file', '=', $tree->id())
->where('o_type', '=', $type)
->select(['o_id AS xref', 'o_type AS type', 'o_gedcom AS gedcom'])
->get();
$tmp = array_merge($tmp, $rows->all());
break;
}
}
$data = [];
foreach ($tmp as $value) {
$data[$value->xref] = $value;
}
ksort($tmp);
return $data;
} | [
"private",
"function",
"allData",
"(",
"BatchUpdateBasePlugin",
"$",
"plugin",
",",
"Tree",
"$",
"tree",
")",
":",
"array",
"{",
"$",
"tmp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"plugin",
"->",
"getRecordTypesToUpdate",
"(",
")",
"as",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'INDI'",
":",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'i_id AS xref'",
",",
"DB",
"::",
"raw",
"(",
"\"'INDI' AS type\"",
")",
",",
"'i_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"tmp",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"rows",
"->",
"all",
"(",
")",
")",
";",
"break",
";",
"case",
"'FAM'",
":",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'families'",
")",
"->",
"where",
"(",
"'f_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'f_id AS xref'",
",",
"DB",
"::",
"raw",
"(",
"\"'FAM' AS type\"",
")",
",",
"'f_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"tmp",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"rows",
"->",
"all",
"(",
")",
")",
";",
"break",
";",
"case",
"'SOUR'",
":",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'sources'",
")",
"->",
"where",
"(",
"'s_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'s_id AS xref'",
",",
"DB",
"::",
"raw",
"(",
"\"'SOUR' AS type\"",
")",
",",
"'s_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"tmp",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"rows",
"->",
"all",
"(",
")",
")",
";",
"break",
";",
"case",
"'OBJE'",
":",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'media'",
")",
"->",
"where",
"(",
"'m_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'m_id AS xref'",
",",
"DB",
"::",
"raw",
"(",
"\"'OBJE' AS type\"",
")",
",",
"'m_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"tmp",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"rows",
"->",
"all",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'other'",
")",
"->",
"where",
"(",
"'o_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'o_type'",
",",
"'='",
",",
"$",
"type",
")",
"->",
"select",
"(",
"[",
"'o_id AS xref'",
",",
"'o_type AS type'",
",",
"'o_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"tmp",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"rows",
"->",
"all",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tmp",
"as",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"value",
"->",
"xref",
"]",
"=",
"$",
"value",
";",
"}",
"ksort",
"(",
"$",
"tmp",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Fetch all records that might need updating.
@param BatchUpdateBasePlugin $plugin
@param Tree $tree
@return object[] | [
"Fetch",
"all",
"records",
"that",
"might",
"need",
"updating",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdateModule.php#L173-L236 | train |
fisharebest/webtrees | app/Module/BatchUpdateModule.php | BatchUpdateModule.findNextXref | private function findNextXref(BatchUpdateBasePlugin $plugin, string $xref, array $all_data, Tree $tree): string
{
foreach (array_keys($all_data) as $key) {
if ($key > $xref) {
$record = $this->getRecord($all_data[$key], $tree);
if ($plugin->doesRecordNeedUpdate($record)) {
return $key;
}
}
}
return '';
} | php | private function findNextXref(BatchUpdateBasePlugin $plugin, string $xref, array $all_data, Tree $tree): string
{
foreach (array_keys($all_data) as $key) {
if ($key > $xref) {
$record = $this->getRecord($all_data[$key], $tree);
if ($plugin->doesRecordNeedUpdate($record)) {
return $key;
}
}
}
return '';
} | [
"private",
"function",
"findNextXref",
"(",
"BatchUpdateBasePlugin",
"$",
"plugin",
",",
"string",
"$",
"xref",
",",
"array",
"$",
"all_data",
",",
"Tree",
"$",
"tree",
")",
":",
"string",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"all_data",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
">",
"$",
"xref",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"getRecord",
"(",
"$",
"all_data",
"[",
"$",
"key",
"]",
",",
"$",
"tree",
")",
";",
"if",
"(",
"$",
"plugin",
"->",
"doesRecordNeedUpdate",
"(",
"$",
"record",
")",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"''",
";",
"}"
] | Find the next record that needs to be updated.
@param BatchUpdateBasePlugin $plugin
@param string $xref
@param array $all_data
@param Tree $tree
@return string | [
"Find",
"the",
"next",
"record",
"that",
"needs",
"to",
"be",
"updated",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdateModule.php#L280-L292 | train |
fisharebest/webtrees | app/Module/BatchUpdateModule.php | BatchUpdateModule.findPrevXref | private function findPrevXref(BatchUpdateBasePlugin $plugin, string $xref, array $all_data, Tree $tree): string
{
foreach (array_reverse($all_data) as $key => $value) {
if ($key > $xref) {
$record = $this->getRecord($all_data[$key], $tree);
if ($plugin->doesRecordNeedUpdate($record)) {
return $key;
}
}
}
return '';
} | php | private function findPrevXref(BatchUpdateBasePlugin $plugin, string $xref, array $all_data, Tree $tree): string
{
foreach (array_reverse($all_data) as $key => $value) {
if ($key > $xref) {
$record = $this->getRecord($all_data[$key], $tree);
if ($plugin->doesRecordNeedUpdate($record)) {
return $key;
}
}
}
return '';
} | [
"private",
"function",
"findPrevXref",
"(",
"BatchUpdateBasePlugin",
"$",
"plugin",
",",
"string",
"$",
"xref",
",",
"array",
"$",
"all_data",
",",
"Tree",
"$",
"tree",
")",
":",
"string",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"all_data",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
">",
"$",
"xref",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"getRecord",
"(",
"$",
"all_data",
"[",
"$",
"key",
"]",
",",
"$",
"tree",
")",
";",
"if",
"(",
"$",
"plugin",
"->",
"doesRecordNeedUpdate",
"(",
"$",
"record",
")",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"''",
";",
"}"
] | Find the previous record that needs to be updated.
@param BatchUpdateBasePlugin $plugin
@param string $xref
@param array $all_data
@param Tree $tree
@return string | [
"Find",
"the",
"previous",
"record",
"that",
"needs",
"to",
"be",
"updated",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdateModule.php#L304-L316 | train |
fisharebest/webtrees | app/Report/ReportBaseHtml.php | ReportBaseHtml.getStart | public function getStart(): string
{
$str = '<' . $this->tag . ' ';
foreach ($this->attrs as $key => $value) {
$str .= $key . '="' . $value . '" ';
}
$str .= '>';
return $str;
} | php | public function getStart(): string
{
$str = '<' . $this->tag . ' ';
foreach ($this->attrs as $key => $value) {
$str .= $key . '="' . $value . '" ';
}
$str .= '>';
return $str;
} | [
"public",
"function",
"getStart",
"(",
")",
":",
"string",
"{",
"$",
"str",
"=",
"'<'",
".",
"$",
"this",
"->",
"tag",
".",
"' '",
";",
"foreach",
"(",
"$",
"this",
"->",
"attrs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"str",
".=",
"$",
"key",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\" '",
";",
"}",
"$",
"str",
".=",
"'>'",
";",
"return",
"$",
"str",
";",
"}"
] | Get the start tag.
@return string | [
"Get",
"the",
"start",
"tag",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportBaseHtml.php#L51-L60 | train |
fisharebest/webtrees | app/Report/ReportPdfPageheader.php | ReportPdfPageheader.render | public function render($renderer)
{
$renderer->clearPageHeader();
foreach ($this->elements as $element) {
$renderer->addPageHeader($element);
}
} | php | public function render($renderer)
{
$renderer->clearPageHeader();
foreach ($this->elements as $element) {
$renderer->addPageHeader($element);
}
} | [
"public",
"function",
"render",
"(",
"$",
"renderer",
")",
"{",
"$",
"renderer",
"->",
"clearPageHeader",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"renderer",
"->",
"addPageHeader",
"(",
"$",
"element",
")",
";",
"}",
"}"
] | PageHeader element renderer
@param ReportTcpdf $renderer
@return void | [
"PageHeader",
"element",
"renderer"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportPdfPageheader.php#L32-L38 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/MediaController.php | MediaController.allMediaFolders | private function allMediaFolders(): Collection
{
$base_folders = DB::table('gedcom_setting')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->select(DB::raw("setting_value || 'dummy.jpeg' AS path"));
return DB::table('media_file')
->join('gedcom_setting', 'gedcom_id', '=', 'm_file')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->where('multimedia_file_refn', 'LIKE', '%/%')
->where('multimedia_file_refn', 'NOT LIKE', 'http://%')
->where('multimedia_file_refn', 'NOT LIKE', 'https://%')
->select(DB::raw('setting_value || multimedia_file_refn AS path'))
->union($base_folders)
->pluck('path')
->map(static function (string $path): string {
return dirname($path) . '/';
})
->unique()
->sort()
->mapWithKeys(static function (string $path): array {
return [$path => $path];
});
} | php | private function allMediaFolders(): Collection
{
$base_folders = DB::table('gedcom_setting')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->select(DB::raw("setting_value || 'dummy.jpeg' AS path"));
return DB::table('media_file')
->join('gedcom_setting', 'gedcom_id', '=', 'm_file')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->where('multimedia_file_refn', 'LIKE', '%/%')
->where('multimedia_file_refn', 'NOT LIKE', 'http://%')
->where('multimedia_file_refn', 'NOT LIKE', 'https://%')
->select(DB::raw('setting_value || multimedia_file_refn AS path'))
->union($base_folders)
->pluck('path')
->map(static function (string $path): string {
return dirname($path) . '/';
})
->unique()
->sort()
->mapWithKeys(static function (string $path): array {
return [$path => $path];
});
} | [
"private",
"function",
"allMediaFolders",
"(",
")",
":",
"Collection",
"{",
"$",
"base_folders",
"=",
"DB",
"::",
"table",
"(",
"'gedcom_setting'",
")",
"->",
"where",
"(",
"'setting_name'",
",",
"'='",
",",
"'MEDIA_DIRECTORY'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"\"setting_value || 'dummy.jpeg' AS path\"",
")",
")",
";",
"return",
"DB",
"::",
"table",
"(",
"'media_file'",
")",
"->",
"join",
"(",
"'gedcom_setting'",
",",
"'gedcom_id'",
",",
"'='",
",",
"'m_file'",
")",
"->",
"where",
"(",
"'setting_name'",
",",
"'='",
",",
"'MEDIA_DIRECTORY'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'LIKE'",
",",
"'%/%'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'NOT LIKE'",
",",
"'http://%'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'NOT LIKE'",
",",
"'https://%'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn AS path'",
")",
")",
"->",
"union",
"(",
"$",
"base_folders",
")",
"->",
"pluck",
"(",
"'path'",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"return",
"dirname",
"(",
"$",
"path",
")",
".",
"'/'",
";",
"}",
")",
"->",
"unique",
"(",
")",
"->",
"sort",
"(",
")",
"->",
"mapWithKeys",
"(",
"static",
"function",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"return",
"[",
"$",
"path",
"=>",
"$",
"path",
"]",
";",
"}",
")",
";",
"}"
] | Generate a list of all folders from all the trees.
@return Collection
@return string[] | [
"Generate",
"a",
"list",
"of",
"all",
"folders",
"from",
"all",
"the",
"trees",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/MediaController.php#L93-L116 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/MediaController.php | MediaController.allDiskFiles | private function allDiskFiles(string $media_folder, string $subfolders): array
{
return $this->scanFolders(WT_DATA_DIR . $media_folder, $subfolders === 'include');
} | php | private function allDiskFiles(string $media_folder, string $subfolders): array
{
return $this->scanFolders(WT_DATA_DIR . $media_folder, $subfolders === 'include');
} | [
"private",
"function",
"allDiskFiles",
"(",
"string",
"$",
"media_folder",
",",
"string",
"$",
"subfolders",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"scanFolders",
"(",
"WT_DATA_DIR",
".",
"$",
"media_folder",
",",
"$",
"subfolders",
"===",
"'include'",
")",
";",
"}"
] | Fetch a list of all files on disk
@param string $media_folder Location of root folder
@param string $subfolders Include or exclude subfolders
@return string[] | [
"Fetch",
"a",
"list",
"of",
"all",
"files",
"on",
"disk"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/MediaController.php#L153-L156 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/MediaController.php | MediaController.mediaObjectInfo | private function mediaObjectInfo(Media $media): string
{
$html = '<b><a href="' . e($media->url()) . '">' . $media->fullName() . '</a></b>' . '<br><i>' . e($media->getNote()) . '</i></br><br>';
$linked = [];
foreach ($media->linkedIndividuals('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedFamilies('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedSources('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedNotes('OBJE') as $link) {
// Invalid GEDCOM - you cannot link a NOTE to an OBJE
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedRepositories('OBJE') as $link) {
// Invalid GEDCOM - you cannot link a REPO to an OBJE
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
if (!empty($linked)) {
$html .= '<ul>';
foreach ($linked as $link) {
$html .= '<li>' . $link . '</li>';
}
$html .= '</ul>';
} else {
$html .= '<div class="alert alert-danger">' . I18N::translate('There are no links to this media object.') . '</div>';
}
return $html;
} | php | private function mediaObjectInfo(Media $media): string
{
$html = '<b><a href="' . e($media->url()) . '">' . $media->fullName() . '</a></b>' . '<br><i>' . e($media->getNote()) . '</i></br><br>';
$linked = [];
foreach ($media->linkedIndividuals('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedFamilies('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedSources('OBJE') as $link) {
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedNotes('OBJE') as $link) {
// Invalid GEDCOM - you cannot link a NOTE to an OBJE
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
foreach ($media->linkedRepositories('OBJE') as $link) {
// Invalid GEDCOM - you cannot link a REPO to an OBJE
$linked[] = '<a href="' . e($link->url()) . '">' . $link->fullName() . '</a>';
}
if (!empty($linked)) {
$html .= '<ul>';
foreach ($linked as $link) {
$html .= '<li>' . $link . '</li>';
}
$html .= '</ul>';
} else {
$html .= '<div class="alert alert-danger">' . I18N::translate('There are no links to this media object.') . '</div>';
}
return $html;
} | [
"private",
"function",
"mediaObjectInfo",
"(",
"Media",
"$",
"media",
")",
":",
"string",
"{",
"$",
"html",
"=",
"'<b><a href=\"'",
".",
"e",
"(",
"$",
"media",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"media",
"->",
"fullName",
"(",
")",
".",
"'</a></b>'",
".",
"'<br><i>'",
".",
"e",
"(",
"$",
"media",
"->",
"getNote",
"(",
")",
")",
".",
"'</i></br><br>'",
";",
"$",
"linked",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"media",
"->",
"linkedIndividuals",
"(",
"'OBJE'",
")",
"as",
"$",
"link",
")",
"{",
"$",
"linked",
"[",
"]",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"link",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"link",
"->",
"fullName",
"(",
")",
".",
"'</a>'",
";",
"}",
"foreach",
"(",
"$",
"media",
"->",
"linkedFamilies",
"(",
"'OBJE'",
")",
"as",
"$",
"link",
")",
"{",
"$",
"linked",
"[",
"]",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"link",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"link",
"->",
"fullName",
"(",
")",
".",
"'</a>'",
";",
"}",
"foreach",
"(",
"$",
"media",
"->",
"linkedSources",
"(",
"'OBJE'",
")",
"as",
"$",
"link",
")",
"{",
"$",
"linked",
"[",
"]",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"link",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"link",
"->",
"fullName",
"(",
")",
".",
"'</a>'",
";",
"}",
"foreach",
"(",
"$",
"media",
"->",
"linkedNotes",
"(",
"'OBJE'",
")",
"as",
"$",
"link",
")",
"{",
"// Invalid GEDCOM - you cannot link a NOTE to an OBJE",
"$",
"linked",
"[",
"]",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"link",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"link",
"->",
"fullName",
"(",
")",
".",
"'</a>'",
";",
"}",
"foreach",
"(",
"$",
"media",
"->",
"linkedRepositories",
"(",
"'OBJE'",
")",
"as",
"$",
"link",
")",
"{",
"// Invalid GEDCOM - you cannot link a REPO to an OBJE",
"$",
"linked",
"[",
"]",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"link",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"$",
"link",
"->",
"fullName",
"(",
")",
".",
"'</a>'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"linked",
")",
")",
"{",
"$",
"html",
".=",
"'<ul>'",
";",
"foreach",
"(",
"$",
"linked",
"as",
"$",
"link",
")",
"{",
"$",
"html",
".=",
"'<li>'",
".",
"$",
"link",
".",
"'</li>'",
";",
"}",
"$",
"html",
".=",
"'</ul>'",
";",
"}",
"else",
"{",
"$",
"html",
".=",
"'<div class=\"alert alert-danger\">'",
".",
"I18N",
"::",
"translate",
"(",
"'There are no links to this media object.'",
")",
".",
"'</div>'",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Generate some useful information and links about a media object.
@param Media $media
@return string HTML | [
"Generate",
"some",
"useful",
"information",
"and",
"links",
"about",
"a",
"media",
"object",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/MediaController.php#L382-L415 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/MediaController.php | MediaController.allMediaFiles | private function allMediaFiles(string $media_folder, string $subfolders): array
{
$query = DB::table('media_file')
->join('gedcom_setting', 'gedcom_id', '=', 'm_file')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->where('multimedia_file_refn', 'LIKE', '%/%')
->where('multimedia_file_refn', 'NOT LIKE', 'http://%')
->where('multimedia_file_refn', 'NOT LIKE', 'https://%')
->where(DB::raw('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%')
->select(DB::raw('setting_value || multimedia_file_refn AS path'))
->orderBy(DB::raw('setting_value || multimedia_file_refn'));
if ($subfolders === 'exclude') {
$query->where(DB::raw('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%');
}
return $query->pluck('path')->all();
} | php | private function allMediaFiles(string $media_folder, string $subfolders): array
{
$query = DB::table('media_file')
->join('gedcom_setting', 'gedcom_id', '=', 'm_file')
->where('setting_name', '=', 'MEDIA_DIRECTORY')
->where('multimedia_file_refn', 'LIKE', '%/%')
->where('multimedia_file_refn', 'NOT LIKE', 'http://%')
->where('multimedia_file_refn', 'NOT LIKE', 'https://%')
->where(DB::raw('setting_value || multimedia_file_refn'), 'LIKE', $media_folder . '%')
->select(DB::raw('setting_value || multimedia_file_refn AS path'))
->orderBy(DB::raw('setting_value || multimedia_file_refn'));
if ($subfolders === 'exclude') {
$query->where(DB::raw('setting_value || multimedia_file_refn'), 'NOT LIKE', $media_folder . '%/%');
}
return $query->pluck('path')->all();
} | [
"private",
"function",
"allMediaFiles",
"(",
"string",
"$",
"media_folder",
",",
"string",
"$",
"subfolders",
")",
":",
"array",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'media_file'",
")",
"->",
"join",
"(",
"'gedcom_setting'",
",",
"'gedcom_id'",
",",
"'='",
",",
"'m_file'",
")",
"->",
"where",
"(",
"'setting_name'",
",",
"'='",
",",
"'MEDIA_DIRECTORY'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'LIKE'",
",",
"'%/%'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'NOT LIKE'",
",",
"'http://%'",
")",
"->",
"where",
"(",
"'multimedia_file_refn'",
",",
"'NOT LIKE'",
",",
"'https://%'",
")",
"->",
"where",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn'",
")",
",",
"'LIKE'",
",",
"$",
"media_folder",
".",
"'%'",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn AS path'",
")",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn'",
")",
")",
";",
"if",
"(",
"$",
"subfolders",
"===",
"'exclude'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn'",
")",
",",
"'NOT LIKE'",
",",
"$",
"media_folder",
".",
"'%/%'",
")",
";",
"}",
"return",
"$",
"query",
"->",
"pluck",
"(",
"'path'",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Fetch a list of all files on in the database.
@param string $media_folder
@param string $subfolders
@return string[] | [
"Fetch",
"a",
"list",
"of",
"all",
"files",
"on",
"in",
"the",
"database",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/MediaController.php#L425-L442 | train |
fisharebest/webtrees | app/Mail.php | Mail.send | public static function send(UserInterface $from, UserInterface $to, UserInterface $reply_to, $subject, $message_text, $message_html): bool
{
try {
$message_text = preg_replace('/\r?\n/', "\r\n", $message_text);
$message_html = preg_replace('/\r?\n/', "\r\n", $message_html);
$message = (new Swift_Message($subject))
->setFrom($from->email(), $from->realName())
->setTo($to->email(), $to->realName())
->setReplyTo($reply_to->email(), $reply_to->realName())
->setBody($message_html, 'text/html')
->addPart($message_text, 'text/plain');
$mailer = new Swift_Mailer(self::transport());
$mailer->send($message);
} catch (Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
} | php | public static function send(UserInterface $from, UserInterface $to, UserInterface $reply_to, $subject, $message_text, $message_html): bool
{
try {
$message_text = preg_replace('/\r?\n/', "\r\n", $message_text);
$message_html = preg_replace('/\r?\n/', "\r\n", $message_html);
$message = (new Swift_Message($subject))
->setFrom($from->email(), $from->realName())
->setTo($to->email(), $to->realName())
->setReplyTo($reply_to->email(), $reply_to->realName())
->setBody($message_html, 'text/html')
->addPart($message_text, 'text/plain');
$mailer = new Swift_Mailer(self::transport());
$mailer->send($message);
} catch (Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
return false;
}
return true;
} | [
"public",
"static",
"function",
"send",
"(",
"UserInterface",
"$",
"from",
",",
"UserInterface",
"$",
"to",
",",
"UserInterface",
"$",
"reply_to",
",",
"$",
"subject",
",",
"$",
"message_text",
",",
"$",
"message_html",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"message_text",
"=",
"preg_replace",
"(",
"'/\\r?\\n/'",
",",
"\"\\r\\n\"",
",",
"$",
"message_text",
")",
";",
"$",
"message_html",
"=",
"preg_replace",
"(",
"'/\\r?\\n/'",
",",
"\"\\r\\n\"",
",",
"$",
"message_html",
")",
";",
"$",
"message",
"=",
"(",
"new",
"Swift_Message",
"(",
"$",
"subject",
")",
")",
"->",
"setFrom",
"(",
"$",
"from",
"->",
"email",
"(",
")",
",",
"$",
"from",
"->",
"realName",
"(",
")",
")",
"->",
"setTo",
"(",
"$",
"to",
"->",
"email",
"(",
")",
",",
"$",
"to",
"->",
"realName",
"(",
")",
")",
"->",
"setReplyTo",
"(",
"$",
"reply_to",
"->",
"email",
"(",
")",
",",
"$",
"reply_to",
"->",
"realName",
"(",
")",
")",
"->",
"setBody",
"(",
"$",
"message_html",
",",
"'text/html'",
")",
"->",
"addPart",
"(",
"$",
"message_text",
",",
"'text/plain'",
")",
";",
"$",
"mailer",
"=",
"new",
"Swift_Mailer",
"(",
"self",
"::",
"transport",
"(",
")",
")",
";",
"$",
"mailer",
"->",
"send",
"(",
"$",
"message",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"Log",
"::",
"addErrorLog",
"(",
"'Mail: '",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Send an external email message
Caution! gmail may rewrite the "From" header unless you have added the address to your account.
@param UserInterface $from
@param UserInterface $to
@param UserInterface $reply_to
@param string $subject
@param string $message_text
@param string $message_html
@return bool | [
"Send",
"an",
"external",
"email",
"message",
"Caution!",
"gmail",
"may",
"rewrite",
"the",
"From",
"header",
"unless",
"you",
"have",
"added",
"the",
"address",
"to",
"your",
"account",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Mail.php#L47-L69 | train |
fisharebest/webtrees | app/Mail.php | Mail.transport | public static function transport(): Swift_Transport
{
switch (Site::getPreference('SMTP_ACTIVE')) {
case 'sendmail':
// Local sendmail (requires PHP proc_* functions)
return new Swift_SendmailTransport();
case 'external':
// SMTP
$smtp_host = Site::getPreference('SMTP_HOST');
$smtp_port = (int) Site::getPreference('SMTP_PORT', '25');
$smtp_auth = Site::getPreference('SMTP_AUTH');
$smtp_user = Site::getPreference('SMTP_AUTH_USER');
$smtp_pass = Site::getPreference('SMTP_AUTH_PASS');
$smtp_encr = Site::getPreference('SMTP_SSL');
$transport = new Swift_SmtpTransport($smtp_host, $smtp_port, $smtp_encr);
$transport->setLocalDomain(Site::getPreference('SMTP_HELO'));
if ($smtp_auth) {
$transport
->setUsername($smtp_user)
->setPassword($smtp_pass);
}
return $transport;
default:
// For testing
return new Swift_NullTransport();
}
} | php | public static function transport(): Swift_Transport
{
switch (Site::getPreference('SMTP_ACTIVE')) {
case 'sendmail':
// Local sendmail (requires PHP proc_* functions)
return new Swift_SendmailTransport();
case 'external':
// SMTP
$smtp_host = Site::getPreference('SMTP_HOST');
$smtp_port = (int) Site::getPreference('SMTP_PORT', '25');
$smtp_auth = Site::getPreference('SMTP_AUTH');
$smtp_user = Site::getPreference('SMTP_AUTH_USER');
$smtp_pass = Site::getPreference('SMTP_AUTH_PASS');
$smtp_encr = Site::getPreference('SMTP_SSL');
$transport = new Swift_SmtpTransport($smtp_host, $smtp_port, $smtp_encr);
$transport->setLocalDomain(Site::getPreference('SMTP_HELO'));
if ($smtp_auth) {
$transport
->setUsername($smtp_user)
->setPassword($smtp_pass);
}
return $transport;
default:
// For testing
return new Swift_NullTransport();
}
} | [
"public",
"static",
"function",
"transport",
"(",
")",
":",
"Swift_Transport",
"{",
"switch",
"(",
"Site",
"::",
"getPreference",
"(",
"'SMTP_ACTIVE'",
")",
")",
"{",
"case",
"'sendmail'",
":",
"// Local sendmail (requires PHP proc_* functions)",
"return",
"new",
"Swift_SendmailTransport",
"(",
")",
";",
"case",
"'external'",
":",
"// SMTP",
"$",
"smtp_host",
"=",
"Site",
"::",
"getPreference",
"(",
"'SMTP_HOST'",
")",
";",
"$",
"smtp_port",
"=",
"(",
"int",
")",
"Site",
"::",
"getPreference",
"(",
"'SMTP_PORT'",
",",
"'25'",
")",
";",
"$",
"smtp_auth",
"=",
"Site",
"::",
"getPreference",
"(",
"'SMTP_AUTH'",
")",
";",
"$",
"smtp_user",
"=",
"Site",
"::",
"getPreference",
"(",
"'SMTP_AUTH_USER'",
")",
";",
"$",
"smtp_pass",
"=",
"Site",
"::",
"getPreference",
"(",
"'SMTP_AUTH_PASS'",
")",
";",
"$",
"smtp_encr",
"=",
"Site",
"::",
"getPreference",
"(",
"'SMTP_SSL'",
")",
";",
"$",
"transport",
"=",
"new",
"Swift_SmtpTransport",
"(",
"$",
"smtp_host",
",",
"$",
"smtp_port",
",",
"$",
"smtp_encr",
")",
";",
"$",
"transport",
"->",
"setLocalDomain",
"(",
"Site",
"::",
"getPreference",
"(",
"'SMTP_HELO'",
")",
")",
";",
"if",
"(",
"$",
"smtp_auth",
")",
"{",
"$",
"transport",
"->",
"setUsername",
"(",
"$",
"smtp_user",
")",
"->",
"setPassword",
"(",
"$",
"smtp_pass",
")",
";",
"}",
"return",
"$",
"transport",
";",
"default",
":",
"// For testing",
"return",
"new",
"Swift_NullTransport",
"(",
")",
";",
"}",
"}"
] | Create a transport mechanism for sending mail
@return Swift_Transport | [
"Create",
"a",
"transport",
"mechanism",
"for",
"sending",
"mail"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Mail.php#L76-L108 | train |
fisharebest/webtrees | app/Functions/FunctionsEdit.php | FunctionsEdit.optionsRestrictions | public static function optionsRestrictions($include_empty): array
{
$options = [
'none' => I18N::translate('Show to visitors'),
'privacy' => I18N::translate('Show to members'),
'confidential' => I18N::translate('Show to managers'),
'locked' => I18N::translate('Only managers can edit'),
];
if ($include_empty) {
$options = ['' => ''] + $options;
}
return $options;
} | php | public static function optionsRestrictions($include_empty): array
{
$options = [
'none' => I18N::translate('Show to visitors'),
'privacy' => I18N::translate('Show to members'),
'confidential' => I18N::translate('Show to managers'),
'locked' => I18N::translate('Only managers can edit'),
];
if ($include_empty) {
$options = ['' => ''] + $options;
}
return $options;
} | [
"public",
"static",
"function",
"optionsRestrictions",
"(",
"$",
"include_empty",
")",
":",
"array",
"{",
"$",
"options",
"=",
"[",
"'none'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to visitors'",
")",
",",
"'privacy'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to members'",
")",
",",
"'confidential'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to managers'",
")",
",",
"'locked'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Only managers can edit'",
")",
",",
"]",
";",
"if",
"(",
"$",
"include_empty",
")",
"{",
"$",
"options",
"=",
"[",
"''",
"=>",
"''",
"]",
"+",
"$",
"options",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | A list of GEDCOM restrictions for inline data.
@param bool $include_empty
@return string[] | [
"A",
"list",
"of",
"GEDCOM",
"restrictions",
"for",
"inline",
"data",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsEdit.php#L225-L239 | train |
fisharebest/webtrees | app/Functions/FunctionsEdit.php | FunctionsEdit.optionsRestrictionsRule | public static function optionsRestrictionsRule(): array
{
$options = [
'none' => I18N::translate('Show to visitors'),
'privacy' => I18N::translate('Show to members'),
'confidential' => I18N::translate('Show to managers'),
'hidden' => I18N::translate('Hide from everyone'),
];
return $options;
} | php | public static function optionsRestrictionsRule(): array
{
$options = [
'none' => I18N::translate('Show to visitors'),
'privacy' => I18N::translate('Show to members'),
'confidential' => I18N::translate('Show to managers'),
'hidden' => I18N::translate('Hide from everyone'),
];
return $options;
} | [
"public",
"static",
"function",
"optionsRestrictionsRule",
"(",
")",
":",
"array",
"{",
"$",
"options",
"=",
"[",
"'none'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to visitors'",
")",
",",
"'privacy'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to members'",
")",
",",
"'confidential'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Show to managers'",
")",
",",
"'hidden'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Hide from everyone'",
")",
",",
"]",
";",
"return",
"$",
"options",
";",
"}"
] | A list of GEDCOM restrictions for privacy rules.
@return string[] | [
"A",
"list",
"of",
"GEDCOM",
"restrictions",
"for",
"privacy",
"rules",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsEdit.php#L246-L256 | train |
fisharebest/webtrees | app/Functions/FunctionsEdit.php | FunctionsEdit.addSimpleTags | public static function addSimpleTags(Tree $tree, $fact): void
{
// For new individuals, these facts default to "Y"
if ($fact === 'MARR') {
echo self::addSimpleTag($tree, '0 ' . $fact . ' Y');
} else {
echo self::addSimpleTag($tree, '0 ' . $fact);
}
if (!in_array($fact, Config::nonDateFacts(), true)) {
echo self::addSimpleTag($tree, '0 DATE', $fact, GedcomTag::getLabel($fact . ':DATE'));
echo self::addSimpleTag($tree, '0 RELI', $fact, GedcomTag::getLabel($fact . ':RELI'));
}
if (!in_array($fact, Config::nonPlaceFacts(), true)) {
echo self::addSimpleTag($tree, '0 PLAC', $fact, GedcomTag::getLabel($fact . ':PLAC'));
if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $tag) {
echo self::addSimpleTag($tree, '0 ' . $tag, $fact, GedcomTag::getLabel($fact . ':PLAC:' . $tag));
}
}
echo self::addSimpleTag($tree, '0 MAP', $fact);
echo self::addSimpleTag($tree, '0 LATI', $fact);
echo self::addSimpleTag($tree, '0 LONG', $fact);
}
} | php | public static function addSimpleTags(Tree $tree, $fact): void
{
// For new individuals, these facts default to "Y"
if ($fact === 'MARR') {
echo self::addSimpleTag($tree, '0 ' . $fact . ' Y');
} else {
echo self::addSimpleTag($tree, '0 ' . $fact);
}
if (!in_array($fact, Config::nonDateFacts(), true)) {
echo self::addSimpleTag($tree, '0 DATE', $fact, GedcomTag::getLabel($fact . ':DATE'));
echo self::addSimpleTag($tree, '0 RELI', $fact, GedcomTag::getLabel($fact . ':RELI'));
}
if (!in_array($fact, Config::nonPlaceFacts(), true)) {
echo self::addSimpleTag($tree, '0 PLAC', $fact, GedcomTag::getLabel($fact . ':PLAC'));
if (preg_match_all('/(' . Gedcom::REGEX_TAG . ')/', $tree->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
foreach ($match[1] as $tag) {
echo self::addSimpleTag($tree, '0 ' . $tag, $fact, GedcomTag::getLabel($fact . ':PLAC:' . $tag));
}
}
echo self::addSimpleTag($tree, '0 MAP', $fact);
echo self::addSimpleTag($tree, '0 LATI', $fact);
echo self::addSimpleTag($tree, '0 LONG', $fact);
}
} | [
"public",
"static",
"function",
"addSimpleTags",
"(",
"Tree",
"$",
"tree",
",",
"$",
"fact",
")",
":",
"void",
"{",
"// For new individuals, these facts default to \"Y\"",
"if",
"(",
"$",
"fact",
"===",
"'MARR'",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 '",
".",
"$",
"fact",
".",
"' Y'",
")",
";",
"}",
"else",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 '",
".",
"$",
"fact",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fact",
",",
"Config",
"::",
"nonDateFacts",
"(",
")",
",",
"true",
")",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 DATE'",
",",
"$",
"fact",
",",
"GedcomTag",
"::",
"getLabel",
"(",
"$",
"fact",
".",
"':DATE'",
")",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 RELI'",
",",
"$",
"fact",
",",
"GedcomTag",
"::",
"getLabel",
"(",
"$",
"fact",
".",
"':RELI'",
")",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fact",
",",
"Config",
"::",
"nonPlaceFacts",
"(",
")",
",",
"true",
")",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 PLAC'",
",",
"$",
"fact",
",",
"GedcomTag",
"::",
"getLabel",
"(",
"$",
"fact",
".",
"':PLAC'",
")",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/('",
".",
"Gedcom",
"::",
"REGEX_TAG",
".",
"')/'",
",",
"$",
"tree",
"->",
"getPreference",
"(",
"'ADVANCED_PLAC_FACTS'",
")",
",",
"$",
"match",
")",
")",
"{",
"foreach",
"(",
"$",
"match",
"[",
"1",
"]",
"as",
"$",
"tag",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 '",
".",
"$",
"tag",
",",
"$",
"fact",
",",
"GedcomTag",
"::",
"getLabel",
"(",
"$",
"fact",
".",
"':PLAC:'",
".",
"$",
"tag",
")",
")",
";",
"}",
"}",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 MAP'",
",",
"$",
"fact",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 LATI'",
",",
"$",
"fact",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'0 LONG'",
",",
"$",
"fact",
")",
";",
"}",
"}"
] | Add some empty tags to create a new fact.
@param Tree $tree
@param string $fact
@return void | [
"Add",
"some",
"empty",
"tags",
"to",
"create",
"a",
"new",
"fact",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsEdit.php#L639-L665 | train |
fisharebest/webtrees | app/Functions/FunctionsEdit.php | FunctionsEdit.createAddForm | public static function createAddForm(Tree $tree, $fact): void
{
self::$tags = [];
// handle MARRiage TYPE
if (substr($fact, 0, 5) === 'MARR_') {
self::$tags[0] = 'MARR';
echo self::addSimpleTag($tree, '1 MARR');
self::insertMissingSubtags($tree, $fact);
} else {
self::$tags[0] = $fact;
if ($fact === '_UID') {
$fact .= ' ' . GedcomTag::createUid();
}
// These new level 1 tags need to be turned into links
if (in_array($fact, [
'ALIA',
'ASSO',
])) {
$fact .= ' @';
}
if (in_array($fact, Config::emptyFacts(), true)) {
echo self::addSimpleTag($tree, '1 ' . $fact . ' Y');
} else {
echo self::addSimpleTag($tree, '1 ' . $fact);
}
self::insertMissingSubtags($tree, self::$tags[0]);
//-- handle the special SOURce case for level 1 sources [ 1759246 ]
if ($fact === 'SOUR') {
echo self::addSimpleTag($tree, '2 PAGE');
echo self::addSimpleTag($tree, '2 DATA');
echo self::addSimpleTag($tree, '3 TEXT');
if ($tree->getPreference('FULL_SOURCES')) {
echo self::addSimpleTag($tree, '3 DATE', '', GedcomTag::getLabel('DATA:DATE'));
echo self::addSimpleTag($tree, '2 QUAY');
}
}
}
} | php | public static function createAddForm(Tree $tree, $fact): void
{
self::$tags = [];
// handle MARRiage TYPE
if (substr($fact, 0, 5) === 'MARR_') {
self::$tags[0] = 'MARR';
echo self::addSimpleTag($tree, '1 MARR');
self::insertMissingSubtags($tree, $fact);
} else {
self::$tags[0] = $fact;
if ($fact === '_UID') {
$fact .= ' ' . GedcomTag::createUid();
}
// These new level 1 tags need to be turned into links
if (in_array($fact, [
'ALIA',
'ASSO',
])) {
$fact .= ' @';
}
if (in_array($fact, Config::emptyFacts(), true)) {
echo self::addSimpleTag($tree, '1 ' . $fact . ' Y');
} else {
echo self::addSimpleTag($tree, '1 ' . $fact);
}
self::insertMissingSubtags($tree, self::$tags[0]);
//-- handle the special SOURce case for level 1 sources [ 1759246 ]
if ($fact === 'SOUR') {
echo self::addSimpleTag($tree, '2 PAGE');
echo self::addSimpleTag($tree, '2 DATA');
echo self::addSimpleTag($tree, '3 TEXT');
if ($tree->getPreference('FULL_SOURCES')) {
echo self::addSimpleTag($tree, '3 DATE', '', GedcomTag::getLabel('DATA:DATE'));
echo self::addSimpleTag($tree, '2 QUAY');
}
}
}
} | [
"public",
"static",
"function",
"createAddForm",
"(",
"Tree",
"$",
"tree",
",",
"$",
"fact",
")",
":",
"void",
"{",
"self",
"::",
"$",
"tags",
"=",
"[",
"]",
";",
"// handle MARRiage TYPE",
"if",
"(",
"substr",
"(",
"$",
"fact",
",",
"0",
",",
"5",
")",
"===",
"'MARR_'",
")",
"{",
"self",
"::",
"$",
"tags",
"[",
"0",
"]",
"=",
"'MARR'",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'1 MARR'",
")",
";",
"self",
"::",
"insertMissingSubtags",
"(",
"$",
"tree",
",",
"$",
"fact",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"tags",
"[",
"0",
"]",
"=",
"$",
"fact",
";",
"if",
"(",
"$",
"fact",
"===",
"'_UID'",
")",
"{",
"$",
"fact",
".=",
"' '",
".",
"GedcomTag",
"::",
"createUid",
"(",
")",
";",
"}",
"// These new level 1 tags need to be turned into links",
"if",
"(",
"in_array",
"(",
"$",
"fact",
",",
"[",
"'ALIA'",
",",
"'ASSO'",
",",
"]",
")",
")",
"{",
"$",
"fact",
".=",
"' @'",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"fact",
",",
"Config",
"::",
"emptyFacts",
"(",
")",
",",
"true",
")",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'1 '",
".",
"$",
"fact",
".",
"' Y'",
")",
";",
"}",
"else",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'1 '",
".",
"$",
"fact",
")",
";",
"}",
"self",
"::",
"insertMissingSubtags",
"(",
"$",
"tree",
",",
"self",
"::",
"$",
"tags",
"[",
"0",
"]",
")",
";",
"//-- handle the special SOURce case for level 1 sources [ 1759246 ]",
"if",
"(",
"$",
"fact",
"===",
"'SOUR'",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'2 PAGE'",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'2 DATA'",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'3 TEXT'",
")",
";",
"if",
"(",
"$",
"tree",
"->",
"getPreference",
"(",
"'FULL_SOURCES'",
")",
")",
"{",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'3 DATE'",
",",
"''",
",",
"GedcomTag",
"::",
"getLabel",
"(",
"'DATA:DATE'",
")",
")",
";",
"echo",
"self",
"::",
"addSimpleTag",
"(",
"$",
"tree",
",",
"'2 QUAY'",
")",
";",
"}",
"}",
"}",
"}"
] | builds the form for adding new facts
@param Tree $tree
@param string $fact the new fact we are adding
@return void | [
"builds",
"the",
"form",
"for",
"adding",
"new",
"facts"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsEdit.php#L675-L713 | train |
fisharebest/webtrees | app/Note.php | Note.getNote | public function getNote(): string
{
if (preg_match('/^0 @' . Gedcom::REGEX_XREF . '@ NOTE ?(.*(?:\n1 CONT ?.*)*)/', $this->gedcom . $this->pending, $match)) {
return preg_replace("/\n1 CONT ?/", "\n", $match[1]);
}
return '';
} | php | public function getNote(): string
{
if (preg_match('/^0 @' . Gedcom::REGEX_XREF . '@ NOTE ?(.*(?:\n1 CONT ?.*)*)/', $this->gedcom . $this->pending, $match)) {
return preg_replace("/\n1 CONT ?/", "\n", $match[1]);
}
return '';
} | [
"public",
"function",
"getNote",
"(",
")",
":",
"string",
"{",
"if",
"(",
"preg_match",
"(",
"'/^0 @'",
".",
"Gedcom",
"::",
"REGEX_XREF",
".",
"'@ NOTE ?(.*(?:\\n1 CONT ?.*)*)/'",
",",
"$",
"this",
"->",
"gedcom",
".",
"$",
"this",
"->",
"pending",
",",
"$",
"match",
")",
")",
"{",
"return",
"preg_replace",
"(",
"\"/\\n1 CONT ?/\"",
",",
"\"\\n\"",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Get the text contents of the note
@return string | [
"Get",
"the",
"text",
"contents",
"of",
"the",
"note"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Note.php#L76-L83 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.whereFamily | private function whereFamily(bool $fams, Builder $query): void
{
if ($fams) {
$query->join('link', static function (JoinClause $join): void {
$join
->on('l_from', '=', 'n_id')
->on('l_file', '=', 'n_file')
->where('l_type', '=', 'FAMS');
});
}
} | php | private function whereFamily(bool $fams, Builder $query): void
{
if ($fams) {
$query->join('link', static function (JoinClause $join): void {
$join
->on('l_from', '=', 'n_id')
->on('l_file', '=', 'n_file')
->where('l_type', '=', 'FAMS');
});
}
} | [
"private",
"function",
"whereFamily",
"(",
"bool",
"$",
"fams",
",",
"Builder",
"$",
"query",
")",
":",
"void",
"{",
"if",
"(",
"$",
"fams",
")",
"{",
"$",
"query",
"->",
"join",
"(",
"'link'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l_from'",
",",
"'='",
",",
"'n_id'",
")",
"->",
"on",
"(",
"'l_file'",
",",
"'='",
",",
"'n_file'",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"'FAMS'",
")",
";",
"}",
")",
";",
"}",
"}"
] | Restrict a query to individuals that are a spouse in a family record.
@param bool $fams
@param Builder $query | [
"Restrict",
"a",
"query",
"to",
"individuals",
"that",
"are",
"a",
"spouse",
"in",
"a",
"family",
"record",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L59-L69 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.surnameAlpha | public function surnameAlpha(bool $marnm, bool $fams, string $locale, string $collation): array
{
$n_surn = $this->fieldWithCollation('n_surn', $collation);
$alphas = [];
$query = DB::table('name')->where('n_file', '=', $this->tree->id());
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
// Fetch all the letters in our alphabet, whether or not there
// are any names beginning with that letter. It looks better to
// show the full alphabet, rather than omitting rare letters such as X.
foreach ($this->localization_service->alphabet() as $letter) {
$query2 = clone $query;
$this->whereInitial($query2, 'n_surn', $letter, $locale, $collation);
$alphas[$letter] = $query2->count();
}
// Now fetch initial letters that are not in our alphabet,
// including "@" (for "@N.N.") and "" for no surname.
$query2 = clone $query;
foreach ($this->localization_service->alphabet() as $n => $letter) {
$query2->where($n_surn, 'NOT LIKE', $letter . '%');
}
$rows = $query2
->select([DB::raw('SUBSTR(n_surn, 1, 1) AS initial'), DB::raw('COUNT(*) AS count')])
->groupBy('initial')
->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END"))
->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END"))
->orderBy('initial')
->pluck('count', 'initial');
foreach ($rows as $alpha => $count) {
$alphas[$alpha] = (int) $count;
}
$count_no_surname = $query->where('n_surn', '=', '')->count();
if ($count_no_surname !== 0) {
// Special code to indicate "no surname"
$alphas[','] = $count_no_surname;
}
return $alphas;
} | php | public function surnameAlpha(bool $marnm, bool $fams, string $locale, string $collation): array
{
$n_surn = $this->fieldWithCollation('n_surn', $collation);
$alphas = [];
$query = DB::table('name')->where('n_file', '=', $this->tree->id());
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
// Fetch all the letters in our alphabet, whether or not there
// are any names beginning with that letter. It looks better to
// show the full alphabet, rather than omitting rare letters such as X.
foreach ($this->localization_service->alphabet() as $letter) {
$query2 = clone $query;
$this->whereInitial($query2, 'n_surn', $letter, $locale, $collation);
$alphas[$letter] = $query2->count();
}
// Now fetch initial letters that are not in our alphabet,
// including "@" (for "@N.N.") and "" for no surname.
$query2 = clone $query;
foreach ($this->localization_service->alphabet() as $n => $letter) {
$query2->where($n_surn, 'NOT LIKE', $letter . '%');
}
$rows = $query2
->select([DB::raw('SUBSTR(n_surn, 1, 1) AS initial'), DB::raw('COUNT(*) AS count')])
->groupBy('initial')
->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END"))
->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END"))
->orderBy('initial')
->pluck('count', 'initial');
foreach ($rows as $alpha => $count) {
$alphas[$alpha] = (int) $count;
}
$count_no_surname = $query->where('n_surn', '=', '')->count();
if ($count_no_surname !== 0) {
// Special code to indicate "no surname"
$alphas[','] = $count_no_surname;
}
return $alphas;
} | [
"public",
"function",
"surnameAlpha",
"(",
"bool",
"$",
"marnm",
",",
"bool",
"$",
"fams",
",",
"string",
"$",
"locale",
",",
"string",
"$",
"collation",
")",
":",
"array",
"{",
"$",
"n_surn",
"=",
"$",
"this",
"->",
"fieldWithCollation",
"(",
"'n_surn'",
",",
"$",
"collation",
")",
";",
"$",
"alphas",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'name'",
")",
"->",
"where",
"(",
"'n_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
";",
"$",
"this",
"->",
"whereFamily",
"(",
"$",
"fams",
",",
"$",
"query",
")",
";",
"$",
"this",
"->",
"whereMarriedName",
"(",
"$",
"marnm",
",",
"$",
"query",
")",
";",
"// Fetch all the letters in our alphabet, whether or not there",
"// are any names beginning with that letter. It looks better to",
"// show the full alphabet, rather than omitting rare letters such as X.",
"foreach",
"(",
"$",
"this",
"->",
"localization_service",
"->",
"alphabet",
"(",
")",
"as",
"$",
"letter",
")",
"{",
"$",
"query2",
"=",
"clone",
"$",
"query",
";",
"$",
"this",
"->",
"whereInitial",
"(",
"$",
"query2",
",",
"'n_surn'",
",",
"$",
"letter",
",",
"$",
"locale",
",",
"$",
"collation",
")",
";",
"$",
"alphas",
"[",
"$",
"letter",
"]",
"=",
"$",
"query2",
"->",
"count",
"(",
")",
";",
"}",
"// Now fetch initial letters that are not in our alphabet,",
"// including \"@\" (for \"@N.N.\") and \"\" for no surname.",
"$",
"query2",
"=",
"clone",
"$",
"query",
";",
"foreach",
"(",
"$",
"this",
"->",
"localization_service",
"->",
"alphabet",
"(",
")",
"as",
"$",
"n",
"=>",
"$",
"letter",
")",
"{",
"$",
"query2",
"->",
"where",
"(",
"$",
"n_surn",
",",
"'NOT LIKE'",
",",
"$",
"letter",
".",
"'%'",
")",
";",
"}",
"$",
"rows",
"=",
"$",
"query2",
"->",
"select",
"(",
"[",
"DB",
"::",
"raw",
"(",
"'SUBSTR(n_surn, 1, 1) AS initial'",
")",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(*) AS count'",
")",
"]",
")",
"->",
"groupBy",
"(",
"'initial'",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"\"CASE initial WHEN '' THEN 1 ELSE 0 END\"",
")",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"\"CASE initial WHEN '@' THEN 1 ELSE 0 END\"",
")",
")",
"->",
"orderBy",
"(",
"'initial'",
")",
"->",
"pluck",
"(",
"'count'",
",",
"'initial'",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"alpha",
"=>",
"$",
"count",
")",
"{",
"$",
"alphas",
"[",
"$",
"alpha",
"]",
"=",
"(",
"int",
")",
"$",
"count",
";",
"}",
"$",
"count_no_surname",
"=",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"''",
")",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"count_no_surname",
"!==",
"0",
")",
"{",
"// Special code to indicate \"no surname\"",
"$",
"alphas",
"[",
"','",
"]",
"=",
"$",
"count_no_surname",
";",
"}",
"return",
"$",
"alphas",
";",
"}"
] | Get a list of initial surname letters.
@param bool $marnm if set, include married names
@param bool $fams if set, only consider individuals with FAMS records
@param string $locale
@param string $collation
@return int[] | [
"Get",
"a",
"list",
"of",
"initial",
"surname",
"letters",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L94-L142 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.givenAlpha | public function givenAlpha(string $surn, string $salpha, bool $marnm, bool $fams, string $locale, string $collation): array
{
$alphas = [];
$query = DB::table('name')
->where('n_file', '=', $this->tree->id());
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
if ($surn !== '') {
$n_surn = $this->fieldWithCollation('n_surn', $collation);
$query->where($n_surn, '=', $surn);
} elseif ($salpha === ',') {
$query->where('n_surn', '=', '');
} elseif ($salpha === '@') {
$query->where('n_surn', '=', '@N.N.');
} elseif ($salpha !== '') {
$this->whereInitial($query, 'n_surn', $salpha, $locale, $collation);
} else {
// All surnames
$query->whereNotIn('n_surn', ['', '@N.N.']);
}
// Fetch all the letters in our alphabet, whether or not there
// are any names beginning with that letter. It looks better to
// show the full alphabet, rather than omitting rare letters such as X
foreach ($this->localization_service->alphabet() as $letter) {
$query2 = clone $query;
$this->whereInitial($query2, 'n_givn', $letter, $locale, $collation);
$alphas[$letter] = (int) $query2->distinct()->count('n_id');
}
$rows = $query
->select([DB::raw('UPPER(SUBSTR(n_givn, 1, 1)) AS initial'), DB::raw('COUNT(*) AS count')])
->groupBy('initial')
->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END"))
->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END"))
->orderBy('initial')
->pluck('count', 'initial');
foreach ($rows as $alpha => $count) {
$alphas[$alpha] = (int) $count;
}
return $alphas;
} | php | public function givenAlpha(string $surn, string $salpha, bool $marnm, bool $fams, string $locale, string $collation): array
{
$alphas = [];
$query = DB::table('name')
->where('n_file', '=', $this->tree->id());
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
if ($surn !== '') {
$n_surn = $this->fieldWithCollation('n_surn', $collation);
$query->where($n_surn, '=', $surn);
} elseif ($salpha === ',') {
$query->where('n_surn', '=', '');
} elseif ($salpha === '@') {
$query->where('n_surn', '=', '@N.N.');
} elseif ($salpha !== '') {
$this->whereInitial($query, 'n_surn', $salpha, $locale, $collation);
} else {
// All surnames
$query->whereNotIn('n_surn', ['', '@N.N.']);
}
// Fetch all the letters in our alphabet, whether or not there
// are any names beginning with that letter. It looks better to
// show the full alphabet, rather than omitting rare letters such as X
foreach ($this->localization_service->alphabet() as $letter) {
$query2 = clone $query;
$this->whereInitial($query2, 'n_givn', $letter, $locale, $collation);
$alphas[$letter] = (int) $query2->distinct()->count('n_id');
}
$rows = $query
->select([DB::raw('UPPER(SUBSTR(n_givn, 1, 1)) AS initial'), DB::raw('COUNT(*) AS count')])
->groupBy('initial')
->orderBy(DB::raw("CASE initial WHEN '' THEN 1 ELSE 0 END"))
->orderBy(DB::raw("CASE initial WHEN '@' THEN 1 ELSE 0 END"))
->orderBy('initial')
->pluck('count', 'initial');
foreach ($rows as $alpha => $count) {
$alphas[$alpha] = (int) $count;
}
return $alphas;
} | [
"public",
"function",
"givenAlpha",
"(",
"string",
"$",
"surn",
",",
"string",
"$",
"salpha",
",",
"bool",
"$",
"marnm",
",",
"bool",
"$",
"fams",
",",
"string",
"$",
"locale",
",",
"string",
"$",
"collation",
")",
":",
"array",
"{",
"$",
"alphas",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'name'",
")",
"->",
"where",
"(",
"'n_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
";",
"$",
"this",
"->",
"whereFamily",
"(",
"$",
"fams",
",",
"$",
"query",
")",
";",
"$",
"this",
"->",
"whereMarriedName",
"(",
"$",
"marnm",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"surn",
"!==",
"''",
")",
"{",
"$",
"n_surn",
"=",
"$",
"this",
"->",
"fieldWithCollation",
"(",
"'n_surn'",
",",
"$",
"collation",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"n_surn",
",",
"'='",
",",
"$",
"surn",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"===",
"','",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"''",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"===",
"'@'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"'@N.N.'",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"whereInitial",
"(",
"$",
"query",
",",
"'n_surn'",
",",
"$",
"salpha",
",",
"$",
"locale",
",",
"$",
"collation",
")",
";",
"}",
"else",
"{",
"// All surnames",
"$",
"query",
"->",
"whereNotIn",
"(",
"'n_surn'",
",",
"[",
"''",
",",
"'@N.N.'",
"]",
")",
";",
"}",
"// Fetch all the letters in our alphabet, whether or not there",
"// are any names beginning with that letter. It looks better to",
"// show the full alphabet, rather than omitting rare letters such as X",
"foreach",
"(",
"$",
"this",
"->",
"localization_service",
"->",
"alphabet",
"(",
")",
"as",
"$",
"letter",
")",
"{",
"$",
"query2",
"=",
"clone",
"$",
"query",
";",
"$",
"this",
"->",
"whereInitial",
"(",
"$",
"query2",
",",
"'n_givn'",
",",
"$",
"letter",
",",
"$",
"locale",
",",
"$",
"collation",
")",
";",
"$",
"alphas",
"[",
"$",
"letter",
"]",
"=",
"(",
"int",
")",
"$",
"query2",
"->",
"distinct",
"(",
")",
"->",
"count",
"(",
"'n_id'",
")",
";",
"}",
"$",
"rows",
"=",
"$",
"query",
"->",
"select",
"(",
"[",
"DB",
"::",
"raw",
"(",
"'UPPER(SUBSTR(n_givn, 1, 1)) AS initial'",
")",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(*) AS count'",
")",
"]",
")",
"->",
"groupBy",
"(",
"'initial'",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"\"CASE initial WHEN '' THEN 1 ELSE 0 END\"",
")",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"\"CASE initial WHEN '@' THEN 1 ELSE 0 END\"",
")",
")",
"->",
"orderBy",
"(",
"'initial'",
")",
"->",
"pluck",
"(",
"'count'",
",",
"'initial'",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"alpha",
"=>",
"$",
"count",
")",
"{",
"$",
"alphas",
"[",
"$",
"alpha",
"]",
"=",
"(",
"int",
")",
"$",
"count",
";",
"}",
"return",
"$",
"alphas",
";",
"}"
] | Get a list of initial given name letters for indilist.php and famlist.php
@param string $surn if set, only consider people with this surname
@param string $salpha if set, only consider surnames starting with this letter
@param bool $marnm if set, include married names
@param bool $fams if set, only consider individuals with FAMS records
@param string $locale
@param string $collation
@return int[] | [
"Get",
"a",
"list",
"of",
"initial",
"given",
"name",
"letters",
"for",
"indilist",
".",
"php",
"and",
"famlist",
".",
"php"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L156-L204 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.surnames | public function surnames(string $surn, string $salpha, bool $marnm, bool $fams, string $locale, string $collation): array
{
$query = DB::table('name')
->where('n_file', '=', $this->tree->id())
->select([
DB::raw('UPPER(n_surn /*! COLLATE ' . I18N::collation() . ' */) AS n_surn'),
DB::raw('n_surname /*! COLLATE utf8_bin */ AS n_surname'),
DB::raw('COUNT(*) AS total'),
])
->groupBy(['n_surn'])
->groupBy(['n_surname'])
->orderBy('n_surname');
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
if ($surn !== '') {
$query->where('n_surn', '=', $surn);
} elseif ($salpha === ',') {
$query->where('n_surn', '=', '');
} elseif ($salpha === '@') {
$query->where('n_surn', '=', '@N.N.');
} elseif ($salpha !== '') {
$this->whereInitial($query, 'n_surn', $salpha, $locale, $collation);
} else {
// All surnames
$query->whereNotIn('n_surn', ['', '@N.N.']);
}
$query->groupBy(['n_surn'])->groupBy(['n_surname']);
$list = [];
foreach ($query->get() as $row) {
$list[$row->n_surn][$row->n_surname] = (int) $row->total;
}
return $list;
} | php | public function surnames(string $surn, string $salpha, bool $marnm, bool $fams, string $locale, string $collation): array
{
$query = DB::table('name')
->where('n_file', '=', $this->tree->id())
->select([
DB::raw('UPPER(n_surn /*! COLLATE ' . I18N::collation() . ' */) AS n_surn'),
DB::raw('n_surname /*! COLLATE utf8_bin */ AS n_surname'),
DB::raw('COUNT(*) AS total'),
])
->groupBy(['n_surn'])
->groupBy(['n_surname'])
->orderBy('n_surname');
$this->whereFamily($fams, $query);
$this->whereMarriedName($marnm, $query);
if ($surn !== '') {
$query->where('n_surn', '=', $surn);
} elseif ($salpha === ',') {
$query->where('n_surn', '=', '');
} elseif ($salpha === '@') {
$query->where('n_surn', '=', '@N.N.');
} elseif ($salpha !== '') {
$this->whereInitial($query, 'n_surn', $salpha, $locale, $collation);
} else {
// All surnames
$query->whereNotIn('n_surn', ['', '@N.N.']);
}
$query->groupBy(['n_surn'])->groupBy(['n_surname']);
$list = [];
foreach ($query->get() as $row) {
$list[$row->n_surn][$row->n_surname] = (int) $row->total;
}
return $list;
} | [
"public",
"function",
"surnames",
"(",
"string",
"$",
"surn",
",",
"string",
"$",
"salpha",
",",
"bool",
"$",
"marnm",
",",
"bool",
"$",
"fams",
",",
"string",
"$",
"locale",
",",
"string",
"$",
"collation",
")",
":",
"array",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'name'",
")",
"->",
"where",
"(",
"'n_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"select",
"(",
"[",
"DB",
"::",
"raw",
"(",
"'UPPER(n_surn /*! COLLATE '",
".",
"I18N",
"::",
"collation",
"(",
")",
".",
"' */) AS n_surn'",
")",
",",
"DB",
"::",
"raw",
"(",
"'n_surname /*! COLLATE utf8_bin */ AS n_surname'",
")",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(*) AS total'",
")",
",",
"]",
")",
"->",
"groupBy",
"(",
"[",
"'n_surn'",
"]",
")",
"->",
"groupBy",
"(",
"[",
"'n_surname'",
"]",
")",
"->",
"orderBy",
"(",
"'n_surname'",
")",
";",
"$",
"this",
"->",
"whereFamily",
"(",
"$",
"fams",
",",
"$",
"query",
")",
";",
"$",
"this",
"->",
"whereMarriedName",
"(",
"$",
"marnm",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"surn",
"!==",
"''",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"$",
"surn",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"===",
"','",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"''",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"===",
"'@'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'n_surn'",
",",
"'='",
",",
"'@N.N.'",
")",
";",
"}",
"elseif",
"(",
"$",
"salpha",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"whereInitial",
"(",
"$",
"query",
",",
"'n_surn'",
",",
"$",
"salpha",
",",
"$",
"locale",
",",
"$",
"collation",
")",
";",
"}",
"else",
"{",
"// All surnames",
"$",
"query",
"->",
"whereNotIn",
"(",
"'n_surn'",
",",
"[",
"''",
",",
"'@N.N.'",
"]",
")",
";",
"}",
"$",
"query",
"->",
"groupBy",
"(",
"[",
"'n_surn'",
"]",
")",
"->",
"groupBy",
"(",
"[",
"'n_surname'",
"]",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"get",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"list",
"[",
"$",
"row",
"->",
"n_surn",
"]",
"[",
"$",
"row",
"->",
"n_surname",
"]",
"=",
"(",
"int",
")",
"$",
"row",
"->",
"total",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Get a count of actual surnames and variants, based on a "root" surname.
@param string $surn if set, only count people with this surname
@param string $salpha if set, only consider surnames starting with this letter
@param bool $marnm if set, include married names
@param bool $fams if set, only consider individuals with FAMS records
@param string $locale
@param string $collation
@return int[][] | [
"Get",
"a",
"count",
"of",
"actual",
"surnames",
"and",
"variants",
"based",
"on",
"a",
"root",
"surname",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L218-L255 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.fieldWithCollation | private function fieldWithCollation(string $field, string $collation): Expression
{
return DB::raw($field . ' /*! COLLATE ' . $collation . ' */');
} | php | private function fieldWithCollation(string $field, string $collation): Expression
{
return DB::raw($field . ' /*! COLLATE ' . $collation . ' */');
} | [
"private",
"function",
"fieldWithCollation",
"(",
"string",
"$",
"field",
",",
"string",
"$",
"collation",
")",
":",
"Expression",
"{",
"return",
"DB",
"::",
"raw",
"(",
"$",
"field",
".",
"' /*! COLLATE '",
".",
"$",
"collation",
".",
"' */'",
")",
";",
"}"
] | Use MySQL-specific comments so we can run these queries on other RDBMS.
@param string $field
@param string $collation
@return Expression | [
"Use",
"MySQL",
"-",
"specific",
"comments",
"so",
"we",
"can",
"run",
"these",
"queries",
"on",
"other",
"RDBMS",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L365-L368 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.whereInitial | private function whereInitial(Builder $query, string $field, string $letter, string $locale, string $collation): void
{
// Use MySQL-specific comments so we can run these queries on other RDBMS.
$field_with_collation = $this->fieldWithCollation($field, $collation);
switch ($locale) {
case 'cs':
$this->whereInitialCzech($query, $field_with_collation, $letter);
break;
case 'da':
case 'nb':
case 'nn':
$this->whereInitialNorwegian($query, $field_with_collation, $letter);
break;
case 'sv':
case 'fi':
$this->whereInitialSwedish($query, $field_with_collation, $letter);
break;
case 'hu':
$this->whereInitialHungarian($query, $field_with_collation, $letter);
break;
case 'nl':
$this->whereInitialDutch($query, $field_with_collation, $letter);
break;
default:
$query->where($field_with_collation, 'LIKE', '\\' . $letter . '%');
}
} | php | private function whereInitial(Builder $query, string $field, string $letter, string $locale, string $collation): void
{
// Use MySQL-specific comments so we can run these queries on other RDBMS.
$field_with_collation = $this->fieldWithCollation($field, $collation);
switch ($locale) {
case 'cs':
$this->whereInitialCzech($query, $field_with_collation, $letter);
break;
case 'da':
case 'nb':
case 'nn':
$this->whereInitialNorwegian($query, $field_with_collation, $letter);
break;
case 'sv':
case 'fi':
$this->whereInitialSwedish($query, $field_with_collation, $letter);
break;
case 'hu':
$this->whereInitialHungarian($query, $field_with_collation, $letter);
break;
case 'nl':
$this->whereInitialDutch($query, $field_with_collation, $letter);
break;
default:
$query->where($field_with_collation, 'LIKE', '\\' . $letter . '%');
}
} | [
"private",
"function",
"whereInitial",
"(",
"Builder",
"$",
"query",
",",
"string",
"$",
"field",
",",
"string",
"$",
"letter",
",",
"string",
"$",
"locale",
",",
"string",
"$",
"collation",
")",
":",
"void",
"{",
"// Use MySQL-specific comments so we can run these queries on other RDBMS.",
"$",
"field_with_collation",
"=",
"$",
"this",
"->",
"fieldWithCollation",
"(",
"$",
"field",
",",
"$",
"collation",
")",
";",
"switch",
"(",
"$",
"locale",
")",
"{",
"case",
"'cs'",
":",
"$",
"this",
"->",
"whereInitialCzech",
"(",
"$",
"query",
",",
"$",
"field_with_collation",
",",
"$",
"letter",
")",
";",
"break",
";",
"case",
"'da'",
":",
"case",
"'nb'",
":",
"case",
"'nn'",
":",
"$",
"this",
"->",
"whereInitialNorwegian",
"(",
"$",
"query",
",",
"$",
"field_with_collation",
",",
"$",
"letter",
")",
";",
"break",
";",
"case",
"'sv'",
":",
"case",
"'fi'",
":",
"$",
"this",
"->",
"whereInitialSwedish",
"(",
"$",
"query",
",",
"$",
"field_with_collation",
",",
"$",
"letter",
")",
";",
"break",
";",
"case",
"'hu'",
":",
"$",
"this",
"->",
"whereInitialHungarian",
"(",
"$",
"query",
",",
"$",
"field_with_collation",
",",
"$",
"letter",
")",
";",
"break",
";",
"case",
"'nl'",
":",
"$",
"this",
"->",
"whereInitialDutch",
"(",
"$",
"query",
",",
"$",
"field_with_collation",
",",
"$",
"letter",
")",
";",
"break",
";",
"default",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field_with_collation",
",",
"'LIKE'",
",",
"'\\\\'",
".",
"$",
"letter",
".",
"'%'",
")",
";",
"}",
"}"
] | Modify a query to restrict a field to a given initial letter.
Take account of digraphs, equialent letters, etc.
@param Builder $query
@param string $field
@param string $letter
@param string $locale
@param string $collation
@return void | [
"Modify",
"a",
"query",
"to",
"restrict",
"a",
"field",
"to",
"a",
"given",
"initial",
"letter",
".",
"Take",
"account",
"of",
"digraphs",
"equialent",
"letters",
"etc",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L382-L414 | train |
fisharebest/webtrees | app/Services/IndividualListService.php | IndividualListService.whereInitialHungarian | private function whereInitialHungarian(Builder $query, Expression $field, string $letter): void
{
switch ($letter) {
case 'C':
$query->where($field, 'LIKE', 'C%')->where($field, 'NOT LIKE', 'CS%');
break;
case 'D':
$query->where($field, 'LIKE', 'D%')->where($field, 'NOT LIKE', 'DZ%');
break;
case 'DZ':
$query->where($field, 'LIKE', 'DZ%')->where($field, 'NOT LIKE', 'DZS%');
break;
case 'G':
$query->where($field, 'LIKE', 'G%')->where($field, 'NOT LIKE', 'GY%');
break;
case 'L':
$query->where($field, 'LIKE', 'L%')->where($field, 'NOT LIKE', 'LY%');
break;
case 'N':
$query->where($field, 'LIKE', 'N%')->where($field, 'NOT LIKE', 'NY%');
break;
case 'S':
$query->where($field, 'LIKE', 'S%')->where($field, 'NOT LIKE', 'SZ%');
break;
case 'T':
$query->where($field, 'LIKE', 'T%')->where($field, 'NOT LIKE', 'TY%');
break;
case 'Z':
$query->where($field, 'LIKE', 'Z%')->where($field, 'NOT LIKE', 'ZS%');
break;
default:
$query->where($field, 'LIKE', '\\' . $letter . '%');
break;
}
} | php | private function whereInitialHungarian(Builder $query, Expression $field, string $letter): void
{
switch ($letter) {
case 'C':
$query->where($field, 'LIKE', 'C%')->where($field, 'NOT LIKE', 'CS%');
break;
case 'D':
$query->where($field, 'LIKE', 'D%')->where($field, 'NOT LIKE', 'DZ%');
break;
case 'DZ':
$query->where($field, 'LIKE', 'DZ%')->where($field, 'NOT LIKE', 'DZS%');
break;
case 'G':
$query->where($field, 'LIKE', 'G%')->where($field, 'NOT LIKE', 'GY%');
break;
case 'L':
$query->where($field, 'LIKE', 'L%')->where($field, 'NOT LIKE', 'LY%');
break;
case 'N':
$query->where($field, 'LIKE', 'N%')->where($field, 'NOT LIKE', 'NY%');
break;
case 'S':
$query->where($field, 'LIKE', 'S%')->where($field, 'NOT LIKE', 'SZ%');
break;
case 'T':
$query->where($field, 'LIKE', 'T%')->where($field, 'NOT LIKE', 'TY%');
break;
case 'Z':
$query->where($field, 'LIKE', 'Z%')->where($field, 'NOT LIKE', 'ZS%');
break;
default:
$query->where($field, 'LIKE', '\\' . $letter . '%');
break;
}
} | [
"private",
"function",
"whereInitialHungarian",
"(",
"Builder",
"$",
"query",
",",
"Expression",
"$",
"field",
",",
"string",
"$",
"letter",
")",
":",
"void",
"{",
"switch",
"(",
"$",
"letter",
")",
"{",
"case",
"'C'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'C%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'CS%'",
")",
";",
"break",
";",
"case",
"'D'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'D%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'DZ%'",
")",
";",
"break",
";",
"case",
"'DZ'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'DZ%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'DZS%'",
")",
";",
"break",
";",
"case",
"'G'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'G%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'GY%'",
")",
";",
"break",
";",
"case",
"'L'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'L%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'LY%'",
")",
";",
"break",
";",
"case",
"'N'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'N%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'NY%'",
")",
";",
"break",
";",
"case",
"'S'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'S%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'SZ%'",
")",
";",
"break",
";",
"case",
"'T'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'T%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'TY%'",
")",
";",
"break",
";",
"case",
"'Z'",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'Z%'",
")",
"->",
"where",
"(",
"$",
"field",
",",
"'NOT LIKE'",
",",
"'ZS%'",
")",
";",
"break",
";",
"default",
":",
"$",
"query",
"->",
"where",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'\\\\'",
".",
"$",
"letter",
".",
"'%'",
")",
";",
"break",
";",
"}",
"}"
] | Hungarian has many digraphs and trigraphs, so exclude these from prefixes.
@param Builder $query
@param Expression $field
@param string $letter | [
"Hungarian",
"has",
"many",
"digraphs",
"and",
"trigraphs",
"so",
"exclude",
"these",
"from",
"prefixes",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/IndividualListService.php#L459-L502 | train |
fisharebest/webtrees | app/GedcomCode/GedcomCodeRela.php | GedcomCodeRela.getValues | public static function getValues(GedcomRecord $record = null): array
{
$values = [];
foreach (self::TYPES as $type) {
$values[$type] = self::getValue($type, $record);
}
uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $values;
} | php | public static function getValues(GedcomRecord $record = null): array
{
$values = [];
foreach (self::TYPES as $type) {
$values[$type] = self::getValue($type, $record);
}
uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $values;
} | [
"public",
"static",
"function",
"getValues",
"(",
"GedcomRecord",
"$",
"record",
"=",
"null",
")",
":",
"array",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"TYPES",
"as",
"$",
"type",
")",
"{",
"$",
"values",
"[",
"$",
"type",
"]",
"=",
"self",
"::",
"getValue",
"(",
"$",
"type",
",",
"$",
"record",
")",
";",
"}",
"uasort",
"(",
"$",
"values",
",",
"'\\Fisharebest\\Webtrees\\I18N::strcasecmp'",
")",
";",
"return",
"$",
"values",
";",
"}"
] | A list of all possible values for RELA
@param GedcomRecord|null $record
@return string[] | [
"A",
"list",
"of",
"all",
"possible",
"values",
"for",
"RELA"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomCode/GedcomCodeRela.php#L362-L371 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.commonGivenQuery | private function commonGivenQuery(string $sex, string $type, bool $show_tot, int $threshold, int $maxtoshow)
{
$query = DB::table('name')
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_file', '=', 'n_file')
->on('i_id', '=', 'n_id');
})
->where('n_file', '=', $this->tree->id())
->where('n_type', '<>', '_MARNM')
->where('n_givn', '<>', '@P.N.')
->where(DB::raw('LENGTH(n_givn)'), '>', 1);
switch ($sex) {
case 'M':
case 'F':
case 'U':
$query->where('i_sex', '=', $sex);
break;
case 'B':
default:
$query->where('i_sex', '<>', 'U');
break;
}
$rows = $query
->groupBy(['n_givn'])
->select(['n_givn', DB::raw('COUNT(distinct n_id) AS count')])
->pluck('count', 'n_givn');
$nameList = [];
foreach ($rows as $n_givn => $count) {
// Split “John Thomas” into “John” and “Thomas” and count against both totals
foreach (explode(' ', $n_givn) as $given) {
// Exclude initials and particles.
if (!preg_match('/^([A-Z]|[a-z]{1,3})$/', $given)) {
if (array_key_exists($given, $nameList)) {
$nameList[$given] += (int) $count;
} else {
$nameList[$given] = (int) $count;
}
}
}
}
arsort($nameList);
$nameList = array_slice($nameList, 0, $maxtoshow);
foreach ($nameList as $given => $total) {
if ($total < $threshold) {
unset($nameList[$given]);
}
}
switch ($type) {
case 'chart':
return $nameList;
case 'table':
return view('lists/given-names-table', [
'given_names' => $nameList,
]);
case 'list':
return view('lists/given-names-list', [
'given_names' => $nameList,
'show_totals' => $show_tot,
]);
case 'nolist':
default:
array_walk($nameList, static function (string &$value, string $key) use ($show_tot): void {
if ($show_tot) {
$value = '<span dir="auto">' . e($key) . '</span>';
} else {
$value = '<span dir="auto">' . e($key) . '</span> (' . I18N::number((int) $value) . ')';
}
});
return implode(I18N::$list_separator, $nameList);
}
} | php | private function commonGivenQuery(string $sex, string $type, bool $show_tot, int $threshold, int $maxtoshow)
{
$query = DB::table('name')
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_file', '=', 'n_file')
->on('i_id', '=', 'n_id');
})
->where('n_file', '=', $this->tree->id())
->where('n_type', '<>', '_MARNM')
->where('n_givn', '<>', '@P.N.')
->where(DB::raw('LENGTH(n_givn)'), '>', 1);
switch ($sex) {
case 'M':
case 'F':
case 'U':
$query->where('i_sex', '=', $sex);
break;
case 'B':
default:
$query->where('i_sex', '<>', 'U');
break;
}
$rows = $query
->groupBy(['n_givn'])
->select(['n_givn', DB::raw('COUNT(distinct n_id) AS count')])
->pluck('count', 'n_givn');
$nameList = [];
foreach ($rows as $n_givn => $count) {
// Split “John Thomas” into “John” and “Thomas” and count against both totals
foreach (explode(' ', $n_givn) as $given) {
// Exclude initials and particles.
if (!preg_match('/^([A-Z]|[a-z]{1,3})$/', $given)) {
if (array_key_exists($given, $nameList)) {
$nameList[$given] += (int) $count;
} else {
$nameList[$given] = (int) $count;
}
}
}
}
arsort($nameList);
$nameList = array_slice($nameList, 0, $maxtoshow);
foreach ($nameList as $given => $total) {
if ($total < $threshold) {
unset($nameList[$given]);
}
}
switch ($type) {
case 'chart':
return $nameList;
case 'table':
return view('lists/given-names-table', [
'given_names' => $nameList,
]);
case 'list':
return view('lists/given-names-list', [
'given_names' => $nameList,
'show_totals' => $show_tot,
]);
case 'nolist':
default:
array_walk($nameList, static function (string &$value, string $key) use ($show_tot): void {
if ($show_tot) {
$value = '<span dir="auto">' . e($key) . '</span>';
} else {
$value = '<span dir="auto">' . e($key) . '</span> (' . I18N::number((int) $value) . ')';
}
});
return implode(I18N::$list_separator, $nameList);
}
} | [
"private",
"function",
"commonGivenQuery",
"(",
"string",
"$",
"sex",
",",
"string",
"$",
"type",
",",
"bool",
"$",
"show_tot",
",",
"int",
"$",
"threshold",
",",
"int",
"$",
"maxtoshow",
")",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'name'",
")",
"->",
"join",
"(",
"'individuals'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'i_file'",
",",
"'='",
",",
"'n_file'",
")",
"->",
"on",
"(",
"'i_id'",
",",
"'='",
",",
"'n_id'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'n_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'n_type'",
",",
"'<>'",
",",
"'_MARNM'",
")",
"->",
"where",
"(",
"'n_givn'",
",",
"'<>'",
",",
"'@P.N.'",
")",
"->",
"where",
"(",
"DB",
"::",
"raw",
"(",
"'LENGTH(n_givn)'",
")",
",",
"'>'",
",",
"1",
")",
";",
"switch",
"(",
"$",
"sex",
")",
"{",
"case",
"'M'",
":",
"case",
"'F'",
":",
"case",
"'U'",
":",
"$",
"query",
"->",
"where",
"(",
"'i_sex'",
",",
"'='",
",",
"$",
"sex",
")",
";",
"break",
";",
"case",
"'B'",
":",
"default",
":",
"$",
"query",
"->",
"where",
"(",
"'i_sex'",
",",
"'<>'",
",",
"'U'",
")",
";",
"break",
";",
"}",
"$",
"rows",
"=",
"$",
"query",
"->",
"groupBy",
"(",
"[",
"'n_givn'",
"]",
")",
"->",
"select",
"(",
"[",
"'n_givn'",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(distinct n_id) AS count'",
")",
"]",
")",
"->",
"pluck",
"(",
"'count'",
",",
"'n_givn'",
")",
";",
"$",
"nameList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"n_givn",
"=>",
"$",
"count",
")",
"{",
"// Split “John Thomas” into “John” and “Thomas” and count against both totals",
"foreach",
"(",
"explode",
"(",
"' '",
",",
"$",
"n_givn",
")",
"as",
"$",
"given",
")",
"{",
"// Exclude initials and particles.",
"if",
"(",
"!",
"preg_match",
"(",
"'/^([A-Z]|[a-z]{1,3})$/'",
",",
"$",
"given",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"given",
",",
"$",
"nameList",
")",
")",
"{",
"$",
"nameList",
"[",
"$",
"given",
"]",
"+=",
"(",
"int",
")",
"$",
"count",
";",
"}",
"else",
"{",
"$",
"nameList",
"[",
"$",
"given",
"]",
"=",
"(",
"int",
")",
"$",
"count",
";",
"}",
"}",
"}",
"}",
"arsort",
"(",
"$",
"nameList",
")",
";",
"$",
"nameList",
"=",
"array_slice",
"(",
"$",
"nameList",
",",
"0",
",",
"$",
"maxtoshow",
")",
";",
"foreach",
"(",
"$",
"nameList",
"as",
"$",
"given",
"=>",
"$",
"total",
")",
"{",
"if",
"(",
"$",
"total",
"<",
"$",
"threshold",
")",
"{",
"unset",
"(",
"$",
"nameList",
"[",
"$",
"given",
"]",
")",
";",
"}",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'chart'",
":",
"return",
"$",
"nameList",
";",
"case",
"'table'",
":",
"return",
"view",
"(",
"'lists/given-names-table'",
",",
"[",
"'given_names'",
"=>",
"$",
"nameList",
",",
"]",
")",
";",
"case",
"'list'",
":",
"return",
"view",
"(",
"'lists/given-names-list'",
",",
"[",
"'given_names'",
"=>",
"$",
"nameList",
",",
"'show_totals'",
"=>",
"$",
"show_tot",
",",
"]",
")",
";",
"case",
"'nolist'",
":",
"default",
":",
"array_walk",
"(",
"$",
"nameList",
",",
"static",
"function",
"(",
"string",
"&",
"$",
"value",
",",
"string",
"$",
"key",
")",
"use",
"(",
"$",
"show_tot",
")",
":",
"void",
"{",
"if",
"(",
"$",
"show_tot",
")",
"{",
"$",
"value",
"=",
"'<span dir=\"auto\">'",
".",
"e",
"(",
"$",
"key",
")",
".",
"'</span>'",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"'<span dir=\"auto\">'",
".",
"e",
"(",
"$",
"key",
")",
".",
"'</span> ('",
".",
"I18N",
"::",
"number",
"(",
"(",
"int",
")",
"$",
"value",
")",
".",
"')'",
";",
"}",
"}",
")",
";",
"return",
"implode",
"(",
"I18N",
"::",
"$",
"list_separator",
",",
"$",
"nameList",
")",
";",
"}",
"}"
] | Find common given names.
@param string $sex
@param string $type
@param bool $show_tot
@param int $threshold
@param int $maxtoshow
@return string|int[] | [
"Find",
"common",
"given",
"names",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L81-L163 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.statsBirthBySexQuery | public function statsBirthBySexQuery(int $year1 = -1, int $year2 = -1): Builder
{
return $this->statsBirthQuery($year1, $year2)
->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_id', '=', 'd_gid')
->on('i_file', '=', 'd_file');
})
->groupBy('i_sex');
} | php | public function statsBirthBySexQuery(int $year1 = -1, int $year2 = -1): Builder
{
return $this->statsBirthQuery($year1, $year2)
->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_id', '=', 'd_gid')
->on('i_file', '=', 'd_file');
})
->groupBy('i_sex');
} | [
"public",
"function",
"statsBirthBySexQuery",
"(",
"int",
"$",
"year1",
"=",
"-",
"1",
",",
"int",
"$",
"year2",
"=",
"-",
"1",
")",
":",
"Builder",
"{",
"return",
"$",
"this",
"->",
"statsBirthQuery",
"(",
"$",
"year1",
",",
"$",
"year2",
")",
"->",
"select",
"(",
"[",
"'d_month'",
",",
"'i_sex'",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(*) AS total'",
")",
"]",
")",
"->",
"join",
"(",
"'individuals'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'i_id'",
",",
"'='",
",",
"'d_gid'",
")",
"->",
"on",
"(",
"'i_file'",
",",
"'='",
",",
"'d_file'",
")",
";",
"}",
")",
"->",
"groupBy",
"(",
"'i_sex'",
")",
";",
"}"
] | Get a count of births by month.
@param int $year1
@param int $year2
@return Builder | [
"Get",
"a",
"count",
"of",
"births",
"by",
"month",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L679-L689 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.statsBirth | public function statsBirth(string $color_from = null, string $color_to = null): string
{
return (new ChartBirth($this->tree))
->chartBirth($color_from, $color_to);
} | php | public function statsBirth(string $color_from = null, string $color_to = null): string
{
return (new ChartBirth($this->tree))
->chartBirth($color_from, $color_to);
} | [
"public",
"function",
"statsBirth",
"(",
"string",
"$",
"color_from",
"=",
"null",
",",
"string",
"$",
"color_to",
"=",
"null",
")",
":",
"string",
"{",
"return",
"(",
"new",
"ChartBirth",
"(",
"$",
"this",
"->",
"tree",
")",
")",
"->",
"chartBirth",
"(",
"$",
"color_from",
",",
"$",
"color_to",
")",
";",
"}"
] | General query on births.
@param string|null $color_from
@param string|null $color_to
@return string | [
"General",
"query",
"on",
"births",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L699-L703 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.statsDeathBySexQuery | public function statsDeathBySexQuery(int $year1 = -1, int $year2 = -1): Builder
{
return $this->statsDeathQuery($year1, $year2)
->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_id', '=', 'd_gid')
->on('i_file', '=', 'd_file');
})
->groupBy('i_sex');
} | php | public function statsDeathBySexQuery(int $year1 = -1, int $year2 = -1): Builder
{
return $this->statsDeathQuery($year1, $year2)
->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
->join('individuals', static function (JoinClause $join): void {
$join
->on('i_id', '=', 'd_gid')
->on('i_file', '=', 'd_file');
})
->groupBy('i_sex');
} | [
"public",
"function",
"statsDeathBySexQuery",
"(",
"int",
"$",
"year1",
"=",
"-",
"1",
",",
"int",
"$",
"year2",
"=",
"-",
"1",
")",
":",
"Builder",
"{",
"return",
"$",
"this",
"->",
"statsDeathQuery",
"(",
"$",
"year1",
",",
"$",
"year2",
")",
"->",
"select",
"(",
"[",
"'d_month'",
",",
"'i_sex'",
",",
"DB",
"::",
"raw",
"(",
"'COUNT(*) AS total'",
")",
"]",
")",
"->",
"join",
"(",
"'individuals'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'i_id'",
",",
"'='",
",",
"'d_gid'",
")",
"->",
"on",
"(",
"'i_file'",
",",
"'='",
",",
"'d_file'",
")",
";",
"}",
")",
"->",
"groupBy",
"(",
"'i_sex'",
")",
";",
"}"
] | Get a list of death dates.
@param int $year1
@param int $year2
@return Builder | [
"Get",
"a",
"list",
"of",
"death",
"dates",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L737-L747 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.statsDeath | public function statsDeath(string $color_from = null, string $color_to = null): string
{
return (new ChartDeath($this->tree))
->chartDeath($color_from, $color_to);
} | php | public function statsDeath(string $color_from = null, string $color_to = null): string
{
return (new ChartDeath($this->tree))
->chartDeath($color_from, $color_to);
} | [
"public",
"function",
"statsDeath",
"(",
"string",
"$",
"color_from",
"=",
"null",
",",
"string",
"$",
"color_to",
"=",
"null",
")",
":",
"string",
"{",
"return",
"(",
"new",
"ChartDeath",
"(",
"$",
"this",
"->",
"tree",
")",
")",
"->",
"chartDeath",
"(",
"$",
"color_from",
",",
"$",
"color_to",
")",
";",
"}"
] | General query on deaths.
@param string|null $color_from
@param string|null $color_to
@return string | [
"General",
"query",
"on",
"deaths",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L757-L761 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.statsAgeQuery | public function statsAgeQuery(string $related = 'BIRT', string $sex = 'BOTH', int $year1 = -1, int $year2 = -1)
{
$prefix = DB::connection()->getTablePrefix();
$query = $this->birthAndDeathQuery($sex);
if ($year1 >= 0 && $year2 >= 0) {
$query
->whereIn('birth.d_type', ['@#DGREGORIAN@', '@#DJULIAN@'])
->whereIn('death.d_type', ['@#DGREGORIAN@', '@#DJULIAN@']);
if ($related === 'BIRT') {
$query->whereBetween('birth.d_year', [$year1, $year2]);
} elseif ($related === 'DEAT') {
$query->whereBetween('death.d_year', [$year1, $year2]);
}
}
return $query
->select(DB::raw($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days'))
->orderBy('days', 'desc')
->get()
->all();
} | php | public function statsAgeQuery(string $related = 'BIRT', string $sex = 'BOTH', int $year1 = -1, int $year2 = -1)
{
$prefix = DB::connection()->getTablePrefix();
$query = $this->birthAndDeathQuery($sex);
if ($year1 >= 0 && $year2 >= 0) {
$query
->whereIn('birth.d_type', ['@#DGREGORIAN@', '@#DJULIAN@'])
->whereIn('death.d_type', ['@#DGREGORIAN@', '@#DJULIAN@']);
if ($related === 'BIRT') {
$query->whereBetween('birth.d_year', [$year1, $year2]);
} elseif ($related === 'DEAT') {
$query->whereBetween('death.d_year', [$year1, $year2]);
}
}
return $query
->select(DB::raw($prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1 AS days'))
->orderBy('days', 'desc')
->get()
->all();
} | [
"public",
"function",
"statsAgeQuery",
"(",
"string",
"$",
"related",
"=",
"'BIRT'",
",",
"string",
"$",
"sex",
"=",
"'BOTH'",
",",
"int",
"$",
"year1",
"=",
"-",
"1",
",",
"int",
"$",
"year2",
"=",
"-",
"1",
")",
"{",
"$",
"prefix",
"=",
"DB",
"::",
"connection",
"(",
")",
"->",
"getTablePrefix",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"birthAndDeathQuery",
"(",
"$",
"sex",
")",
";",
"if",
"(",
"$",
"year1",
">=",
"0",
"&&",
"$",
"year2",
">=",
"0",
")",
"{",
"$",
"query",
"->",
"whereIn",
"(",
"'birth.d_type'",
",",
"[",
"'@#DGREGORIAN@'",
",",
"'@#DJULIAN@'",
"]",
")",
"->",
"whereIn",
"(",
"'death.d_type'",
",",
"[",
"'@#DGREGORIAN@'",
",",
"'@#DJULIAN@'",
"]",
")",
";",
"if",
"(",
"$",
"related",
"===",
"'BIRT'",
")",
"{",
"$",
"query",
"->",
"whereBetween",
"(",
"'birth.d_year'",
",",
"[",
"$",
"year1",
",",
"$",
"year2",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"related",
"===",
"'DEAT'",
")",
"{",
"$",
"query",
"->",
"whereBetween",
"(",
"'death.d_year'",
",",
"[",
"$",
"year1",
",",
"$",
"year2",
"]",
")",
";",
"}",
"}",
"return",
"$",
"query",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"$",
"prefix",
".",
"'death.d_julianday2 - '",
".",
"$",
"prefix",
".",
"'birth.d_julianday1 AS days'",
")",
")",
"->",
"orderBy",
"(",
"'days'",
",",
"'desc'",
")",
"->",
"get",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] | General query on ages.
@param string $related
@param string $sex
@param int $year1
@param int $year2
@return array|string | [
"General",
"query",
"on",
"ages",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L773-L796 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.topTenOldestFemale | public function topTenOldestFemale(int $total = 10): string
{
$records = $this->topTenOldestQuery('F', $total);
return view('statistics/individuals/top10-nolist', [
'records' => $records,
]);
} | php | public function topTenOldestFemale(int $total = 10): string
{
$records = $this->topTenOldestQuery('F', $total);
return view('statistics/individuals/top10-nolist', [
'records' => $records,
]);
} | [
"public",
"function",
"topTenOldestFemale",
"(",
"int",
"$",
"total",
"=",
"10",
")",
":",
"string",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"topTenOldestQuery",
"(",
"'F'",
",",
"$",
"total",
")",
";",
"return",
"view",
"(",
"'statistics/individuals/top10-nolist'",
",",
"[",
"'records'",
"=>",
"$",
"records",
",",
"]",
")",
";",
"}"
] | Find the oldest females.
@param int $total
@return string | [
"Find",
"the",
"oldest",
"females",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1033-L1040 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.topTenOldestFemaleList | public function topTenOldestFemaleList(int $total = 10): string
{
$records = $this->topTenOldestQuery('F', $total);
return view('statistics/individuals/top10-list', [
'records' => $records,
]);
} | php | public function topTenOldestFemaleList(int $total = 10): string
{
$records = $this->topTenOldestQuery('F', $total);
return view('statistics/individuals/top10-list', [
'records' => $records,
]);
} | [
"public",
"function",
"topTenOldestFemaleList",
"(",
"int",
"$",
"total",
"=",
"10",
")",
":",
"string",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"topTenOldestQuery",
"(",
"'F'",
",",
"$",
"total",
")",
";",
"return",
"view",
"(",
"'statistics/individuals/top10-list'",
",",
"[",
"'records'",
"=>",
"$",
"records",
",",
"]",
")",
";",
"}"
] | Find the oldest living females.
@param int $total
@return string | [
"Find",
"the",
"oldest",
"living",
"females",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1049-L1056 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.averageLifespanQuery | private function averageLifespanQuery(string $sex, bool $show_years): string
{
$prefix = DB::connection()->getTablePrefix();
$days = (int) $this->birthAndDeathQuery($sex)
->select(DB::raw('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days'))
->value('days');
if ($show_years) {
return $this->calculateAge($days);
}
return I18N::number((int) ($days / 365.25));
} | php | private function averageLifespanQuery(string $sex, bool $show_years): string
{
$prefix = DB::connection()->getTablePrefix();
$days = (int) $this->birthAndDeathQuery($sex)
->select(DB::raw('AVG(' . $prefix . 'death.d_julianday2 - ' . $prefix . 'birth.d_julianday1) AS days'))
->value('days');
if ($show_years) {
return $this->calculateAge($days);
}
return I18N::number((int) ($days / 365.25));
} | [
"private",
"function",
"averageLifespanQuery",
"(",
"string",
"$",
"sex",
",",
"bool",
"$",
"show_years",
")",
":",
"string",
"{",
"$",
"prefix",
"=",
"DB",
"::",
"connection",
"(",
")",
"->",
"getTablePrefix",
"(",
")",
";",
"$",
"days",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"birthAndDeathQuery",
"(",
"$",
"sex",
")",
"->",
"select",
"(",
"DB",
"::",
"raw",
"(",
"'AVG('",
".",
"$",
"prefix",
".",
"'death.d_julianday2 - '",
".",
"$",
"prefix",
".",
"'birth.d_julianday1) AS days'",
")",
")",
"->",
"value",
"(",
"'days'",
")",
";",
"if",
"(",
"$",
"show_years",
")",
"{",
"return",
"$",
"this",
"->",
"calculateAge",
"(",
"$",
"days",
")",
";",
"}",
"return",
"I18N",
"::",
"number",
"(",
"(",
"int",
")",
"(",
"$",
"days",
"/",
"365.25",
")",
")",
";",
"}"
] | Find the average lifespan.
@param string $sex "M", "F" or "BOTH"
@param bool $show_years
@return string | [
"Find",
"the",
"average",
"lifespan",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1262-L1275 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.getPercentage | private function getPercentage(int $count, int $total): string
{
return ($total !== 0) ? I18N::percentage($count / $total, 1) : '';
} | php | private function getPercentage(int $count, int $total): string
{
return ($total !== 0) ? I18N::percentage($count / $total, 1) : '';
} | [
"private",
"function",
"getPercentage",
"(",
"int",
"$",
"count",
",",
"int",
"$",
"total",
")",
":",
"string",
"{",
"return",
"(",
"$",
"total",
"!==",
"0",
")",
"?",
"I18N",
"::",
"percentage",
"(",
"$",
"count",
"/",
"$",
"total",
",",
"1",
")",
":",
"''",
";",
"}"
] | Convert totals into percentages.
@param int $count
@param int $total
@return string | [
"Convert",
"totals",
"into",
"percentages",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1321-L1324 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.totalLivingQuery | private function totalLivingQuery(): int
{
$query = DB::table('individuals')
->where('i_file', '=', $this->tree->id());
foreach (Gedcom::DEATH_EVENTS as $death_event) {
$query->where('i_gedcom', 'NOT LIKE', "%\n1 " . $death_event . '%');
}
return $query->count();
} | php | private function totalLivingQuery(): int
{
$query = DB::table('individuals')
->where('i_file', '=', $this->tree->id());
foreach (Gedcom::DEATH_EVENTS as $death_event) {
$query->where('i_gedcom', 'NOT LIKE', "%\n1 " . $death_event . '%');
}
return $query->count();
} | [
"private",
"function",
"totalLivingQuery",
"(",
")",
":",
"int",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
";",
"foreach",
"(",
"Gedcom",
"::",
"DEATH_EVENTS",
"as",
"$",
"death_event",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'i_gedcom'",
",",
"'NOT LIKE'",
",",
"\"%\\n1 \"",
".",
"$",
"death_event",
".",
"'%'",
")",
";",
"}",
"return",
"$",
"query",
"->",
"count",
"(",
")",
";",
"}"
] | Count the number of living individuals.
The totalLiving/totalDeceased queries assume that every dead person will
have a DEAT record. It will not include individuals who were born more
than MAX_ALIVE_AGE years ago, and who have no DEAT record.
A good reason to run the “Add missing DEAT records” batch-update!
@return int | [
"Count",
"the",
"number",
"of",
"living",
"individuals",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1348-L1358 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.totalDeceasedQuery | private function totalDeceasedQuery(): int
{
return DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->where(static function (Builder $query): void {
foreach (Gedcom::DEATH_EVENTS as $death_event) {
$query->orWhere('i_gedcom', 'LIKE', "%\n1 " . $death_event . '%');
}
})
->count();
} | php | private function totalDeceasedQuery(): int
{
return DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->where(static function (Builder $query): void {
foreach (Gedcom::DEATH_EVENTS as $death_event) {
$query->orWhere('i_gedcom', 'LIKE', "%\n1 " . $death_event . '%');
}
})
->count();
} | [
"private",
"function",
"totalDeceasedQuery",
"(",
")",
":",
"int",
"{",
"return",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"static",
"function",
"(",
"Builder",
"$",
"query",
")",
":",
"void",
"{",
"foreach",
"(",
"Gedcom",
"::",
"DEATH_EVENTS",
"as",
"$",
"death_event",
")",
"{",
"$",
"query",
"->",
"orWhere",
"(",
"'i_gedcom'",
",",
"'LIKE'",
",",
"\"%\\n1 \"",
".",
"$",
"death_event",
".",
"'%'",
")",
";",
"}",
"}",
")",
"->",
"count",
"(",
")",
";",
"}"
] | Count the number of dead individuals.
@return int | [
"Count",
"the",
"number",
"of",
"dead",
"individuals",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1365-L1375 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.getTotalSexQuery | private function getTotalSexQuery(string $sex): int
{
return DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->where('i_sex', '=', $sex)
->count();
} | php | private function getTotalSexQuery(string $sex): int
{
return DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->where('i_sex', '=', $sex)
->count();
} | [
"private",
"function",
"getTotalSexQuery",
"(",
"string",
"$",
"sex",
")",
":",
"int",
"{",
"return",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'i_sex'",
",",
"'='",
",",
"$",
"sex",
")",
"->",
"count",
"(",
")",
";",
"}"
] | Returns the total count of a specific sex.
@param string $sex The sex to query
@return int | [
"Returns",
"the",
"total",
"count",
"of",
"a",
"specific",
"sex",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1384-L1390 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.totalIndisWithSourcesQuery | private function totalIndisWithSourcesQuery(): int
{
return DB::table('individuals')
->select(['i_id'])
->distinct()
->join('link', static function (JoinClause $join): void {
$join->on('i_id', '=', 'l_from')
->on('i_file', '=', 'l_file');
})
->where('l_file', '=', $this->tree->id())
->where('l_type', '=', 'SOUR')
->count('i_id');
} | php | private function totalIndisWithSourcesQuery(): int
{
return DB::table('individuals')
->select(['i_id'])
->distinct()
->join('link', static function (JoinClause $join): void {
$join->on('i_id', '=', 'l_from')
->on('i_file', '=', 'l_file');
})
->where('l_file', '=', $this->tree->id())
->where('l_type', '=', 'SOUR')
->count('i_id');
} | [
"private",
"function",
"totalIndisWithSourcesQuery",
"(",
")",
":",
"int",
"{",
"return",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"select",
"(",
"[",
"'i_id'",
"]",
")",
"->",
"distinct",
"(",
")",
"->",
"join",
"(",
"'link'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'i_id'",
",",
"'='",
",",
"'l_from'",
")",
"->",
"on",
"(",
"'i_file'",
",",
"'='",
",",
"'l_file'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'l_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"'SOUR'",
")",
"->",
"count",
"(",
"'i_id'",
")",
";",
"}"
] | How many individuals have one or more sources.
@return int | [
"How",
"many",
"individuals",
"have",
"one",
"or",
"more",
"sources",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1439-L1451 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.totalRecordsQuery | private function totalRecordsQuery(): int
{
return $this->totalIndividualsQuery()
+ $this->totalFamiliesQuery()
+ $this->totalNotesQuery()
+ $this->totalRepositoriesQuery()
+ $this->totalSourcesQuery();
} | php | private function totalRecordsQuery(): int
{
return $this->totalIndividualsQuery()
+ $this->totalFamiliesQuery()
+ $this->totalNotesQuery()
+ $this->totalRepositoriesQuery()
+ $this->totalSourcesQuery();
} | [
"private",
"function",
"totalRecordsQuery",
"(",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"totalIndividualsQuery",
"(",
")",
"+",
"$",
"this",
"->",
"totalFamiliesQuery",
"(",
")",
"+",
"$",
"this",
"->",
"totalNotesQuery",
"(",
")",
"+",
"$",
"this",
"->",
"totalRepositoriesQuery",
"(",
")",
"+",
"$",
"this",
"->",
"totalSourcesQuery",
"(",
")",
";",
"}"
] | Returns the total number of records.
@return int | [
"Returns",
"the",
"total",
"number",
"of",
"records",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1515-L1522 | train |
fisharebest/webtrees | app/Statistics/Repository/IndividualRepository.php | IndividualRepository.birthAndDeathQuery | private function birthAndDeathQuery(string $sex): Builder
{
$query = DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->join('dates AS birth', static function (JoinClause $join): void {
$join
->on('birth.d_file', '=', 'i_file')
->on('birth.d_gid', '=', 'i_id');
})
->join('dates AS death', static function (JoinClause $join): void {
$join
->on('death.d_file', '=', 'i_file')
->on('death.d_gid', '=', 'i_id');
})
->where('birth.d_fact', '=', 'BIRT')
->where('death.d_fact', '=', 'DEAT')
->whereColumn('death.d_julianday1', '>=', 'birth.d_julianday2')
->where('birth.d_julianday2', '<>', 0);
if ($sex === 'M' || $sex === 'F') {
$query->where('i_sex', '=', $sex);
}
return $query;
} | php | private function birthAndDeathQuery(string $sex): Builder
{
$query = DB::table('individuals')
->where('i_file', '=', $this->tree->id())
->join('dates AS birth', static function (JoinClause $join): void {
$join
->on('birth.d_file', '=', 'i_file')
->on('birth.d_gid', '=', 'i_id');
})
->join('dates AS death', static function (JoinClause $join): void {
$join
->on('death.d_file', '=', 'i_file')
->on('death.d_gid', '=', 'i_id');
})
->where('birth.d_fact', '=', 'BIRT')
->where('death.d_fact', '=', 'DEAT')
->whereColumn('death.d_julianday1', '>=', 'birth.d_julianday2')
->where('birth.d_julianday2', '<>', 0);
if ($sex === 'M' || $sex === 'F') {
$query->where('i_sex', '=', $sex);
}
return $query;
} | [
"private",
"function",
"birthAndDeathQuery",
"(",
"string",
"$",
"sex",
")",
":",
"Builder",
"{",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"join",
"(",
"'dates AS birth'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'birth.d_file'",
",",
"'='",
",",
"'i_file'",
")",
"->",
"on",
"(",
"'birth.d_gid'",
",",
"'='",
",",
"'i_id'",
")",
";",
"}",
")",
"->",
"join",
"(",
"'dates AS death'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'death.d_file'",
",",
"'='",
",",
"'i_file'",
")",
"->",
"on",
"(",
"'death.d_gid'",
",",
"'='",
",",
"'i_id'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'birth.d_fact'",
",",
"'='",
",",
"'BIRT'",
")",
"->",
"where",
"(",
"'death.d_fact'",
",",
"'='",
",",
"'DEAT'",
")",
"->",
"whereColumn",
"(",
"'death.d_julianday1'",
",",
"'>='",
",",
"'birth.d_julianday2'",
")",
"->",
"where",
"(",
"'birth.d_julianday2'",
",",
"'<>'",
",",
"0",
")",
";",
"if",
"(",
"$",
"sex",
"===",
"'M'",
"||",
"$",
"sex",
"===",
"'F'",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'i_sex'",
",",
"'='",
",",
"$",
"sex",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Query individuals, with their births and deaths.
@param string $sex
@return Builder | [
"Query",
"individuals",
"with",
"their",
"births",
"and",
"deaths",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/IndividualRepository.php#L1874-L1898 | train |
fisharebest/webtrees | app/Place.php | Place.parent | public function parent(): Place
{
return new self($this->parts->slice(1)->implode(Gedcom::PLACE_SEPARATOR), $this->tree);
} | php | public function parent(): Place
{
return new self($this->parts->slice(1)->implode(Gedcom::PLACE_SEPARATOR), $this->tree);
} | [
"public",
"function",
"parent",
"(",
")",
":",
"Place",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"parts",
"->",
"slice",
"(",
"1",
")",
"->",
"implode",
"(",
"Gedcom",
"::",
"PLACE_SEPARATOR",
")",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}"
] | Get the higher level place.
@return Place | [
"Get",
"the",
"higher",
"level",
"place",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Place.php#L64-L67 | train |
fisharebest/webtrees | app/Place.php | Place.getChildPlaces | public function getChildPlaces(): array
{
if ($this->place_name !== '') {
$parent_text = Gedcom::PLACE_SEPARATOR . $this->place_name;
} else {
$parent_text = '';
}
return DB::table('places')
->where('p_file', '=', $this->tree->id())
->where('p_parent_id', '=', $this->id())
->orderBy(DB::raw('p_place /*! COLLATE ' . I18N::collation() . ' */'))
->pluck('p_place')
->map(function (string $place) use ($parent_text): Place {
return new self($place . $parent_text, $this->tree);
})
->all();
} | php | public function getChildPlaces(): array
{
if ($this->place_name !== '') {
$parent_text = Gedcom::PLACE_SEPARATOR . $this->place_name;
} else {
$parent_text = '';
}
return DB::table('places')
->where('p_file', '=', $this->tree->id())
->where('p_parent_id', '=', $this->id())
->orderBy(DB::raw('p_place /*! COLLATE ' . I18N::collation() . ' */'))
->pluck('p_place')
->map(function (string $place) use ($parent_text): Place {
return new self($place . $parent_text, $this->tree);
})
->all();
} | [
"public",
"function",
"getChildPlaces",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"place_name",
"!==",
"''",
")",
"{",
"$",
"parent_text",
"=",
"Gedcom",
"::",
"PLACE_SEPARATOR",
".",
"$",
"this",
"->",
"place_name",
";",
"}",
"else",
"{",
"$",
"parent_text",
"=",
"''",
";",
"}",
"return",
"DB",
"::",
"table",
"(",
"'places'",
")",
"->",
"where",
"(",
"'p_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'p_parent_id'",
",",
"'='",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"'p_place /*! COLLATE '",
".",
"I18N",
"::",
"collation",
"(",
")",
".",
"' */'",
")",
")",
"->",
"pluck",
"(",
"'p_place'",
")",
"->",
"map",
"(",
"function",
"(",
"string",
"$",
"place",
")",
"use",
"(",
"$",
"parent_text",
")",
":",
"Place",
"{",
"return",
"new",
"self",
"(",
"$",
"place",
".",
"$",
"parent_text",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Get the lower level places.
@return Place[] | [
"Get",
"the",
"lower",
"level",
"places",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Place.php#L138-L155 | train |
fisharebest/webtrees | app/Place.php | Place.url | public function url(): string
{
//find a module providing the place hierarchy
$module = app(ModuleService::class)
->findByComponent(ModuleListInterface::class, $this->tree, Auth::user())
->first(static function (ModuleInterface $module): bool {
return $module instanceof PlaceHierarchyListModule;
});
if ($module instanceof PlaceHierarchyListModule) {
return $module->listUrl($this->tree, [
'parent' => $this->parts->reverse()->all(),
'ged' => $this->tree->name(),
]);
}
// The place-list module is disabled...
return '#';
} | php | public function url(): string
{
//find a module providing the place hierarchy
$module = app(ModuleService::class)
->findByComponent(ModuleListInterface::class, $this->tree, Auth::user())
->first(static function (ModuleInterface $module): bool {
return $module instanceof PlaceHierarchyListModule;
});
if ($module instanceof PlaceHierarchyListModule) {
return $module->listUrl($this->tree, [
'parent' => $this->parts->reverse()->all(),
'ged' => $this->tree->name(),
]);
}
// The place-list module is disabled...
return '#';
} | [
"public",
"function",
"url",
"(",
")",
":",
"string",
"{",
"//find a module providing the place hierarchy",
"$",
"module",
"=",
"app",
"(",
"ModuleService",
"::",
"class",
")",
"->",
"findByComponent",
"(",
"ModuleListInterface",
"::",
"class",
",",
"$",
"this",
"->",
"tree",
",",
"Auth",
"::",
"user",
"(",
")",
")",
"->",
"first",
"(",
"static",
"function",
"(",
"ModuleInterface",
"$",
"module",
")",
":",
"bool",
"{",
"return",
"$",
"module",
"instanceof",
"PlaceHierarchyListModule",
";",
"}",
")",
";",
"if",
"(",
"$",
"module",
"instanceof",
"PlaceHierarchyListModule",
")",
"{",
"return",
"$",
"module",
"->",
"listUrl",
"(",
"$",
"this",
"->",
"tree",
",",
"[",
"'parent'",
"=>",
"$",
"this",
"->",
"parts",
"->",
"reverse",
"(",
")",
"->",
"all",
"(",
")",
",",
"'ged'",
"=>",
"$",
"this",
"->",
"tree",
"->",
"name",
"(",
")",
",",
"]",
")",
";",
"}",
"// The place-list module is disabled...",
"return",
"'#'",
";",
"}"
] | Create a URL to the place-hierarchy page.
@return string | [
"Create",
"a",
"URL",
"to",
"the",
"place",
"-",
"hierarchy",
"page",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Place.php#L162-L180 | train |
fisharebest/webtrees | app/Place.php | Place.placeName | public function placeName(): string
{
$place_name = $this->parts->first() ?? I18N::translate('unknown');
return '<span dir="auto">' . e($place_name) . '</span>';
} | php | public function placeName(): string
{
$place_name = $this->parts->first() ?? I18N::translate('unknown');
return '<span dir="auto">' . e($place_name) . '</span>';
} | [
"public",
"function",
"placeName",
"(",
")",
":",
"string",
"{",
"$",
"place_name",
"=",
"$",
"this",
"->",
"parts",
"->",
"first",
"(",
")",
"??",
"I18N",
"::",
"translate",
"(",
"'unknown'",
")",
";",
"return",
"'<span dir=\"auto\">'",
".",
"e",
"(",
"$",
"place_name",
")",
".",
"'</span>'",
";",
"}"
] | Format this place for display on screen.
@return string | [
"Format",
"this",
"place",
"for",
"display",
"on",
"screen",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Place.php#L197-L202 | train |
fisharebest/webtrees | app/Place.php | Place.fullName | public function fullName(bool $link = false): string
{
if ($this->parts->isEmpty()) {
return '';
}
$full_name = $this->parts->implode(I18N::$list_separator);
if ($link) {
return '<a dir="auto" href="' . e($this->url()) . '">' . e($full_name) . '</a>';
}
return '<span dir="auto">' . e($full_name) . '</span>';
} | php | public function fullName(bool $link = false): string
{
if ($this->parts->isEmpty()) {
return '';
}
$full_name = $this->parts->implode(I18N::$list_separator);
if ($link) {
return '<a dir="auto" href="' . e($this->url()) . '">' . e($full_name) . '</a>';
}
return '<span dir="auto">' . e($full_name) . '</span>';
} | [
"public",
"function",
"fullName",
"(",
"bool",
"$",
"link",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"parts",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"full_name",
"=",
"$",
"this",
"->",
"parts",
"->",
"implode",
"(",
"I18N",
"::",
"$",
"list_separator",
")",
";",
"if",
"(",
"$",
"link",
")",
"{",
"return",
"'<a dir=\"auto\" href=\"'",
".",
"e",
"(",
"$",
"this",
"->",
"url",
"(",
")",
")",
".",
"'\">'",
".",
"e",
"(",
"$",
"full_name",
")",
".",
"'</a>'",
";",
"}",
"return",
"'<span dir=\"auto\">'",
".",
"e",
"(",
"$",
"full_name",
")",
".",
"'</span>'",
";",
"}"
] | Generate the place name for display, including the full hierarchy.
@param bool $link
@return string | [
"Generate",
"the",
"place",
"name",
"for",
"display",
"including",
"the",
"full",
"hierarchy",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Place.php#L211-L224 | train |
fisharebest/webtrees | app/Family.php | Family.marriageDateComparator | public static function marriageDateComparator(): Closure
{
return static function (Family $x, Family $y): int {
return Date::compare($x->getMarriageDate(), $y->getMarriageDate());
};
} | php | public static function marriageDateComparator(): Closure
{
return static function (Family $x, Family $y): int {
return Date::compare($x->getMarriageDate(), $y->getMarriageDate());
};
} | [
"public",
"static",
"function",
"marriageDateComparator",
"(",
")",
":",
"Closure",
"{",
"return",
"static",
"function",
"(",
"Family",
"$",
"x",
",",
"Family",
"$",
"y",
")",
":",
"int",
"{",
"return",
"Date",
"::",
"compare",
"(",
"$",
"x",
"->",
"getMarriageDate",
"(",
")",
",",
"$",
"y",
"->",
"getMarriageDate",
"(",
")",
")",
";",
"}",
";",
"}"
] | A closure which will compare families by marriage date.
@return Closure | [
"A",
"closure",
"which",
"will",
"compare",
"families",
"by",
"marriage",
"date",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Family.php#L84-L89 | train |
fisharebest/webtrees | app/Family.php | Family.spouse | public function spouse(Individual $person, $access_level = null): ?Individual
{
if ($person === $this->wife) {
return $this->husband($access_level);
}
return $this->wife($access_level);
} | php | public function spouse(Individual $person, $access_level = null): ?Individual
{
if ($person === $this->wife) {
return $this->husband($access_level);
}
return $this->wife($access_level);
} | [
"public",
"function",
"spouse",
"(",
"Individual",
"$",
"person",
",",
"$",
"access_level",
"=",
"null",
")",
":",
"?",
"Individual",
"{",
"if",
"(",
"$",
"person",
"===",
"$",
"this",
"->",
"wife",
")",
"{",
"return",
"$",
"this",
"->",
"husband",
"(",
"$",
"access_level",
")",
";",
"}",
"return",
"$",
"this",
"->",
"wife",
"(",
"$",
"access_level",
")",
";",
"}"
] | Find the spouse of a person.
@param Individual $person
@param int|null $access_level
@return Individual|null | [
"Find",
"the",
"spouse",
"of",
"a",
"person",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Family.php#L234-L241 | train |
fisharebest/webtrees | app/Family.php | Family.numberOfChildren | public function numberOfChildren(): int
{
$nchi = $this->children()->count();
foreach ($this->facts(['NCHI']) as $fact) {
$nchi = max($nchi, (int) $fact->value());
}
return $nchi;
} | php | public function numberOfChildren(): int
{
$nchi = $this->children()->count();
foreach ($this->facts(['NCHI']) as $fact) {
$nchi = max($nchi, (int) $fact->value());
}
return $nchi;
} | [
"public",
"function",
"numberOfChildren",
"(",
")",
":",
"int",
"{",
"$",
"nchi",
"=",
"$",
"this",
"->",
"children",
"(",
")",
"->",
"count",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"facts",
"(",
"[",
"'NCHI'",
"]",
")",
"as",
"$",
"fact",
")",
"{",
"$",
"nchi",
"=",
"max",
"(",
"$",
"nchi",
",",
"(",
"int",
")",
"$",
"fact",
"->",
"value",
"(",
")",
")",
";",
"}",
"return",
"$",
"nchi",
";",
"}"
] | Number of children - for the individual list
@return int | [
"Number",
"of",
"children",
"-",
"for",
"the",
"individual",
"list"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Family.php#L295-L304 | train |
fisharebest/webtrees | app/Family.php | Family.getMarriagePlace | public function getMarriagePlace(): Place
{
$marriage = $this->getMarriage();
if ($marriage instanceof Fact) {
return $marriage->place();
}
return new Place('', $this->tree);
} | php | public function getMarriagePlace(): Place
{
$marriage = $this->getMarriage();
if ($marriage instanceof Fact) {
return $marriage->place();
}
return new Place('', $this->tree);
} | [
"public",
"function",
"getMarriagePlace",
"(",
")",
":",
"Place",
"{",
"$",
"marriage",
"=",
"$",
"this",
"->",
"getMarriage",
"(",
")",
";",
"if",
"(",
"$",
"marriage",
"instanceof",
"Fact",
")",
"{",
"return",
"$",
"marriage",
"->",
"place",
"(",
")",
";",
"}",
"return",
"new",
"Place",
"(",
"''",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}"
] | Get the marriage place
@return Place | [
"Get",
"the",
"marriage",
"place"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Family.php#L346-L355 | train |
fisharebest/webtrees | app/Family.php | Family.getAllMarriagePlaces | public function getAllMarriagePlaces(): array
{
foreach (Gedcom::MARRIAGE_EVENTS as $event) {
$places = $this->getAllEventPlaces([$event]);
if (!empty($places)) {
return $places;
}
}
return [];
} | php | public function getAllMarriagePlaces(): array
{
foreach (Gedcom::MARRIAGE_EVENTS as $event) {
$places = $this->getAllEventPlaces([$event]);
if (!empty($places)) {
return $places;
}
}
return [];
} | [
"public",
"function",
"getAllMarriagePlaces",
"(",
")",
":",
"array",
"{",
"foreach",
"(",
"Gedcom",
"::",
"MARRIAGE_EVENTS",
"as",
"$",
"event",
")",
"{",
"$",
"places",
"=",
"$",
"this",
"->",
"getAllEventPlaces",
"(",
"[",
"$",
"event",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"places",
")",
")",
"{",
"return",
"$",
"places",
";",
"}",
"}",
"return",
"[",
"]",
";",
"}"
] | Get a list of all marriage places - for the family lists.
@return Place[] | [
"Get",
"a",
"list",
"of",
"all",
"marriage",
"places",
"-",
"for",
"the",
"family",
"lists",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Family.php#L380-L390 | train |
fisharebest/webtrees | app/Http/Controllers/Auth/VerifyEmailController.php | VerifyEmailController.verify | public function verify(ServerRequestInterface $request, Tree $tree, UserService $user_service): ResponseInterface
{
$username = $request->get('username', '');
$token = $request->get('token', '');
$title = I18N::translate('User verification');
$user = $user_service->findByUserName($username);
if ($user instanceof User && $user->getPreference('reg_hashcode') === $token) {
// switch language to webmaster settings
$webmaster = $user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));
if ($webmaster instanceof User) {
I18N::init($webmaster->getPreference('language'));
/* I18N: %s is a server name/URL */
$subject = I18N::translate('New user at %s', WT_BASE_URL . ' ' . $tree->title());
Mail::send(
new TreeUser($tree),
$webmaster,
new TreeUser($tree),
$subject,
view('emails/verify-notify-text', ['user' => $user]),
view('emails/verify-notify-html', ['user' => $user])
);
$mail1_method = $webmaster->getPreference('CONTACT_METHOD');
if ($mail1_method !== 'messaging3' && $mail1_method !== 'mailto' && $mail1_method !== 'none') {
DB::table('message')->insert([
'sender' => $username,
'ip_address' => $request->getClientIp(),
'user_id' => $webmaster->id(),
'subject' => $subject,
'body' => view('emails/verify-notify-text', ['user' => $user]),
]);
}
I18N::init(WT_LOCALE);
}
$user
->setPreference('verified', '1')
->setPreference('reg_timestamp', date('U'))
->setPreference('reg_hashcode', '');
Log::addAuthenticationLog('User ' . $username . ' verified their email address');
return $this->viewResponse('verify-success-page', [
'title' => $title,
]);
}
return $this->viewResponse('verify-failure-page', [
'title' => $title,
]);
} | php | public function verify(ServerRequestInterface $request, Tree $tree, UserService $user_service): ResponseInterface
{
$username = $request->get('username', '');
$token = $request->get('token', '');
$title = I18N::translate('User verification');
$user = $user_service->findByUserName($username);
if ($user instanceof User && $user->getPreference('reg_hashcode') === $token) {
// switch language to webmaster settings
$webmaster = $user_service->find((int) $tree->getPreference('WEBMASTER_USER_ID'));
if ($webmaster instanceof User) {
I18N::init($webmaster->getPreference('language'));
/* I18N: %s is a server name/URL */
$subject = I18N::translate('New user at %s', WT_BASE_URL . ' ' . $tree->title());
Mail::send(
new TreeUser($tree),
$webmaster,
new TreeUser($tree),
$subject,
view('emails/verify-notify-text', ['user' => $user]),
view('emails/verify-notify-html', ['user' => $user])
);
$mail1_method = $webmaster->getPreference('CONTACT_METHOD');
if ($mail1_method !== 'messaging3' && $mail1_method !== 'mailto' && $mail1_method !== 'none') {
DB::table('message')->insert([
'sender' => $username,
'ip_address' => $request->getClientIp(),
'user_id' => $webmaster->id(),
'subject' => $subject,
'body' => view('emails/verify-notify-text', ['user' => $user]),
]);
}
I18N::init(WT_LOCALE);
}
$user
->setPreference('verified', '1')
->setPreference('reg_timestamp', date('U'))
->setPreference('reg_hashcode', '');
Log::addAuthenticationLog('User ' . $username . ' verified their email address');
return $this->viewResponse('verify-success-page', [
'title' => $title,
]);
}
return $this->viewResponse('verify-failure-page', [
'title' => $title,
]);
} | [
"public",
"function",
"verify",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
",",
"UserService",
"$",
"user_service",
")",
":",
"ResponseInterface",
"{",
"$",
"username",
"=",
"$",
"request",
"->",
"get",
"(",
"'username'",
",",
"''",
")",
";",
"$",
"token",
"=",
"$",
"request",
"->",
"get",
"(",
"'token'",
",",
"''",
")",
";",
"$",
"title",
"=",
"I18N",
"::",
"translate",
"(",
"'User verification'",
")",
";",
"$",
"user",
"=",
"$",
"user_service",
"->",
"findByUserName",
"(",
"$",
"username",
")",
";",
"if",
"(",
"$",
"user",
"instanceof",
"User",
"&&",
"$",
"user",
"->",
"getPreference",
"(",
"'reg_hashcode'",
")",
"===",
"$",
"token",
")",
"{",
"// switch language to webmaster settings",
"$",
"webmaster",
"=",
"$",
"user_service",
"->",
"find",
"(",
"(",
"int",
")",
"$",
"tree",
"->",
"getPreference",
"(",
"'WEBMASTER_USER_ID'",
")",
")",
";",
"if",
"(",
"$",
"webmaster",
"instanceof",
"User",
")",
"{",
"I18N",
"::",
"init",
"(",
"$",
"webmaster",
"->",
"getPreference",
"(",
"'language'",
")",
")",
";",
"/* I18N: %s is a server name/URL */",
"$",
"subject",
"=",
"I18N",
"::",
"translate",
"(",
"'New user at %s'",
",",
"WT_BASE_URL",
".",
"' '",
".",
"$",
"tree",
"->",
"title",
"(",
")",
")",
";",
"Mail",
"::",
"send",
"(",
"new",
"TreeUser",
"(",
"$",
"tree",
")",
",",
"$",
"webmaster",
",",
"new",
"TreeUser",
"(",
"$",
"tree",
")",
",",
"$",
"subject",
",",
"view",
"(",
"'emails/verify-notify-text'",
",",
"[",
"'user'",
"=>",
"$",
"user",
"]",
")",
",",
"view",
"(",
"'emails/verify-notify-html'",
",",
"[",
"'user'",
"=>",
"$",
"user",
"]",
")",
")",
";",
"$",
"mail1_method",
"=",
"$",
"webmaster",
"->",
"getPreference",
"(",
"'CONTACT_METHOD'",
")",
";",
"if",
"(",
"$",
"mail1_method",
"!==",
"'messaging3'",
"&&",
"$",
"mail1_method",
"!==",
"'mailto'",
"&&",
"$",
"mail1_method",
"!==",
"'none'",
")",
"{",
"DB",
"::",
"table",
"(",
"'message'",
")",
"->",
"insert",
"(",
"[",
"'sender'",
"=>",
"$",
"username",
",",
"'ip_address'",
"=>",
"$",
"request",
"->",
"getClientIp",
"(",
")",
",",
"'user_id'",
"=>",
"$",
"webmaster",
"->",
"id",
"(",
")",
",",
"'subject'",
"=>",
"$",
"subject",
",",
"'body'",
"=>",
"view",
"(",
"'emails/verify-notify-text'",
",",
"[",
"'user'",
"=>",
"$",
"user",
"]",
")",
",",
"]",
")",
";",
"}",
"I18N",
"::",
"init",
"(",
"WT_LOCALE",
")",
";",
"}",
"$",
"user",
"->",
"setPreference",
"(",
"'verified'",
",",
"'1'",
")",
"->",
"setPreference",
"(",
"'reg_timestamp'",
",",
"date",
"(",
"'U'",
")",
")",
"->",
"setPreference",
"(",
"'reg_hashcode'",
",",
"''",
")",
";",
"Log",
"::",
"addAuthenticationLog",
"(",
"'User '",
".",
"$",
"username",
".",
"' verified their email address'",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'verify-success-page'",
",",
"[",
"'title'",
"=>",
"$",
"title",
",",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'verify-failure-page'",
",",
"[",
"'title'",
"=>",
"$",
"title",
",",
"]",
")",
";",
"}"
] | Respond to a verification link that was emailed to a user.
@param ServerRequestInterface $request
@param Tree $tree
@param UserService $user_service
@return ResponseInterface | [
"Respond",
"to",
"a",
"verification",
"link",
"that",
"was",
"emailed",
"to",
"a",
"user",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Auth/VerifyEmailController.php#L46-L103 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ImportThumbnailsController.php | ImportThumbnailsController.findMediaObjectsForMediaFile | private function findMediaObjectsForMediaFile(string $file): array
{
return DB::table('media')
->join('media_file', static function (JoinClause $join): void {
$join
->on('media_file.m_file', '=', 'media.m_file')
->on('media_file.m_id', '=', 'media.m_id');
})
->join('gedcom_setting', 'media.m_file', '=', 'gedcom_setting.gedcom_id')
->where(DB::raw('setting_value || multimedia_file_refn'), '=', $file)
->select(['media.*'])
->distinct()
->get()
->map(Media::rowMapper())
->all();
} | php | private function findMediaObjectsForMediaFile(string $file): array
{
return DB::table('media')
->join('media_file', static function (JoinClause $join): void {
$join
->on('media_file.m_file', '=', 'media.m_file')
->on('media_file.m_id', '=', 'media.m_id');
})
->join('gedcom_setting', 'media.m_file', '=', 'gedcom_setting.gedcom_id')
->where(DB::raw('setting_value || multimedia_file_refn'), '=', $file)
->select(['media.*'])
->distinct()
->get()
->map(Media::rowMapper())
->all();
} | [
"private",
"function",
"findMediaObjectsForMediaFile",
"(",
"string",
"$",
"file",
")",
":",
"array",
"{",
"return",
"DB",
"::",
"table",
"(",
"'media'",
")",
"->",
"join",
"(",
"'media_file'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'media_file.m_file'",
",",
"'='",
",",
"'media.m_file'",
")",
"->",
"on",
"(",
"'media_file.m_id'",
",",
"'='",
",",
"'media.m_id'",
")",
";",
"}",
")",
"->",
"join",
"(",
"'gedcom_setting'",
",",
"'media.m_file'",
",",
"'='",
",",
"'gedcom_setting.gedcom_id'",
")",
"->",
"where",
"(",
"DB",
"::",
"raw",
"(",
"'setting_value || multimedia_file_refn'",
")",
",",
"'='",
",",
"$",
"file",
")",
"->",
"select",
"(",
"[",
"'media.*'",
"]",
")",
"->",
"distinct",
"(",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"Media",
"::",
"rowMapper",
"(",
")",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Find the media object that uses a particular media file.
@param string $file
@return Media[] | [
"Find",
"the",
"media",
"object",
"that",
"uses",
"a",
"particular",
"media",
"file",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ImportThumbnailsController.php#L232-L247 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ImportThumbnailsController.php | ImportThumbnailsController.scaledImagePixels | private function scaledImagePixels($path): array
{
$size = 10;
$sha1 = sha1_file($path);
$cache_file = WT_DATA_DIR . 'cache/' . $sha1 . '.php';
if (file_exists($cache_file)) {
return include $cache_file;
}
$manager = new ImageManager();
$image = $manager->make($path)->resize($size, $size);
$pixels = [];
for ($x = 0; $x < $size; ++$x) {
$pixels[$x] = [];
for ($y = 0; $y < $size; ++$y) {
$pixel = $image->pickColor($x, $y);
$pixels[$x][$y] = (int) (($pixel[0] + $pixel[1] + $pixel[2]) / 3);
}
}
file_put_contents($cache_file, '<?php return ' . var_export($pixels, true) . ';');
return $pixels;
} | php | private function scaledImagePixels($path): array
{
$size = 10;
$sha1 = sha1_file($path);
$cache_file = WT_DATA_DIR . 'cache/' . $sha1 . '.php';
if (file_exists($cache_file)) {
return include $cache_file;
}
$manager = new ImageManager();
$image = $manager->make($path)->resize($size, $size);
$pixels = [];
for ($x = 0; $x < $size; ++$x) {
$pixels[$x] = [];
for ($y = 0; $y < $size; ++$y) {
$pixel = $image->pickColor($x, $y);
$pixels[$x][$y] = (int) (($pixel[0] + $pixel[1] + $pixel[2]) / 3);
}
}
file_put_contents($cache_file, '<?php return ' . var_export($pixels, true) . ';');
return $pixels;
} | [
"private",
"function",
"scaledImagePixels",
"(",
"$",
"path",
")",
":",
"array",
"{",
"$",
"size",
"=",
"10",
";",
"$",
"sha1",
"=",
"sha1_file",
"(",
"$",
"path",
")",
";",
"$",
"cache_file",
"=",
"WT_DATA_DIR",
".",
"'cache/'",
".",
"$",
"sha1",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cache_file",
")",
")",
"{",
"return",
"include",
"$",
"cache_file",
";",
"}",
"$",
"manager",
"=",
"new",
"ImageManager",
"(",
")",
";",
"$",
"image",
"=",
"$",
"manager",
"->",
"make",
"(",
"$",
"path",
")",
"->",
"resize",
"(",
"$",
"size",
",",
"$",
"size",
")",
";",
"$",
"pixels",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"size",
";",
"++",
"$",
"x",
")",
"{",
"$",
"pixels",
"[",
"$",
"x",
"]",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"y",
"=",
"0",
";",
"$",
"y",
"<",
"$",
"size",
";",
"++",
"$",
"y",
")",
"{",
"$",
"pixel",
"=",
"$",
"image",
"->",
"pickColor",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"pixels",
"[",
"$",
"x",
"]",
"[",
"$",
"y",
"]",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"pixel",
"[",
"0",
"]",
"+",
"$",
"pixel",
"[",
"1",
"]",
"+",
"$",
"pixel",
"[",
"2",
"]",
")",
"/",
"3",
")",
";",
"}",
"}",
"file_put_contents",
"(",
"$",
"cache_file",
",",
"'<?php return '",
".",
"var_export",
"(",
"$",
"pixels",
",",
"true",
")",
".",
"';'",
")",
";",
"return",
"$",
"pixels",
";",
"}"
] | Scale an image to 10x10 and read the individual pixels.
This is a slow operation, add we will do it many times on
the "import wetbrees 1 thumbnails" page so cache the results.
@param string $path
@return int[][] | [
"Scale",
"an",
"image",
"to",
"10x10",
"and",
"read",
"the",
"individual",
"pixels",
".",
"This",
"is",
"a",
"slow",
"operation",
"add",
"we",
"will",
"do",
"it",
"many",
"times",
"on",
"the",
"import",
"wetbrees",
"1",
"thumbnails",
"page",
"so",
"cache",
"the",
"results",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ImportThumbnailsController.php#L304-L329 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.header | public function header()
{
foreach ($this->headerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
foreach ($this->pageHeaderElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | php | public function header()
{
foreach ($this->headerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
foreach ($this->pageHeaderElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | [
"public",
"function",
"header",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headerElements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ReportBaseElement",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'footnotetexts'",
")",
"{",
"$",
"this",
"->",
"footnotes",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'addpage'",
")",
"{",
"$",
"this",
"->",
"newPage",
"(",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"pageHeaderElements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ReportBaseElement",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'footnotetexts'",
")",
"{",
"$",
"this",
"->",
"footnotes",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'addpage'",
")",
"{",
"$",
"this",
"->",
"newPage",
"(",
")",
";",
"}",
"}",
"}"
] | PDF Header -PDF
@return void | [
"PDF",
"Header",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L64-L85 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.body | public function body()
{
$this->AddPage();
foreach ($this->bodyElements as $key => $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | php | public function body()
{
$this->AddPage();
foreach ($this->bodyElements as $key => $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | [
"public",
"function",
"body",
"(",
")",
"{",
"$",
"this",
"->",
"AddPage",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"bodyElements",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ReportBaseElement",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'footnotetexts'",
")",
"{",
"$",
"this",
"->",
"footnotes",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'addpage'",
")",
"{",
"$",
"this",
"->",
"newPage",
"(",
")",
";",
"}",
"}",
"}"
] | PDF Body -PDF
@return void | [
"PDF",
"Body",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L92-L105 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.footnotes | public function footnotes()
{
foreach ($this->printedfootnotes as $element) {
if (($this->GetY() + $element->getFootnoteHeight($this)) > $this->getPageHeight()) {
$this->AddPage();
}
$element->renderFootnote($this);
if ($this->GetY() > $this->getPageHeight()) {
$this->AddPage();
}
}
} | php | public function footnotes()
{
foreach ($this->printedfootnotes as $element) {
if (($this->GetY() + $element->getFootnoteHeight($this)) > $this->getPageHeight()) {
$this->AddPage();
}
$element->renderFootnote($this);
if ($this->GetY() > $this->getPageHeight()) {
$this->AddPage();
}
}
} | [
"public",
"function",
"footnotes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"printedfootnotes",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"GetY",
"(",
")",
"+",
"$",
"element",
"->",
"getFootnoteHeight",
"(",
"$",
"this",
")",
")",
">",
"$",
"this",
"->",
"getPageHeight",
"(",
")",
")",
"{",
"$",
"this",
"->",
"AddPage",
"(",
")",
";",
"}",
"$",
"element",
"->",
"renderFootnote",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"GetY",
"(",
")",
">",
"$",
"this",
"->",
"getPageHeight",
"(",
")",
")",
"{",
"$",
"this",
"->",
"AddPage",
"(",
")",
";",
"}",
"}",
"}"
] | PDF Footnotes -PDF
@return void | [
"PDF",
"Footnotes",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L112-L125 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.footer | public function footer()
{
foreach ($this->footerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | php | public function footer()
{
foreach ($this->footerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->newPage();
}
}
} | [
"public",
"function",
"footer",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"footerElements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ReportBaseElement",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'footnotetexts'",
")",
"{",
"$",
"this",
"->",
"footnotes",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'addpage'",
")",
"{",
"$",
"this",
"->",
"newPage",
"(",
")",
";",
"}",
"}",
"}"
] | PDF Footer -PDF
@return void | [
"PDF",
"Footer",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L132-L143 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.setCurrentStyle | public function setCurrentStyle(string $s)
{
$this->currentStyle = $s;
$style = $this->wt_report->getStyle($s);
$this->SetFont($style['font'], $style['style'], $style['size']);
} | php | public function setCurrentStyle(string $s)
{
$this->currentStyle = $s;
$style = $this->wt_report->getStyle($s);
$this->SetFont($style['font'], $style['style'], $style['size']);
} | [
"public",
"function",
"setCurrentStyle",
"(",
"string",
"$",
"s",
")",
"{",
"$",
"this",
"->",
"currentStyle",
"=",
"$",
"s",
";",
"$",
"style",
"=",
"$",
"this",
"->",
"wt_report",
"->",
"getStyle",
"(",
"$",
"s",
")",
";",
"$",
"this",
"->",
"SetFont",
"(",
"$",
"style",
"[",
"'font'",
"]",
",",
"$",
"style",
"[",
"'style'",
"]",
",",
"$",
"style",
"[",
"'size'",
"]",
")",
";",
"}"
] | Setup a style for usage -PDF
@param string $s Style name
@return void | [
"Setup",
"a",
"style",
"for",
"usage",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L292-L297 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.getStyle | public function getStyle(string $s): array
{
if (!isset($this->wt_report->styles[$s])) {
$s = $this->getCurrentStyle();
$this->wt_report->styles[$s] = $s;
}
return $this->wt_report->styles[$s];
} | php | public function getStyle(string $s): array
{
if (!isset($this->wt_report->styles[$s])) {
$s = $this->getCurrentStyle();
$this->wt_report->styles[$s] = $s;
}
return $this->wt_report->styles[$s];
} | [
"public",
"function",
"getStyle",
"(",
"string",
"$",
"s",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"wt_report",
"->",
"styles",
"[",
"$",
"s",
"]",
")",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"getCurrentStyle",
"(",
")",
";",
"$",
"this",
"->",
"wt_report",
"->",
"styles",
"[",
"$",
"s",
"]",
"=",
"$",
"s",
";",
"}",
"return",
"$",
"this",
"->",
"wt_report",
"->",
"styles",
"[",
"$",
"s",
"]",
";",
"}"
] | Get the style -PDF
@param string $s Style name
@return array | [
"Get",
"the",
"style",
"-",
"PDF"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L306-L314 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.addMarginX | public function addMarginX(float $x): float
{
$m = $this->getMargins();
if ($this->getRTL()) {
$x += $m['right'];
} else {
$x += $m['left'];
}
$this->SetX($x);
return $x;
} | php | public function addMarginX(float $x): float
{
$m = $this->getMargins();
if ($this->getRTL()) {
$x += $m['right'];
} else {
$x += $m['left'];
}
$this->SetX($x);
return $x;
} | [
"public",
"function",
"addMarginX",
"(",
"float",
"$",
"x",
")",
":",
"float",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getMargins",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getRTL",
"(",
")",
")",
"{",
"$",
"x",
"+=",
"$",
"m",
"[",
"'right'",
"]",
";",
"}",
"else",
"{",
"$",
"x",
"+=",
"$",
"m",
"[",
"'left'",
"]",
";",
"}",
"$",
"this",
"->",
"SetX",
"(",
"$",
"x",
")",
";",
"return",
"$",
"x",
";",
"}"
] | Add margin when static horizontal position is used -PDF
RTL supported
@param float $x Static position
@return float | [
"Add",
"margin",
"when",
"static",
"horizontal",
"position",
"is",
"used",
"-",
"PDF",
"RTL",
"supported"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L324-L335 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.getMaxLineWidth | public function getMaxLineWidth()
{
$m = $this->getMargins();
if ($this->getRTL()) {
return ($this->getRemainingWidth() + $m['right']);
}
return ($this->getRemainingWidth() + $m['left']);
} | php | public function getMaxLineWidth()
{
$m = $this->getMargins();
if ($this->getRTL()) {
return ($this->getRemainingWidth() + $m['right']);
}
return ($this->getRemainingWidth() + $m['left']);
} | [
"public",
"function",
"getMaxLineWidth",
"(",
")",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"getMargins",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getRTL",
"(",
")",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"getRemainingWidth",
"(",
")",
"+",
"$",
"m",
"[",
"'right'",
"]",
")",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"getRemainingWidth",
"(",
")",
"+",
"$",
"m",
"[",
"'left'",
"]",
")",
";",
"}"
] | Get the maximum line width to draw from the curren position -PDF
RTL supported
@return float | [
"Get",
"the",
"maximum",
"line",
"width",
"to",
"draw",
"from",
"the",
"curren",
"position",
"-",
"PDF",
"RTL",
"supported"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L343-L351 | train |
fisharebest/webtrees | app/Report/ReportTcpdf.php | ReportTcpdf.getFootnotesHeight | public function getFootnotesHeight(): float
{
$h = 0;
foreach ($this->printedfootnotes as $element) {
$h += $element->getHeight($this);
}
return $h;
} | php | public function getFootnotesHeight(): float
{
$h = 0;
foreach ($this->printedfootnotes as $element) {
$h += $element->getHeight($this);
}
return $h;
} | [
"public",
"function",
"getFootnotesHeight",
"(",
")",
":",
"float",
"{",
"$",
"h",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"printedfootnotes",
"as",
"$",
"element",
")",
"{",
"$",
"h",
"+=",
"$",
"element",
"->",
"getHeight",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"h",
";",
"}"
] | Get the height of the footnote.
@return float | [
"Get",
"the",
"height",
"of",
"the",
"footnote",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportTcpdf.php#L358-L366 | train |
fisharebest/webtrees | app/Date/JulianDate.php | JulianDate.formatLongYear | protected function formatLongYear(): string
{
if ($this->year < 0) {
return /* I18N: BCE=Before the Common Era, for Julian years < 0. See http://en.wikipedia.org/wiki/Common_Era */
I18N::translate('%s BCE', I18N::digits(-$this->year));
}
if ($this->new_old_style) {
return I18N::translate('%s CE', I18N::digits(sprintf('%d/%02d', $this->year - 1, $this->year % 100)));
}
/* I18N: CE=Common Era, for Julian years > 0. See http://en.wikipedia.org/wiki/Common_Era */
return I18N::translate('%s CE', I18N::digits($this->year));
} | php | protected function formatLongYear(): string
{
if ($this->year < 0) {
return /* I18N: BCE=Before the Common Era, for Julian years < 0. See http://en.wikipedia.org/wiki/Common_Era */
I18N::translate('%s BCE', I18N::digits(-$this->year));
}
if ($this->new_old_style) {
return I18N::translate('%s CE', I18N::digits(sprintf('%d/%02d', $this->year - 1, $this->year % 100)));
}
/* I18N: CE=Common Era, for Julian years > 0. See http://en.wikipedia.org/wiki/Common_Era */
return I18N::translate('%s CE', I18N::digits($this->year));
} | [
"protected",
"function",
"formatLongYear",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"year",
"<",
"0",
")",
"{",
"return",
"/* I18N: BCE=Before the Common Era, for Julian years < 0. See http://en.wikipedia.org/wiki/Common_Era */",
"I18N",
"::",
"translate",
"(",
"'%s BCE'",
",",
"I18N",
"::",
"digits",
"(",
"-",
"$",
"this",
"->",
"year",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"new_old_style",
")",
"{",
"return",
"I18N",
"::",
"translate",
"(",
"'%s CE'",
",",
"I18N",
"::",
"digits",
"(",
"sprintf",
"(",
"'%d/%02d'",
",",
"$",
"this",
"->",
"year",
"-",
"1",
",",
"$",
"this",
"->",
"year",
"%",
"100",
")",
")",
")",
";",
"}",
"/* I18N: CE=Common Era, for Julian years > 0. See http://en.wikipedia.org/wiki/Common_Era */",
"return",
"I18N",
"::",
"translate",
"(",
"'%s CE'",
",",
"I18N",
"::",
"digits",
"(",
"$",
"this",
"->",
"year",
")",
")",
";",
"}"
] | Generate the %Y format for a date.
@return string | [
"Generate",
"the",
"%Y",
"format",
"for",
"a",
"date",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date/JulianDate.php#L92-L105 | train |
fisharebest/webtrees | app/Date/JulianDate.php | JulianDate.formatGedcomYear | protected function formatGedcomYear(): string
{
if ($this->year < 0) {
return sprintf('%04d B.C.', -$this->year);
}
if ($this->new_old_style) {
return sprintf('%04d/%02d', $this->year - 1, $this->year % 100);
}
return sprintf('%04d', $this->year);
} | php | protected function formatGedcomYear(): string
{
if ($this->year < 0) {
return sprintf('%04d B.C.', -$this->year);
}
if ($this->new_old_style) {
return sprintf('%04d/%02d', $this->year - 1, $this->year % 100);
}
return sprintf('%04d', $this->year);
} | [
"protected",
"function",
"formatGedcomYear",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"year",
"<",
"0",
")",
"{",
"return",
"sprintf",
"(",
"'%04d B.C.'",
",",
"-",
"$",
"this",
"->",
"year",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"new_old_style",
")",
"{",
"return",
"sprintf",
"(",
"'%04d/%02d'",
",",
"$",
"this",
"->",
"year",
"-",
"1",
",",
"$",
"this",
"->",
"year",
"%",
"100",
")",
";",
"}",
"return",
"sprintf",
"(",
"'%04d'",
",",
"$",
"this",
"->",
"year",
")",
";",
"}"
] | Generate the %E format for a date.
@return string | [
"Generate",
"the",
"%E",
"format",
"for",
"a",
"date",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date/JulianDate.php#L112-L123 | train |
fisharebest/webtrees | app/Http/Controllers/AutocompleteController.php | AutocompleteController.folder | public function folder(ServerRequestInterface $request, Tree $tree, Filesystem $filesystem): ResponseInterface
{
$query = $request->get('query', '');
$prefix = $tree->getPreference('MEDIA_DIRECTORY', '');
$media_filesystem = new Filesystem(new ChrootAdapter($filesystem, $prefix));
$contents = new Collection($media_filesystem->listContents('', true));
$folders = $contents
->filter(static function (array $object) use ($query): bool {
return $object['type'] === 'dir' && Str::contains($object['path'], $query);
})
->map(static function (array $object): array {
return ['value' => $object['path']];
});
return response($folders);
} | php | public function folder(ServerRequestInterface $request, Tree $tree, Filesystem $filesystem): ResponseInterface
{
$query = $request->get('query', '');
$prefix = $tree->getPreference('MEDIA_DIRECTORY', '');
$media_filesystem = new Filesystem(new ChrootAdapter($filesystem, $prefix));
$contents = new Collection($media_filesystem->listContents('', true));
$folders = $contents
->filter(static function (array $object) use ($query): bool {
return $object['type'] === 'dir' && Str::contains($object['path'], $query);
})
->map(static function (array $object): array {
return ['value' => $object['path']];
});
return response($folders);
} | [
"public",
"function",
"folder",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
",",
"Filesystem",
"$",
"filesystem",
")",
":",
"ResponseInterface",
"{",
"$",
"query",
"=",
"$",
"request",
"->",
"get",
"(",
"'query'",
",",
"''",
")",
";",
"$",
"prefix",
"=",
"$",
"tree",
"->",
"getPreference",
"(",
"'MEDIA_DIRECTORY'",
",",
"''",
")",
";",
"$",
"media_filesystem",
"=",
"new",
"Filesystem",
"(",
"new",
"ChrootAdapter",
"(",
"$",
"filesystem",
",",
"$",
"prefix",
")",
")",
";",
"$",
"contents",
"=",
"new",
"Collection",
"(",
"$",
"media_filesystem",
"->",
"listContents",
"(",
"''",
",",
"true",
")",
")",
";",
"$",
"folders",
"=",
"$",
"contents",
"->",
"filter",
"(",
"static",
"function",
"(",
"array",
"$",
"object",
")",
"use",
"(",
"$",
"query",
")",
":",
"bool",
"{",
"return",
"$",
"object",
"[",
"'type'",
"]",
"===",
"'dir'",
"&&",
"Str",
"::",
"contains",
"(",
"$",
"object",
"[",
"'path'",
"]",
",",
"$",
"query",
")",
";",
"}",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"array",
"$",
"object",
")",
":",
"array",
"{",
"return",
"[",
"'value'",
"=>",
"$",
"object",
"[",
"'path'",
"]",
"]",
";",
"}",
")",
";",
"return",
"response",
"(",
"$",
"folders",
")",
";",
"}"
] | Autocomplete for media folders.
@param ServerRequestInterface $request
@param Tree $tree
@param Filesystem $filesystem
@return ResponseInterface | [
"Autocomplete",
"for",
"media",
"folders",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AutocompleteController.php#L69-L88 | train |
fisharebest/webtrees | app/Http/Controllers/AutocompleteController.php | AutocompleteController.page | public function page(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$query = $request->get('query', '');
$xref = $request->get('extra', '');
$source = Source::getInstance($xref, $tree);
Auth::checkSourceAccess($source);
$regex_query = preg_quote(strtr($query, [' ' => '.+']), '/');
// Fetch all records with a link to this source
$individuals = DB::table('individuals')
->join('link', static function (JoinClause $join): void {
$join
->on('l_file', '=', 'i_file')
->on('l_from', '=', 'i_id');
})
->where('i_file', '=', $tree->id())
->where('l_to', '=', $xref)
->where('l_type', '=', 'SOUR')
->distinct()
->select(['individuals.*'])
->get()
->map(Individual::rowMapper())
->filter(GedcomRecord::accessFilter());
$families = DB::table('families')
->join('link', static function (JoinClause $join): void {
$join
->on('l_file', '=', 'f_file')
->on('l_from', '=', 'f_id')
->where('l_type', '=', 'SOUR');
})
->where('f_file', '=', $tree->id())
->where('l_to', '=', $xref)
->where('l_type', '=', 'SOUR')
->distinct()
->select(['families.*'])
->get()
->map(Family::rowMapper())
->filter(GedcomRecord::accessFilter());
$pages = [];
foreach ($individuals->merge($families) as $record) {
if (preg_match_all('/\n1 SOUR @' . $xref . '@(?:\n[2-9].*)*\n2 PAGE (.*' . $regex_query . '.*)/i', $record->gedcom(), $matches)) {
$pages = array_merge($pages, $matches[1]);
}
if (preg_match_all('/\n2 SOUR @' . $xref . '@(?:\n[3-9].*)*\n3 PAGE (.*' . $regex_query . '.*)/i', $record->gedcom(), $matches)) {
$pages = array_merge($pages, $matches[1]);
}
}
$pages = array_unique($pages);
$pages = array_map(static function (string $page): array {
return ['value' => $page];
}, $pages);
return response($pages);
} | php | public function page(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$query = $request->get('query', '');
$xref = $request->get('extra', '');
$source = Source::getInstance($xref, $tree);
Auth::checkSourceAccess($source);
$regex_query = preg_quote(strtr($query, [' ' => '.+']), '/');
// Fetch all records with a link to this source
$individuals = DB::table('individuals')
->join('link', static function (JoinClause $join): void {
$join
->on('l_file', '=', 'i_file')
->on('l_from', '=', 'i_id');
})
->where('i_file', '=', $tree->id())
->where('l_to', '=', $xref)
->where('l_type', '=', 'SOUR')
->distinct()
->select(['individuals.*'])
->get()
->map(Individual::rowMapper())
->filter(GedcomRecord::accessFilter());
$families = DB::table('families')
->join('link', static function (JoinClause $join): void {
$join
->on('l_file', '=', 'f_file')
->on('l_from', '=', 'f_id')
->where('l_type', '=', 'SOUR');
})
->where('f_file', '=', $tree->id())
->where('l_to', '=', $xref)
->where('l_type', '=', 'SOUR')
->distinct()
->select(['families.*'])
->get()
->map(Family::rowMapper())
->filter(GedcomRecord::accessFilter());
$pages = [];
foreach ($individuals->merge($families) as $record) {
if (preg_match_all('/\n1 SOUR @' . $xref . '@(?:\n[2-9].*)*\n2 PAGE (.*' . $regex_query . '.*)/i', $record->gedcom(), $matches)) {
$pages = array_merge($pages, $matches[1]);
}
if (preg_match_all('/\n2 SOUR @' . $xref . '@(?:\n[3-9].*)*\n3 PAGE (.*' . $regex_query . '.*)/i', $record->gedcom(), $matches)) {
$pages = array_merge($pages, $matches[1]);
}
}
$pages = array_unique($pages);
$pages = array_map(static function (string $page): array {
return ['value' => $page];
}, $pages);
return response($pages);
} | [
"public",
"function",
"page",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
")",
":",
"ResponseInterface",
"{",
"$",
"query",
"=",
"$",
"request",
"->",
"get",
"(",
"'query'",
",",
"''",
")",
";",
"$",
"xref",
"=",
"$",
"request",
"->",
"get",
"(",
"'extra'",
",",
"''",
")",
";",
"$",
"source",
"=",
"Source",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"Auth",
"::",
"checkSourceAccess",
"(",
"$",
"source",
")",
";",
"$",
"regex_query",
"=",
"preg_quote",
"(",
"strtr",
"(",
"$",
"query",
",",
"[",
"' '",
"=>",
"'.+'",
"]",
")",
",",
"'/'",
")",
";",
"// Fetch all records with a link to this source",
"$",
"individuals",
"=",
"DB",
"::",
"table",
"(",
"'individuals'",
")",
"->",
"join",
"(",
"'link'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l_file'",
",",
"'='",
",",
"'i_file'",
")",
"->",
"on",
"(",
"'l_from'",
",",
"'='",
",",
"'i_id'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'i_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'l_to'",
",",
"'='",
",",
"$",
"xref",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"'SOUR'",
")",
"->",
"distinct",
"(",
")",
"->",
"select",
"(",
"[",
"'individuals.*'",
"]",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"Individual",
"::",
"rowMapper",
"(",
")",
")",
"->",
"filter",
"(",
"GedcomRecord",
"::",
"accessFilter",
"(",
")",
")",
";",
"$",
"families",
"=",
"DB",
"::",
"table",
"(",
"'families'",
")",
"->",
"join",
"(",
"'link'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l_file'",
",",
"'='",
",",
"'f_file'",
")",
"->",
"on",
"(",
"'l_from'",
",",
"'='",
",",
"'f_id'",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"'SOUR'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'f_file'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'l_to'",
",",
"'='",
",",
"$",
"xref",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"'SOUR'",
")",
"->",
"distinct",
"(",
")",
"->",
"select",
"(",
"[",
"'families.*'",
"]",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"Family",
"::",
"rowMapper",
"(",
")",
")",
"->",
"filter",
"(",
"GedcomRecord",
"::",
"accessFilter",
"(",
")",
")",
";",
"$",
"pages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"individuals",
"->",
"merge",
"(",
"$",
"families",
")",
"as",
"$",
"record",
")",
"{",
"if",
"(",
"preg_match_all",
"(",
"'/\\n1 SOUR @'",
".",
"$",
"xref",
".",
"'@(?:\\n[2-9].*)*\\n2 PAGE (.*'",
".",
"$",
"regex_query",
".",
"'.*)/i'",
",",
"$",
"record",
"->",
"gedcom",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"pages",
"=",
"array_merge",
"(",
"$",
"pages",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"preg_match_all",
"(",
"'/\\n2 SOUR @'",
".",
"$",
"xref",
".",
"'@(?:\\n[3-9].*)*\\n3 PAGE (.*'",
".",
"$",
"regex_query",
".",
"'.*)/i'",
",",
"$",
"record",
"->",
"gedcom",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"pages",
"=",
"array_merge",
"(",
"$",
"pages",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"}",
"$",
"pages",
"=",
"array_unique",
"(",
"$",
"pages",
")",
";",
"$",
"pages",
"=",
"array_map",
"(",
"static",
"function",
"(",
"string",
"$",
"page",
")",
":",
"array",
"{",
"return",
"[",
"'value'",
"=>",
"$",
"page",
"]",
";",
"}",
",",
"$",
"pages",
")",
";",
"return",
"response",
"(",
"$",
"pages",
")",
";",
"}"
] | Autocomplete for source citations.
@param ServerRequestInterface $request
@param Tree $tree
@return ResponseInterface | [
"Autocomplete",
"for",
"source",
"citations",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AutocompleteController.php#L98-L160 | train |
fisharebest/webtrees | app/Http/Controllers/AutocompleteController.php | AutocompleteController.placeSearch | private function placeSearch(Tree $tree, int $page, string $query, bool $create): array
{
$offset = $page * self::RESULTS_PER_PAGE;
$results = [];
$found = false;
foreach ($this->search_service->searchPlaces($tree, $query) as $place) {
$place_name = $place->gedcomName();
if ($place_name === $query) {
$found = true;
}
$results[] = [
'id' => $place_name,
'text' => $place_name,
'title' => ' ',
];
}
// No place found? Use an external gazetteer
if (empty($results) && $tree->getPreference('GEONAMES_ACCOUNT')) {
$url =
'http://api.geonames.org/searchJSON' .
'?name_startsWith=' . urlencode($query) .
'&lang=' . WT_LOCALE .
'&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC' .
'&style=full' .
'&username=' . $tree->getPreference('GEONAMES_ACCOUNT');
// try to use curl when file_get_contents not allowed
if (ini_get('allow_url_fopen')) {
$json = file_get_contents($url);
$places = json_decode($json, true);
} elseif (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json = curl_exec($ch);
$places = json_decode($json, true);
curl_close($ch);
} else {
$places = [];
}
if (isset($places['geonames']) && is_array($places['geonames'])) {
foreach ($places['geonames'] as $k => $place) {
$place_name = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
if ($place_name === $query) {
$found = true;
}
$results[] = [
'id' => $place_name,
'text' => $place_name,
'title' => ' ',
];
}
}
}
// Include the query term in the results. This allows the user to select a
// place that doesn't already exist in the database.
if (!$found && $create) {
array_unshift($results, [
'id' => $query,
'text' => $query,
]);
}
$more = count($results) > $offset + self::RESULTS_PER_PAGE;
$results = array_slice($results, $offset, self::RESULTS_PER_PAGE);
return [
'results' => $results,
'pagination' => [
'more' => $more,
],
];
} | php | private function placeSearch(Tree $tree, int $page, string $query, bool $create): array
{
$offset = $page * self::RESULTS_PER_PAGE;
$results = [];
$found = false;
foreach ($this->search_service->searchPlaces($tree, $query) as $place) {
$place_name = $place->gedcomName();
if ($place_name === $query) {
$found = true;
}
$results[] = [
'id' => $place_name,
'text' => $place_name,
'title' => ' ',
];
}
// No place found? Use an external gazetteer
if (empty($results) && $tree->getPreference('GEONAMES_ACCOUNT')) {
$url =
'http://api.geonames.org/searchJSON' .
'?name_startsWith=' . urlencode($query) .
'&lang=' . WT_LOCALE .
'&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC' .
'&style=full' .
'&username=' . $tree->getPreference('GEONAMES_ACCOUNT');
// try to use curl when file_get_contents not allowed
if (ini_get('allow_url_fopen')) {
$json = file_get_contents($url);
$places = json_decode($json, true);
} elseif (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$json = curl_exec($ch);
$places = json_decode($json, true);
curl_close($ch);
} else {
$places = [];
}
if (isset($places['geonames']) && is_array($places['geonames'])) {
foreach ($places['geonames'] as $k => $place) {
$place_name = $place['name'] . ', ' . $place['adminName2'] . ', ' . $place['adminName1'] . ', ' . $place['countryName'];
if ($place_name === $query) {
$found = true;
}
$results[] = [
'id' => $place_name,
'text' => $place_name,
'title' => ' ',
];
}
}
}
// Include the query term in the results. This allows the user to select a
// place that doesn't already exist in the database.
if (!$found && $create) {
array_unshift($results, [
'id' => $query,
'text' => $query,
]);
}
$more = count($results) > $offset + self::RESULTS_PER_PAGE;
$results = array_slice($results, $offset, self::RESULTS_PER_PAGE);
return [
'results' => $results,
'pagination' => [
'more' => $more,
],
];
} | [
"private",
"function",
"placeSearch",
"(",
"Tree",
"$",
"tree",
",",
"int",
"$",
"page",
",",
"string",
"$",
"query",
",",
"bool",
"$",
"create",
")",
":",
"array",
"{",
"$",
"offset",
"=",
"$",
"page",
"*",
"self",
"::",
"RESULTS_PER_PAGE",
";",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"found",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"search_service",
"->",
"searchPlaces",
"(",
"$",
"tree",
",",
"$",
"query",
")",
"as",
"$",
"place",
")",
"{",
"$",
"place_name",
"=",
"$",
"place",
"->",
"gedcomName",
"(",
")",
";",
"if",
"(",
"$",
"place_name",
"===",
"$",
"query",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"$",
"results",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"place_name",
",",
"'text'",
"=>",
"$",
"place_name",
",",
"'title'",
"=>",
"' '",
",",
"]",
";",
"}",
"// No place found? Use an external gazetteer",
"if",
"(",
"empty",
"(",
"$",
"results",
")",
"&&",
"$",
"tree",
"->",
"getPreference",
"(",
"'GEONAMES_ACCOUNT'",
")",
")",
"{",
"$",
"url",
"=",
"'http://api.geonames.org/searchJSON'",
".",
"'?name_startsWith='",
".",
"urlencode",
"(",
"$",
"query",
")",
".",
"'&lang='",
".",
"WT_LOCALE",
".",
"'&fcode=CMTY&fcode=ADM4&fcode=PPL&fcode=PPLA&fcode=PPLC'",
".",
"'&style=full'",
".",
"'&username='",
".",
"$",
"tree",
"->",
"getPreference",
"(",
"'GEONAMES_ACCOUNT'",
")",
";",
"// try to use curl when file_get_contents not allowed",
"if",
"(",
"ini_get",
"(",
"'allow_url_fopen'",
")",
")",
"{",
"$",
"json",
"=",
"file_get_contents",
"(",
"$",
"url",
")",
";",
"$",
"places",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'curl_init'",
")",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"$",
"json",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"places",
"=",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"}",
"else",
"{",
"$",
"places",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"places",
"[",
"'geonames'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"places",
"[",
"'geonames'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"places",
"[",
"'geonames'",
"]",
"as",
"$",
"k",
"=>",
"$",
"place",
")",
"{",
"$",
"place_name",
"=",
"$",
"place",
"[",
"'name'",
"]",
".",
"', '",
".",
"$",
"place",
"[",
"'adminName2'",
"]",
".",
"', '",
".",
"$",
"place",
"[",
"'adminName1'",
"]",
".",
"', '",
".",
"$",
"place",
"[",
"'countryName'",
"]",
";",
"if",
"(",
"$",
"place_name",
"===",
"$",
"query",
")",
"{",
"$",
"found",
"=",
"true",
";",
"}",
"$",
"results",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"place_name",
",",
"'text'",
"=>",
"$",
"place_name",
",",
"'title'",
"=>",
"' '",
",",
"]",
";",
"}",
"}",
"}",
"// Include the query term in the results. This allows the user to select a",
"// place that doesn't already exist in the database.",
"if",
"(",
"!",
"$",
"found",
"&&",
"$",
"create",
")",
"{",
"array_unshift",
"(",
"$",
"results",
",",
"[",
"'id'",
"=>",
"$",
"query",
",",
"'text'",
"=>",
"$",
"query",
",",
"]",
")",
";",
"}",
"$",
"more",
"=",
"count",
"(",
"$",
"results",
")",
">",
"$",
"offset",
"+",
"self",
"::",
"RESULTS_PER_PAGE",
";",
"$",
"results",
"=",
"array_slice",
"(",
"$",
"results",
",",
"$",
"offset",
",",
"self",
"::",
"RESULTS_PER_PAGE",
")",
";",
"return",
"[",
"'results'",
"=>",
"$",
"results",
",",
"'pagination'",
"=>",
"[",
"'more'",
"=>",
"$",
"more",
",",
"]",
",",
"]",
";",
"}"
] | Look up a place name.
@param Tree $tree Search this tree.
@param int $page Skip this number of pages. Starts with zero.
@param string $query Search terms.
@param bool $create if true, include the query in the results so it can be created.
@return mixed[] | [
"Look",
"up",
"a",
"place",
"name",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AutocompleteController.php#L370-L444 | train |
fisharebest/webtrees | app/Module/IndividualMetadataModule.php | IndividualMetadataModule.getSidebarContent | public function getSidebarContent(Individual $individual): string
{
ob_start();
foreach ($individual->facts(static::HANDLED_FACTS) as $fact) {
FunctionsPrintFacts::printFact($fact, $individual);
}
$html = ob_get_clean();
return strip_tags($html, '<a><div><span>');
} | php | public function getSidebarContent(Individual $individual): string
{
ob_start();
foreach ($individual->facts(static::HANDLED_FACTS) as $fact) {
FunctionsPrintFacts::printFact($fact, $individual);
}
$html = ob_get_clean();
return strip_tags($html, '<a><div><span>');
} | [
"public",
"function",
"getSidebarContent",
"(",
"Individual",
"$",
"individual",
")",
":",
"string",
"{",
"ob_start",
"(",
")",
";",
"foreach",
"(",
"$",
"individual",
"->",
"facts",
"(",
"static",
"::",
"HANDLED_FACTS",
")",
"as",
"$",
"fact",
")",
"{",
"FunctionsPrintFacts",
"::",
"printFact",
"(",
"$",
"fact",
",",
"$",
"individual",
")",
";",
"}",
"$",
"html",
"=",
"ob_get_clean",
"(",
")",
";",
"return",
"strip_tags",
"(",
"$",
"html",
",",
"'<a><div><span>'",
")",
";",
"}"
] | Load this sidebar synchronously.
@param Individual $individual
@return string | [
"Load",
"this",
"sidebar",
"synchronously",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/IndividualMetadataModule.php#L91-L102 | train |
fisharebest/webtrees | app/Module/BatchUpdate/BatchUpdateMarriedNamesPlugin.php | BatchUpdateMarriedNamesPlugin.surnamesToAdd | private function surnamesToAdd(GedcomRecord $record): array
{
$gedcom = $record->gedcom();
$tree = $record->tree();
$wife_surnames = $this->surnames($record);
$husb_surnames = [];
$missing_surnames = [];
preg_match_all('/^1 FAMS @(.+)@/m', $gedcom, $fmatch);
foreach ($fmatch[1] as $famid) {
$family = Family::getInstance($famid, $tree);
$famrec = $family->gedcom();
if (preg_match('/^1 MARR/m', $famrec) && preg_match('/^1 HUSB @(.+)@/m', $famrec, $hmatch)) {
$spouse = Individual::getInstance($hmatch[1], $tree);
if ($spouse instanceof Individual) {
$husb_surnames = array_unique(array_merge($husb_surnames, $this->surnames($spouse)));
}
}
}
foreach ($husb_surnames as $husb_surname) {
if (!in_array($husb_surname, $wife_surnames, true)) {
$missing_surnames[] = $husb_surname;
}
}
return $missing_surnames;
} | php | private function surnamesToAdd(GedcomRecord $record): array
{
$gedcom = $record->gedcom();
$tree = $record->tree();
$wife_surnames = $this->surnames($record);
$husb_surnames = [];
$missing_surnames = [];
preg_match_all('/^1 FAMS @(.+)@/m', $gedcom, $fmatch);
foreach ($fmatch[1] as $famid) {
$family = Family::getInstance($famid, $tree);
$famrec = $family->gedcom();
if (preg_match('/^1 MARR/m', $famrec) && preg_match('/^1 HUSB @(.+)@/m', $famrec, $hmatch)) {
$spouse = Individual::getInstance($hmatch[1], $tree);
if ($spouse instanceof Individual) {
$husb_surnames = array_unique(array_merge($husb_surnames, $this->surnames($spouse)));
}
}
}
foreach ($husb_surnames as $husb_surname) {
if (!in_array($husb_surname, $wife_surnames, true)) {
$missing_surnames[] = $husb_surname;
}
}
return $missing_surnames;
} | [
"private",
"function",
"surnamesToAdd",
"(",
"GedcomRecord",
"$",
"record",
")",
":",
"array",
"{",
"$",
"gedcom",
"=",
"$",
"record",
"->",
"gedcom",
"(",
")",
";",
"$",
"tree",
"=",
"$",
"record",
"->",
"tree",
"(",
")",
";",
"$",
"wife_surnames",
"=",
"$",
"this",
"->",
"surnames",
"(",
"$",
"record",
")",
";",
"$",
"husb_surnames",
"=",
"[",
"]",
";",
"$",
"missing_surnames",
"=",
"[",
"]",
";",
"preg_match_all",
"(",
"'/^1 FAMS @(.+)@/m'",
",",
"$",
"gedcom",
",",
"$",
"fmatch",
")",
";",
"foreach",
"(",
"$",
"fmatch",
"[",
"1",
"]",
"as",
"$",
"famid",
")",
"{",
"$",
"family",
"=",
"Family",
"::",
"getInstance",
"(",
"$",
"famid",
",",
"$",
"tree",
")",
";",
"$",
"famrec",
"=",
"$",
"family",
"->",
"gedcom",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^1 MARR/m'",
",",
"$",
"famrec",
")",
"&&",
"preg_match",
"(",
"'/^1 HUSB @(.+)@/m'",
",",
"$",
"famrec",
",",
"$",
"hmatch",
")",
")",
"{",
"$",
"spouse",
"=",
"Individual",
"::",
"getInstance",
"(",
"$",
"hmatch",
"[",
"1",
"]",
",",
"$",
"tree",
")",
";",
"if",
"(",
"$",
"spouse",
"instanceof",
"Individual",
")",
"{",
"$",
"husb_surnames",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"husb_surnames",
",",
"$",
"this",
"->",
"surnames",
"(",
"$",
"spouse",
")",
")",
")",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"husb_surnames",
"as",
"$",
"husb_surname",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"husb_surname",
",",
"$",
"wife_surnames",
",",
"true",
")",
")",
"{",
"$",
"missing_surnames",
"[",
"]",
"=",
"$",
"husb_surname",
";",
"}",
"}",
"return",
"$",
"missing_surnames",
";",
"}"
] | Generate a list of married surnames that are not already present.
@param GedcomRecord $record
@return string[] | [
"Generate",
"a",
"list",
"of",
"married",
"surnames",
"that",
"are",
"not",
"already",
"present",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdate/BatchUpdateMarriedNamesPlugin.php#L119-L150 | train |
fisharebest/webtrees | app/Module/BatchUpdate/BatchUpdateMarriedNamesPlugin.php | BatchUpdateMarriedNamesPlugin.surnames | private function surnames(GedcomRecord $record): array
{
$gedcom = $record->gedcom();
if (preg_match_all('/^(?:1 NAME|2 _MARNM) .*\/(.+)\//m', $gedcom, $match)) {
return $match[1];
}
return [];
} | php | private function surnames(GedcomRecord $record): array
{
$gedcom = $record->gedcom();
if (preg_match_all('/^(?:1 NAME|2 _MARNM) .*\/(.+)\//m', $gedcom, $match)) {
return $match[1];
}
return [];
} | [
"private",
"function",
"surnames",
"(",
"GedcomRecord",
"$",
"record",
")",
":",
"array",
"{",
"$",
"gedcom",
"=",
"$",
"record",
"->",
"gedcom",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/^(?:1 NAME|2 _MARNM) .*\\/(.+)\\//m'",
",",
"$",
"gedcom",
",",
"$",
"match",
")",
")",
"{",
"return",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Extract a list of surnames from a GEDCOM record.
@param GedcomRecord $record
@return string[] | [
"Extract",
"a",
"list",
"of",
"surnames",
"from",
"a",
"GEDCOM",
"record",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdate/BatchUpdateMarriedNamesPlugin.php#L159-L168 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.