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/GedcomTag.php | GedcomTag.getPicklistFacts | public static function getPicklistFacts($fact_type): array
{
switch ($fact_type) {
case 'INDI':
$tags = [
// Facts, attributes for individuals (no links to FAMs)
'RESN',
'NAME',
'SEX',
'BIRT',
'CHR',
'DEAT',
'BURI',
'CREM',
'ADOP',
'BAPM',
'BARM',
'BASM',
'BLES',
'CHRA',
'CONF',
'FCOM',
'ORDN',
'NATU',
'EMIG',
'IMMI',
'CENS',
'PROB',
'WILL',
'GRAD',
'RETI',
'EVEN',
'CAST',
'DSCR',
'EDUC',
'IDNO',
'NATI',
'NCHI',
'NMR',
'OCCU',
'PROP',
'RELI',
'RESI',
'SSN',
'TITL',
'FACT',
'BAPL',
'CONL',
'ENDL',
'SLGC',
'SUBM',
'ASSO',
'ALIA',
'ANCI',
'DESI',
'RFN',
'AFN',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'SOUR',
'OBJE',
// non standard tags
'_BRTM',
'_DEG',
'_DNA',
'_EYEC',
'_FNRL',
'_HAIR',
'_HEIG',
'_HNM',
'_HOL',
'_INTE',
'_MDCL',
'_MEDC',
'_MILI',
'_MILT',
'_NAME',
'_NAMS',
'_NLIV',
'_NMAR',
'_PRMN',
'_TODO',
'_UID',
'_WEIG',
'_YART',
];
break;
case 'FAM':
$tags = [
// Facts for families, left out HUSB, WIFE & CHIL links
'RESN',
'ANUL',
'CENS',
'DIV',
'DIVF',
'ENGA',
'MARB',
'MARC',
'MARR',
'MARL',
'MARS',
'RESI',
'EVEN',
'NCHI',
'SUBM',
'SLGS',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'SOUR',
'OBJE',
// non standard tags
'_NMR',
'MARR_CIVIL',
'MARR_RELIGIOUS',
'MARR_PARTNERS',
'MARR_UNKNOWN',
'_COML',
'_MBON',
'_MARI',
'_SEPR',
'_TODO',
];
break;
case 'SOUR':
$tags = [
// Facts for sources
'DATA',
'AUTH',
'TITL',
'ABBR',
'PUBL',
'TEXT',
'REPO',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'OBJE',
'RESN',
];
break;
case 'REPO':
$tags = [
// Facts for repositories
'NAME',
'ADDR',
'PHON',
'EMAIL',
'FAX',
'WWW',
'NOTE',
'SHARED_NOTE',
'REFN',
'RIN',
'CHAN',
'RESN',
];
break;
case 'PLAC':
$tags = [
// Facts for places
'FONE',
'ROMN',
// non standard tags
'_HEB',
];
break;
case 'NAME':
$tags = [
// Facts subordinate to NAME
'FONE',
'ROMN',
// non standard tags
'_HEB',
'_AKA',
'_MARNM',
];
break;
default:
$tags = [];
break;
}
$facts = [];
foreach ($tags as $tag) {
$facts[$tag] = self::getLabel($tag, null);
}
uasort($facts, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $facts;
} | php | public static function getPicklistFacts($fact_type): array
{
switch ($fact_type) {
case 'INDI':
$tags = [
// Facts, attributes for individuals (no links to FAMs)
'RESN',
'NAME',
'SEX',
'BIRT',
'CHR',
'DEAT',
'BURI',
'CREM',
'ADOP',
'BAPM',
'BARM',
'BASM',
'BLES',
'CHRA',
'CONF',
'FCOM',
'ORDN',
'NATU',
'EMIG',
'IMMI',
'CENS',
'PROB',
'WILL',
'GRAD',
'RETI',
'EVEN',
'CAST',
'DSCR',
'EDUC',
'IDNO',
'NATI',
'NCHI',
'NMR',
'OCCU',
'PROP',
'RELI',
'RESI',
'SSN',
'TITL',
'FACT',
'BAPL',
'CONL',
'ENDL',
'SLGC',
'SUBM',
'ASSO',
'ALIA',
'ANCI',
'DESI',
'RFN',
'AFN',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'SOUR',
'OBJE',
// non standard tags
'_BRTM',
'_DEG',
'_DNA',
'_EYEC',
'_FNRL',
'_HAIR',
'_HEIG',
'_HNM',
'_HOL',
'_INTE',
'_MDCL',
'_MEDC',
'_MILI',
'_MILT',
'_NAME',
'_NAMS',
'_NLIV',
'_NMAR',
'_PRMN',
'_TODO',
'_UID',
'_WEIG',
'_YART',
];
break;
case 'FAM':
$tags = [
// Facts for families, left out HUSB, WIFE & CHIL links
'RESN',
'ANUL',
'CENS',
'DIV',
'DIVF',
'ENGA',
'MARB',
'MARC',
'MARR',
'MARL',
'MARS',
'RESI',
'EVEN',
'NCHI',
'SUBM',
'SLGS',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'SOUR',
'OBJE',
// non standard tags
'_NMR',
'MARR_CIVIL',
'MARR_RELIGIOUS',
'MARR_PARTNERS',
'MARR_UNKNOWN',
'_COML',
'_MBON',
'_MARI',
'_SEPR',
'_TODO',
];
break;
case 'SOUR':
$tags = [
// Facts for sources
'DATA',
'AUTH',
'TITL',
'ABBR',
'PUBL',
'TEXT',
'REPO',
'REFN',
'RIN',
'CHAN',
'NOTE',
'SHARED_NOTE',
'OBJE',
'RESN',
];
break;
case 'REPO':
$tags = [
// Facts for repositories
'NAME',
'ADDR',
'PHON',
'EMAIL',
'FAX',
'WWW',
'NOTE',
'SHARED_NOTE',
'REFN',
'RIN',
'CHAN',
'RESN',
];
break;
case 'PLAC':
$tags = [
// Facts for places
'FONE',
'ROMN',
// non standard tags
'_HEB',
];
break;
case 'NAME':
$tags = [
// Facts subordinate to NAME
'FONE',
'ROMN',
// non standard tags
'_HEB',
'_AKA',
'_MARNM',
];
break;
default:
$tags = [];
break;
}
$facts = [];
foreach ($tags as $tag) {
$facts[$tag] = self::getLabel($tag, null);
}
uasort($facts, '\Fisharebest\Webtrees\I18N::strcasecmp');
return $facts;
} | [
"public",
"static",
"function",
"getPicklistFacts",
"(",
"$",
"fact_type",
")",
":",
"array",
"{",
"switch",
"(",
"$",
"fact_type",
")",
"{",
"case",
"'INDI'",
":",
"$",
"tags",
"=",
"[",
"// Facts, attributes for individuals (no links to FAMs)",
"'RESN'",
",",
"'NAME'",
",",
"'SEX'",
",",
"'BIRT'",
",",
"'CHR'",
",",
"'DEAT'",
",",
"'BURI'",
",",
"'CREM'",
",",
"'ADOP'",
",",
"'BAPM'",
",",
"'BARM'",
",",
"'BASM'",
",",
"'BLES'",
",",
"'CHRA'",
",",
"'CONF'",
",",
"'FCOM'",
",",
"'ORDN'",
",",
"'NATU'",
",",
"'EMIG'",
",",
"'IMMI'",
",",
"'CENS'",
",",
"'PROB'",
",",
"'WILL'",
",",
"'GRAD'",
",",
"'RETI'",
",",
"'EVEN'",
",",
"'CAST'",
",",
"'DSCR'",
",",
"'EDUC'",
",",
"'IDNO'",
",",
"'NATI'",
",",
"'NCHI'",
",",
"'NMR'",
",",
"'OCCU'",
",",
"'PROP'",
",",
"'RELI'",
",",
"'RESI'",
",",
"'SSN'",
",",
"'TITL'",
",",
"'FACT'",
",",
"'BAPL'",
",",
"'CONL'",
",",
"'ENDL'",
",",
"'SLGC'",
",",
"'SUBM'",
",",
"'ASSO'",
",",
"'ALIA'",
",",
"'ANCI'",
",",
"'DESI'",
",",
"'RFN'",
",",
"'AFN'",
",",
"'REFN'",
",",
"'RIN'",
",",
"'CHAN'",
",",
"'NOTE'",
",",
"'SHARED_NOTE'",
",",
"'SOUR'",
",",
"'OBJE'",
",",
"// non standard tags",
"'_BRTM'",
",",
"'_DEG'",
",",
"'_DNA'",
",",
"'_EYEC'",
",",
"'_FNRL'",
",",
"'_HAIR'",
",",
"'_HEIG'",
",",
"'_HNM'",
",",
"'_HOL'",
",",
"'_INTE'",
",",
"'_MDCL'",
",",
"'_MEDC'",
",",
"'_MILI'",
",",
"'_MILT'",
",",
"'_NAME'",
",",
"'_NAMS'",
",",
"'_NLIV'",
",",
"'_NMAR'",
",",
"'_PRMN'",
",",
"'_TODO'",
",",
"'_UID'",
",",
"'_WEIG'",
",",
"'_YART'",
",",
"]",
";",
"break",
";",
"case",
"'FAM'",
":",
"$",
"tags",
"=",
"[",
"// Facts for families, left out HUSB, WIFE & CHIL links",
"'RESN'",
",",
"'ANUL'",
",",
"'CENS'",
",",
"'DIV'",
",",
"'DIVF'",
",",
"'ENGA'",
",",
"'MARB'",
",",
"'MARC'",
",",
"'MARR'",
",",
"'MARL'",
",",
"'MARS'",
",",
"'RESI'",
",",
"'EVEN'",
",",
"'NCHI'",
",",
"'SUBM'",
",",
"'SLGS'",
",",
"'REFN'",
",",
"'RIN'",
",",
"'CHAN'",
",",
"'NOTE'",
",",
"'SHARED_NOTE'",
",",
"'SOUR'",
",",
"'OBJE'",
",",
"// non standard tags",
"'_NMR'",
",",
"'MARR_CIVIL'",
",",
"'MARR_RELIGIOUS'",
",",
"'MARR_PARTNERS'",
",",
"'MARR_UNKNOWN'",
",",
"'_COML'",
",",
"'_MBON'",
",",
"'_MARI'",
",",
"'_SEPR'",
",",
"'_TODO'",
",",
"]",
";",
"break",
";",
"case",
"'SOUR'",
":",
"$",
"tags",
"=",
"[",
"// Facts for sources",
"'DATA'",
",",
"'AUTH'",
",",
"'TITL'",
",",
"'ABBR'",
",",
"'PUBL'",
",",
"'TEXT'",
",",
"'REPO'",
",",
"'REFN'",
",",
"'RIN'",
",",
"'CHAN'",
",",
"'NOTE'",
",",
"'SHARED_NOTE'",
",",
"'OBJE'",
",",
"'RESN'",
",",
"]",
";",
"break",
";",
"case",
"'REPO'",
":",
"$",
"tags",
"=",
"[",
"// Facts for repositories",
"'NAME'",
",",
"'ADDR'",
",",
"'PHON'",
",",
"'EMAIL'",
",",
"'FAX'",
",",
"'WWW'",
",",
"'NOTE'",
",",
"'SHARED_NOTE'",
",",
"'REFN'",
",",
"'RIN'",
",",
"'CHAN'",
",",
"'RESN'",
",",
"]",
";",
"break",
";",
"case",
"'PLAC'",
":",
"$",
"tags",
"=",
"[",
"// Facts for places",
"'FONE'",
",",
"'ROMN'",
",",
"// non standard tags",
"'_HEB'",
",",
"]",
";",
"break",
";",
"case",
"'NAME'",
":",
"$",
"tags",
"=",
"[",
"// Facts subordinate to NAME",
"'FONE'",
",",
"'ROMN'",
",",
"// non standard tags",
"'_HEB'",
",",
"'_AKA'",
",",
"'_MARNM'",
",",
"]",
";",
"break",
";",
"default",
":",
"$",
"tags",
"=",
"[",
"]",
";",
"break",
";",
"}",
"$",
"facts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"facts",
"[",
"$",
"tag",
"]",
"=",
"self",
"::",
"getLabel",
"(",
"$",
"tag",
",",
"null",
")",
";",
"}",
"uasort",
"(",
"$",
"facts",
",",
"'\\Fisharebest\\Webtrees\\I18N::strcasecmp'",
")",
";",
"return",
"$",
"facts",
";",
"}"
] | Get a list of facts, for use in the "fact picker" edit control
@param string $fact_type
@return string[] | [
"Get",
"a",
"list",
"of",
"facts",
"for",
"use",
"in",
"the",
"fact",
"picker",
"edit",
"control"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomTag.php#L2141-L2338 | train |
fisharebest/webtrees | app/GedcomTag.php | GedcomTag.createUid | public static function createUid(): string
{
$uid = str_replace('-', '', Uuid::uuid4()->toString());
$checksum_a = 0; // a sum of the bytes
$checksum_b = 0; // a sum of the incremental values of $checksum_a
// Compute checksums
for ($i = 0; $i < 32; $i += 2) {
$checksum_a += hexdec(substr($uid, $i, 2));
$checksum_b += $checksum_a & 0xff;
}
return strtoupper($uid . substr(dechex($checksum_a), -2) . substr(dechex($checksum_b), -2));
} | php | public static function createUid(): string
{
$uid = str_replace('-', '', Uuid::uuid4()->toString());
$checksum_a = 0; // a sum of the bytes
$checksum_b = 0; // a sum of the incremental values of $checksum_a
// Compute checksums
for ($i = 0; $i < 32; $i += 2) {
$checksum_a += hexdec(substr($uid, $i, 2));
$checksum_b += $checksum_a & 0xff;
}
return strtoupper($uid . substr(dechex($checksum_a), -2) . substr(dechex($checksum_b), -2));
} | [
"public",
"static",
"function",
"createUid",
"(",
")",
":",
"string",
"{",
"$",
"uid",
"=",
"str_replace",
"(",
"'-'",
",",
"''",
",",
"Uuid",
"::",
"uuid4",
"(",
")",
"->",
"toString",
"(",
")",
")",
";",
"$",
"checksum_a",
"=",
"0",
";",
"// a sum of the bytes",
"$",
"checksum_b",
"=",
"0",
";",
"// a sum of the incremental values of $checksum_a",
"// Compute checksums",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"32",
";",
"$",
"i",
"+=",
"2",
")",
"{",
"$",
"checksum_a",
"+=",
"hexdec",
"(",
"substr",
"(",
"$",
"uid",
",",
"$",
"i",
",",
"2",
")",
")",
";",
"$",
"checksum_b",
"+=",
"$",
"checksum_a",
"&",
"0xff",
";",
"}",
"return",
"strtoupper",
"(",
"$",
"uid",
".",
"substr",
"(",
"dechex",
"(",
"$",
"checksum_a",
")",
",",
"-",
"2",
")",
".",
"substr",
"(",
"dechex",
"(",
"$",
"checksum_b",
")",
",",
"-",
"2",
")",
")",
";",
"}"
] | Generate a value for a new _UID field.
Instead of RFC4122-compatible UUIDs, generate ones that
are compatible with PAF, Legacy, RootsMagic, etc.
In these, the string is upper-cased, dashes are removed,
and a two-byte checksum is added.
@return string | [
"Generate",
"a",
"value",
"for",
"a",
"new",
"_UID",
"field",
".",
"Instead",
"of",
"RFC4122",
"-",
"compatible",
"UUIDs",
"generate",
"ones",
"that",
"are",
"compatible",
"with",
"PAF",
"Legacy",
"RootsMagic",
"etc",
".",
"In",
"these",
"the",
"string",
"is",
"upper",
"-",
"cased",
"dashes",
"are",
"removed",
"and",
"a",
"two",
"-",
"byte",
"checksum",
"is",
"added",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomTag.php#L2432-L2446 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ControlPanelController.php | ControlPanelController.controlPanelManager | public function controlPanelManager(ModuleService $module_service): ResponseInterface
{
$all_trees = array_filter(Tree::getAll(), static function (Tree $tree): bool {
return Auth::isManager($tree);
});
return $this->viewResponse('admin/control-panel-manager', [
'title' => I18N::translate('Control panel'),
'all_trees' => $all_trees,
'changes' => $this->totalChanges(),
'individuals' => $this->totalIndividuals(),
'families' => $this->totalFamilies(),
'sources' => $this->totalSources(),
'media' => $this->totalMediaObjects(),
'repositories' => $this->totalRepositories(),
'notes' => $this->totalNotes(),
'individual_list_module' => $module_service->findByInterface(IndividualListModule::class)->first(),
'family_list_module' => $module_service->findByInterface(FamilyListModule::class)->first(),
'media_list_module' => $module_service->findByInterface(MediaListModule::class)->first(),
'note_list_module' => $module_service->findByInterface(NoteListModule::class)->first(),
'repository_list_module' => $module_service->findByInterface(RepositoryListModule::class)->first(),
'source_list_module' => $module_service->findByInterface(SourceListModule::class)->first(),
]);
} | php | public function controlPanelManager(ModuleService $module_service): ResponseInterface
{
$all_trees = array_filter(Tree::getAll(), static function (Tree $tree): bool {
return Auth::isManager($tree);
});
return $this->viewResponse('admin/control-panel-manager', [
'title' => I18N::translate('Control panel'),
'all_trees' => $all_trees,
'changes' => $this->totalChanges(),
'individuals' => $this->totalIndividuals(),
'families' => $this->totalFamilies(),
'sources' => $this->totalSources(),
'media' => $this->totalMediaObjects(),
'repositories' => $this->totalRepositories(),
'notes' => $this->totalNotes(),
'individual_list_module' => $module_service->findByInterface(IndividualListModule::class)->first(),
'family_list_module' => $module_service->findByInterface(FamilyListModule::class)->first(),
'media_list_module' => $module_service->findByInterface(MediaListModule::class)->first(),
'note_list_module' => $module_service->findByInterface(NoteListModule::class)->first(),
'repository_list_module' => $module_service->findByInterface(RepositoryListModule::class)->first(),
'source_list_module' => $module_service->findByInterface(SourceListModule::class)->first(),
]);
} | [
"public",
"function",
"controlPanelManager",
"(",
"ModuleService",
"$",
"module_service",
")",
":",
"ResponseInterface",
"{",
"$",
"all_trees",
"=",
"array_filter",
"(",
"Tree",
"::",
"getAll",
"(",
")",
",",
"static",
"function",
"(",
"Tree",
"$",
"tree",
")",
":",
"bool",
"{",
"return",
"Auth",
"::",
"isManager",
"(",
"$",
"tree",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'admin/control-panel-manager'",
",",
"[",
"'title'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Control panel'",
")",
",",
"'all_trees'",
"=>",
"$",
"all_trees",
",",
"'changes'",
"=>",
"$",
"this",
"->",
"totalChanges",
"(",
")",
",",
"'individuals'",
"=>",
"$",
"this",
"->",
"totalIndividuals",
"(",
")",
",",
"'families'",
"=>",
"$",
"this",
"->",
"totalFamilies",
"(",
")",
",",
"'sources'",
"=>",
"$",
"this",
"->",
"totalSources",
"(",
")",
",",
"'media'",
"=>",
"$",
"this",
"->",
"totalMediaObjects",
"(",
")",
",",
"'repositories'",
"=>",
"$",
"this",
"->",
"totalRepositories",
"(",
")",
",",
"'notes'",
"=>",
"$",
"this",
"->",
"totalNotes",
"(",
")",
",",
"'individual_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"IndividualListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"'family_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"FamilyListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"'media_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"MediaListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"'note_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"NoteListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"'repository_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"RepositoryListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"'source_list_module'",
"=>",
"$",
"module_service",
"->",
"findByInterface",
"(",
"SourceListModule",
"::",
"class",
")",
"->",
"first",
"(",
")",
",",
"]",
")",
";",
"}"
] | Managers see a restricted version of the contol panel.
@param ModuleService $module_service
@return ResponseInterface | [
"Managers",
"see",
"a",
"restricted",
"version",
"of",
"the",
"contol",
"panel",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ControlPanelController.php#L144-L167 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ControlPanelController.php | ControlPanelController.totalChanges | private function totalChanges(): array
{
return DB::table('gedcom')
->leftJoin('change', static function (JoinClause $join): void {
$join
->on('change.gedcom_id', '=', 'gedcom.gedcom_id')
->where('change.status', '=', 'pending');
})
->groupBy('gedcom.gedcom_id')
->pluck(DB::raw('COUNT(change_id)'), 'gedcom.gedcom_id')
->all();
} | php | private function totalChanges(): array
{
return DB::table('gedcom')
->leftJoin('change', static function (JoinClause $join): void {
$join
->on('change.gedcom_id', '=', 'gedcom.gedcom_id')
->where('change.status', '=', 'pending');
})
->groupBy('gedcom.gedcom_id')
->pluck(DB::raw('COUNT(change_id)'), 'gedcom.gedcom_id')
->all();
} | [
"private",
"function",
"totalChanges",
"(",
")",
":",
"array",
"{",
"return",
"DB",
"::",
"table",
"(",
"'gedcom'",
")",
"->",
"leftJoin",
"(",
"'change'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'change.gedcom_id'",
",",
"'='",
",",
"'gedcom.gedcom_id'",
")",
"->",
"where",
"(",
"'change.status'",
",",
"'='",
",",
"'pending'",
")",
";",
"}",
")",
"->",
"groupBy",
"(",
"'gedcom.gedcom_id'",
")",
"->",
"pluck",
"(",
"DB",
"::",
"raw",
"(",
"'COUNT(change_id)'",
")",
",",
"'gedcom.gedcom_id'",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Count the number of pending changes in each tree.
@return string[] | [
"Count",
"the",
"number",
"of",
"pending",
"changes",
"in",
"each",
"tree",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ControlPanelController.php#L174-L185 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ControlPanelController.php | ControlPanelController.totalFamilies | private function totalFamilies(): Collection
{
return DB::table('gedcom')
->leftJoin('families', 'f_file', '=', 'gedcom_id')
->groupBy('gedcom_id')
->pluck(DB::raw('COUNT(f_id)'), 'gedcom_id')
->map(static function (string $count) {
return (int) $count;
});
} | php | private function totalFamilies(): Collection
{
return DB::table('gedcom')
->leftJoin('families', 'f_file', '=', 'gedcom_id')
->groupBy('gedcom_id')
->pluck(DB::raw('COUNT(f_id)'), 'gedcom_id')
->map(static function (string $count) {
return (int) $count;
});
} | [
"private",
"function",
"totalFamilies",
"(",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"'gedcom'",
")",
"->",
"leftJoin",
"(",
"'families'",
",",
"'f_file'",
",",
"'='",
",",
"'gedcom_id'",
")",
"->",
"groupBy",
"(",
"'gedcom_id'",
")",
"->",
"pluck",
"(",
"DB",
"::",
"raw",
"(",
"'COUNT(f_id)'",
")",
",",
"'gedcom_id'",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"string",
"$",
"count",
")",
"{",
"return",
"(",
"int",
")",
"$",
"count",
";",
"}",
")",
";",
"}"
] | Count the number of families in each tree.
@return Collection
@return int[] | [
"Count",
"the",
"number",
"of",
"families",
"in",
"each",
"tree",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ControlPanelController.php#L193-L202 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/ControlPanelController.php | ControlPanelController.totalNotes | private function totalNotes(): Collection
{
return DB::table('gedcom')
->leftJoin('other', static function (JoinClause $join): void {
$join
->on('o_file', '=', 'gedcom_id')
->where('o_type', '=', 'NOTE');
})
->groupBy('gedcom_id')
->pluck(DB::raw('COUNT(o_id)'), 'gedcom_id')
->map(static function (string $count) {
return (int) $count;
});
} | php | private function totalNotes(): Collection
{
return DB::table('gedcom')
->leftJoin('other', static function (JoinClause $join): void {
$join
->on('o_file', '=', 'gedcom_id')
->where('o_type', '=', 'NOTE');
})
->groupBy('gedcom_id')
->pluck(DB::raw('COUNT(o_id)'), 'gedcom_id')
->map(static function (string $count) {
return (int) $count;
});
} | [
"private",
"function",
"totalNotes",
"(",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"'gedcom'",
")",
"->",
"leftJoin",
"(",
"'other'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'o_file'",
",",
"'='",
",",
"'gedcom_id'",
")",
"->",
"where",
"(",
"'o_type'",
",",
"'='",
",",
"'NOTE'",
")",
";",
"}",
")",
"->",
"groupBy",
"(",
"'gedcom_id'",
")",
"->",
"pluck",
"(",
"DB",
"::",
"raw",
"(",
"'COUNT(o_id)'",
")",
",",
"'gedcom_id'",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"string",
"$",
"count",
")",
"{",
"return",
"(",
"int",
")",
"$",
"count",
";",
"}",
")",
";",
"}"
] | Count the number of notes in each tree.
@return Collection
@return int[] | [
"Count",
"the",
"number",
"of",
"notes",
"in",
"each",
"tree",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ControlPanelController.php#L244-L257 | train |
fisharebest/webtrees | app/Census/CensusColumnFullName.php | CensusColumnFullName.nameAtCensusDate | protected function nameAtCensusDate(Individual $individual, Date $census_date): array
{
$names = $individual->getAllNames();
$name = $names[0];
foreach ($individual->spouseFamilies() as $family) {
foreach ($family->facts(['MARR']) as $marriage) {
if ($marriage->date()->isOK() && Date::compare($marriage->date(), $census_date) < 0) {
$spouse = $family->spouse($individual);
foreach ($names as $individual_name) {
foreach ($spouse->getAllNames() as $spouse_name) {
if ($individual_name['type'] === '_MARNM' && $individual_name['surn'] === $spouse_name['surn']) {
return $individual_name;
}
}
}
}
}
}
return $name;
} | php | protected function nameAtCensusDate(Individual $individual, Date $census_date): array
{
$names = $individual->getAllNames();
$name = $names[0];
foreach ($individual->spouseFamilies() as $family) {
foreach ($family->facts(['MARR']) as $marriage) {
if ($marriage->date()->isOK() && Date::compare($marriage->date(), $census_date) < 0) {
$spouse = $family->spouse($individual);
foreach ($names as $individual_name) {
foreach ($spouse->getAllNames() as $spouse_name) {
if ($individual_name['type'] === '_MARNM' && $individual_name['surn'] === $spouse_name['surn']) {
return $individual_name;
}
}
}
}
}
}
return $name;
} | [
"protected",
"function",
"nameAtCensusDate",
"(",
"Individual",
"$",
"individual",
",",
"Date",
"$",
"census_date",
")",
":",
"array",
"{",
"$",
"names",
"=",
"$",
"individual",
"->",
"getAllNames",
"(",
")",
";",
"$",
"name",
"=",
"$",
"names",
"[",
"0",
"]",
";",
"foreach",
"(",
"$",
"individual",
"->",
"spouseFamilies",
"(",
")",
"as",
"$",
"family",
")",
"{",
"foreach",
"(",
"$",
"family",
"->",
"facts",
"(",
"[",
"'MARR'",
"]",
")",
"as",
"$",
"marriage",
")",
"{",
"if",
"(",
"$",
"marriage",
"->",
"date",
"(",
")",
"->",
"isOK",
"(",
")",
"&&",
"Date",
"::",
"compare",
"(",
"$",
"marriage",
"->",
"date",
"(",
")",
",",
"$",
"census_date",
")",
"<",
"0",
")",
"{",
"$",
"spouse",
"=",
"$",
"family",
"->",
"spouse",
"(",
"$",
"individual",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"individual_name",
")",
"{",
"foreach",
"(",
"$",
"spouse",
"->",
"getAllNames",
"(",
")",
"as",
"$",
"spouse_name",
")",
"{",
"if",
"(",
"$",
"individual_name",
"[",
"'type'",
"]",
"===",
"'_MARNM'",
"&&",
"$",
"individual_name",
"[",
"'surn'",
"]",
"===",
"$",
"spouse_name",
"[",
"'surn'",
"]",
")",
"{",
"return",
"$",
"individual_name",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"name",
";",
"}"
] | What was an individual's likely name on a given date, allowing
for marriages and married names.
@param Individual $individual
@param Date $census_date
@return string[] | [
"What",
"was",
"an",
"individual",
"s",
"likely",
"name",
"on",
"a",
"given",
"date",
"allowing",
"for",
"marriages",
"and",
"married",
"names",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Census/CensusColumnFullName.php#L52-L73 | train |
fisharebest/webtrees | app/SurnameTradition.php | SurnameTradition.create | public static function create($name): SurnameTraditionInterface
{
switch ($name) {
case 'paternal':
return new PaternalSurnameTradition();
case 'patrilineal':
return new PatrilinealSurnameTradition();
case 'matrilineal':
return new MatrilinealSurnameTradition();
case 'portuguese':
return new PortugueseSurnameTradition();
case 'spanish':
return new SpanishSurnameTradition();
case 'polish':
return new PolishSurnameTradition();
case 'lithuanian':
return new LithuanianSurnameTradition();
case 'icelandic':
return new IcelandicSurnameTradition();
default:
return new DefaultSurnameTradition();
}
} | php | public static function create($name): SurnameTraditionInterface
{
switch ($name) {
case 'paternal':
return new PaternalSurnameTradition();
case 'patrilineal':
return new PatrilinealSurnameTradition();
case 'matrilineal':
return new MatrilinealSurnameTradition();
case 'portuguese':
return new PortugueseSurnameTradition();
case 'spanish':
return new SpanishSurnameTradition();
case 'polish':
return new PolishSurnameTradition();
case 'lithuanian':
return new LithuanianSurnameTradition();
case 'icelandic':
return new IcelandicSurnameTradition();
default:
return new DefaultSurnameTradition();
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
":",
"SurnameTraditionInterface",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'paternal'",
":",
"return",
"new",
"PaternalSurnameTradition",
"(",
")",
";",
"case",
"'patrilineal'",
":",
"return",
"new",
"PatrilinealSurnameTradition",
"(",
")",
";",
"case",
"'matrilineal'",
":",
"return",
"new",
"MatrilinealSurnameTradition",
"(",
")",
";",
"case",
"'portuguese'",
":",
"return",
"new",
"PortugueseSurnameTradition",
"(",
")",
";",
"case",
"'spanish'",
":",
"return",
"new",
"SpanishSurnameTradition",
"(",
")",
";",
"case",
"'polish'",
":",
"return",
"new",
"PolishSurnameTradition",
"(",
")",
";",
"case",
"'lithuanian'",
":",
"return",
"new",
"LithuanianSurnameTradition",
"(",
")",
";",
"case",
"'icelandic'",
":",
"return",
"new",
"IcelandicSurnameTradition",
"(",
")",
";",
"default",
":",
"return",
"new",
"DefaultSurnameTradition",
"(",
")",
";",
"}",
"}"
] | Create a surname tradition object for a given surname tradition name.
@param string $name Internal name of the surname tradition
@return SurnameTraditionInterface | [
"Create",
"a",
"surname",
"tradition",
"object",
"for",
"a",
"given",
"surname",
"tradition",
"name",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/SurnameTradition.php#L43-L65 | train |
fisharebest/webtrees | app/Log.php | Log.addConfigurationLog | public static function addConfigurationLog($message, Tree $tree = null): void
{
self::addLog($message, self::TYPE_CONFIGURATION, $tree);
} | php | public static function addConfigurationLog($message, Tree $tree = null): void
{
self::addLog($message, self::TYPE_CONFIGURATION, $tree);
} | [
"public",
"static",
"function",
"addConfigurationLog",
"(",
"$",
"message",
",",
"Tree",
"$",
"tree",
"=",
"null",
")",
":",
"void",
"{",
"self",
"::",
"addLog",
"(",
"$",
"message",
",",
"self",
"::",
"TYPE_CONFIGURATION",
",",
"$",
"tree",
")",
";",
"}"
] | Store a configuration message in the message log.
@param string $message
@param Tree|null $tree
@return void | [
"Store",
"a",
"configuration",
"message",
"in",
"the",
"message",
"log",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Log.php#L84-L87 | train |
fisharebest/webtrees | app/Log.php | Log.addEditLog | public static function addEditLog($message, Tree $tree): void
{
self::addLog($message, self::TYPE_EDIT, $tree);
} | php | public static function addEditLog($message, Tree $tree): void
{
self::addLog($message, self::TYPE_EDIT, $tree);
} | [
"public",
"static",
"function",
"addEditLog",
"(",
"$",
"message",
",",
"Tree",
"$",
"tree",
")",
":",
"void",
"{",
"self",
"::",
"addLog",
"(",
"$",
"message",
",",
"self",
"::",
"TYPE_EDIT",
",",
"$",
"tree",
")",
";",
"}"
] | Store an edit message in the message log.
@param string $message
@param Tree $tree
@return void | [
"Store",
"an",
"edit",
"message",
"in",
"the",
"message",
"log",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Log.php#L97-L100 | train |
fisharebest/webtrees | app/Log.php | Log.addSearchLog | public static function addSearchLog($message, array $trees): void
{
foreach ($trees as $tree) {
self::addLog($message, self::TYPE_SEARCH, $tree);
}
} | php | public static function addSearchLog($message, array $trees): void
{
foreach ($trees as $tree) {
self::addLog($message, self::TYPE_SEARCH, $tree);
}
} | [
"public",
"static",
"function",
"addSearchLog",
"(",
"$",
"message",
",",
"array",
"$",
"trees",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"trees",
"as",
"$",
"tree",
")",
"{",
"self",
"::",
"addLog",
"(",
"$",
"message",
",",
"self",
"::",
"TYPE_SEARCH",
",",
"$",
"tree",
")",
";",
"}",
"}"
] | Store a search event in the message log.
Unlike most webtrees activity, search is not restricted to a single tree,
so we need to record which trees were searchecd.
@param string $message
@param Tree[] $trees Which trees were searched
@return void | [
"Store",
"a",
"search",
"event",
"in",
"the",
"message",
"log",
".",
"Unlike",
"most",
"webtrees",
"activity",
"search",
"is",
"not",
"restricted",
"to",
"a",
"single",
"tree",
"so",
"we",
"need",
"to",
"record",
"which",
"trees",
"were",
"searchecd",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Log.php#L136-L141 | train |
fisharebest/webtrees | app/Module/AbstractModule.php | AbstractModule.getBlockSetting | final protected function getBlockSetting(int $block_id, string $setting_name, string $default = ''): string
{
$settings = app('cache.array')->rememberForever('block_setting' . $block_id, static function () use ($block_id): array {
return DB::table('block_setting')
->where('block_id', '=', $block_id)
->pluck('setting_value', 'setting_name')
->all();
});
return $settings[$setting_name] ?? $default;
} | php | final protected function getBlockSetting(int $block_id, string $setting_name, string $default = ''): string
{
$settings = app('cache.array')->rememberForever('block_setting' . $block_id, static function () use ($block_id): array {
return DB::table('block_setting')
->where('block_id', '=', $block_id)
->pluck('setting_value', 'setting_name')
->all();
});
return $settings[$setting_name] ?? $default;
} | [
"final",
"protected",
"function",
"getBlockSetting",
"(",
"int",
"$",
"block_id",
",",
"string",
"$",
"setting_name",
",",
"string",
"$",
"default",
"=",
"''",
")",
":",
"string",
"{",
"$",
"settings",
"=",
"app",
"(",
"'cache.array'",
")",
"->",
"rememberForever",
"(",
"'block_setting'",
".",
"$",
"block_id",
",",
"static",
"function",
"(",
")",
"use",
"(",
"$",
"block_id",
")",
":",
"array",
"{",
"return",
"DB",
"::",
"table",
"(",
"'block_setting'",
")",
"->",
"where",
"(",
"'block_id'",
",",
"'='",
",",
"$",
"block_id",
")",
"->",
"pluck",
"(",
"'setting_value'",
",",
"'setting_name'",
")",
"->",
"all",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"settings",
"[",
"$",
"setting_name",
"]",
"??",
"$",
"default",
";",
"}"
] | Get a block setting.
Originally, this was just used for the home-page blocks. Now, it is used by any
module that has repeated blocks of content on the same page.
@param int $block_id
@param string $setting_name
@param string $default
@return string | [
"Get",
"a",
"block",
"setting",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/AbstractModule.php#L82-L92 | train |
fisharebest/webtrees | app/Module/AbstractModule.php | AbstractModule.setBlockSetting | final protected function setBlockSetting(int $block_id, string $setting_name, string $setting_value): self
{
DB::table('block_setting')->updateOrInsert([
'block_id' => $block_id,
'setting_name' => $setting_name,
], [
'setting_value' => $setting_value,
]);
return $this;
} | php | final protected function setBlockSetting(int $block_id, string $setting_name, string $setting_value): self
{
DB::table('block_setting')->updateOrInsert([
'block_id' => $block_id,
'setting_name' => $setting_name,
], [
'setting_value' => $setting_value,
]);
return $this;
} | [
"final",
"protected",
"function",
"setBlockSetting",
"(",
"int",
"$",
"block_id",
",",
"string",
"$",
"setting_name",
",",
"string",
"$",
"setting_value",
")",
":",
"self",
"{",
"DB",
"::",
"table",
"(",
"'block_setting'",
")",
"->",
"updateOrInsert",
"(",
"[",
"'block_id'",
"=>",
"$",
"block_id",
",",
"'setting_name'",
"=>",
"$",
"setting_name",
",",
"]",
",",
"[",
"'setting_value'",
"=>",
"$",
"setting_value",
",",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set a block setting.
@param int $block_id
@param string $setting_name
@param string $setting_value
@return $this | [
"Set",
"a",
"block",
"setting",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/AbstractModule.php#L103-L113 | train |
fisharebest/webtrees | app/Module/AbstractModule.php | AbstractModule.getPreference | final public function getPreference(string $setting_name, string $default = ''): string
{
return DB::table('module_setting')
->where('module_name', '=', $this->name())
->where('setting_name', '=', $setting_name)
->value('setting_value') ?? $default;
} | php | final public function getPreference(string $setting_name, string $default = ''): string
{
return DB::table('module_setting')
->where('module_name', '=', $this->name())
->where('setting_name', '=', $setting_name)
->value('setting_value') ?? $default;
} | [
"final",
"public",
"function",
"getPreference",
"(",
"string",
"$",
"setting_name",
",",
"string",
"$",
"default",
"=",
"''",
")",
":",
"string",
"{",
"return",
"DB",
"::",
"table",
"(",
"'module_setting'",
")",
"->",
"where",
"(",
"'module_name'",
",",
"'='",
",",
"$",
"this",
"->",
"name",
"(",
")",
")",
"->",
"where",
"(",
"'setting_name'",
",",
"'='",
",",
"$",
"setting_name",
")",
"->",
"value",
"(",
"'setting_value'",
")",
"??",
"$",
"default",
";",
"}"
] | Get a module setting. Return a default if the setting is not set.
@param string $setting_name
@param string $default
@return string | [
"Get",
"a",
"module",
"setting",
".",
"Return",
"a",
"default",
"if",
"the",
"setting",
"is",
"not",
"set",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/AbstractModule.php#L179-L185 | train |
fisharebest/webtrees | app/Module/AbstractModule.php | AbstractModule.setPreference | final public function setPreference(string $setting_name, string $setting_value): void
{
DB::table('module_setting')->updateOrInsert([
'module_name' => $this->name(),
'setting_name' => $setting_name,
], [
'setting_value' => $setting_value,
]);
} | php | final public function setPreference(string $setting_name, string $setting_value): void
{
DB::table('module_setting')->updateOrInsert([
'module_name' => $this->name(),
'setting_name' => $setting_name,
], [
'setting_value' => $setting_value,
]);
} | [
"final",
"public",
"function",
"setPreference",
"(",
"string",
"$",
"setting_name",
",",
"string",
"$",
"setting_value",
")",
":",
"void",
"{",
"DB",
"::",
"table",
"(",
"'module_setting'",
")",
"->",
"updateOrInsert",
"(",
"[",
"'module_name'",
"=>",
"$",
"this",
"->",
"name",
"(",
")",
",",
"'setting_name'",
"=>",
"$",
"setting_name",
",",
"]",
",",
"[",
"'setting_value'",
"=>",
"$",
"setting_value",
",",
"]",
")",
";",
"}"
] | Set a module setting.
Since module settings are NOT NULL, setting a value to NULL will cause
it to be deleted.
@param string $setting_name
@param string $setting_value
@return void | [
"Set",
"a",
"module",
"setting",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/AbstractModule.php#L198-L206 | train |
fisharebest/webtrees | app/Module/AbstractModule.php | AbstractModule.accessLevel | final public function accessLevel(Tree $tree, string $interface): int
{
$access_levels = app('cache.array')
->rememberForever('module_privacy' . $tree->id(), static function () use ($tree): Collection {
return DB::table('module_privacy')
->where('gedcom_id', '=', $tree->id())
->get();
});
$row = $access_levels->first(function (stdClass $row) use ($interface): bool {
return $row->interface === $interface && $row->module_name === $this->name();
});
return $row ? (int) $row->access_level : $this->access_level;
} | php | final public function accessLevel(Tree $tree, string $interface): int
{
$access_levels = app('cache.array')
->rememberForever('module_privacy' . $tree->id(), static function () use ($tree): Collection {
return DB::table('module_privacy')
->where('gedcom_id', '=', $tree->id())
->get();
});
$row = $access_levels->first(function (stdClass $row) use ($interface): bool {
return $row->interface === $interface && $row->module_name === $this->name();
});
return $row ? (int) $row->access_level : $this->access_level;
} | [
"final",
"public",
"function",
"accessLevel",
"(",
"Tree",
"$",
"tree",
",",
"string",
"$",
"interface",
")",
":",
"int",
"{",
"$",
"access_levels",
"=",
"app",
"(",
"'cache.array'",
")",
"->",
"rememberForever",
"(",
"'module_privacy'",
".",
"$",
"tree",
"->",
"id",
"(",
")",
",",
"static",
"function",
"(",
")",
"use",
"(",
"$",
"tree",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"'module_privacy'",
")",
"->",
"where",
"(",
"'gedcom_id'",
",",
"'='",
",",
"$",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"get",
"(",
")",
";",
"}",
")",
";",
"$",
"row",
"=",
"$",
"access_levels",
"->",
"first",
"(",
"function",
"(",
"stdClass",
"$",
"row",
")",
"use",
"(",
"$",
"interface",
")",
":",
"bool",
"{",
"return",
"$",
"row",
"->",
"interface",
"===",
"$",
"interface",
"&&",
"$",
"row",
"->",
"module_name",
"===",
"$",
"this",
"->",
"name",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"row",
"?",
"(",
"int",
")",
"$",
"row",
"->",
"access_level",
":",
"$",
"this",
"->",
"access_level",
";",
"}"
] | Get a the current access level for a module
@param Tree $tree
@param string $interface
@return int | [
"Get",
"a",
"the",
"current",
"access",
"level",
"for",
"a",
"module"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/AbstractModule.php#L216-L230 | train |
fisharebest/webtrees | app/Http/Controllers/FamilyController.php | FamilyController.show | public function show(ServerRequestInterface $request, Tree $tree, ClipboardService $clipboard_service): ResponseInterface
{
$xref = $request->get('xref', '');
$family = Family::getInstance($xref, $tree);
Auth::checkFamilyAccess($family, false);
$clipboard_facts = $clipboard_service->pastableFacts($family, new Collection());
return $this->viewResponse('family-page', [
'facts' => $family->facts([], true),
'meta_robots' => 'index,follow',
'clipboard_facts' => $clipboard_facts,
'record' => $family,
'significant' => $this->significant($family),
'title' => $family->fullName(),
]);
} | php | public function show(ServerRequestInterface $request, Tree $tree, ClipboardService $clipboard_service): ResponseInterface
{
$xref = $request->get('xref', '');
$family = Family::getInstance($xref, $tree);
Auth::checkFamilyAccess($family, false);
$clipboard_facts = $clipboard_service->pastableFacts($family, new Collection());
return $this->viewResponse('family-page', [
'facts' => $family->facts([], true),
'meta_robots' => 'index,follow',
'clipboard_facts' => $clipboard_facts,
'record' => $family,
'significant' => $this->significant($family),
'title' => $family->fullName(),
]);
} | [
"public",
"function",
"show",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
",",
"ClipboardService",
"$",
"clipboard_service",
")",
":",
"ResponseInterface",
"{",
"$",
"xref",
"=",
"$",
"request",
"->",
"get",
"(",
"'xref'",
",",
"''",
")",
";",
"$",
"family",
"=",
"Family",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"Auth",
"::",
"checkFamilyAccess",
"(",
"$",
"family",
",",
"false",
")",
";",
"$",
"clipboard_facts",
"=",
"$",
"clipboard_service",
"->",
"pastableFacts",
"(",
"$",
"family",
",",
"new",
"Collection",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'family-page'",
",",
"[",
"'facts'",
"=>",
"$",
"family",
"->",
"facts",
"(",
"[",
"]",
",",
"true",
")",
",",
"'meta_robots'",
"=>",
"'index,follow'",
",",
"'clipboard_facts'",
"=>",
"$",
"clipboard_facts",
",",
"'record'",
"=>",
"$",
"family",
",",
"'significant'",
"=>",
"$",
"this",
"->",
"significant",
"(",
"$",
"family",
")",
",",
"'title'",
"=>",
"$",
"family",
"->",
"fullName",
"(",
")",
",",
"]",
")",
";",
"}"
] | Show a family's page.
@param ServerRequestInterface $request
@param Tree $tree
@param ClipboardService $clipboard_service
@return ResponseInterface | [
"Show",
"a",
"family",
"s",
"page",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/FamilyController.php#L43-L60 | train |
fisharebest/webtrees | app/Functions/Functions.php | Functions.fileUploadErrorText | public static function fileUploadErrorText($error_code): string
{
switch ($error_code) {
case UPLOAD_ERR_OK:
return I18N::translate('File successfully uploaded');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The uploaded file exceeds the allowed size.');
case UPLOAD_ERR_PARTIAL:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The file was only partially uploaded. Please try again.');
case UPLOAD_ERR_NO_FILE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('No file was received. Please try again.');
case UPLOAD_ERR_NO_TMP_DIR:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The PHP temporary folder is missing.');
case UPLOAD_ERR_CANT_WRITE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('PHP failed to write to disk.');
case UPLOAD_ERR_EXTENSION:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('PHP blocked the file because of its extension.');
default:
return 'Error: ' . $error_code;
}
} | php | public static function fileUploadErrorText($error_code): string
{
switch ($error_code) {
case UPLOAD_ERR_OK:
return I18N::translate('File successfully uploaded');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The uploaded file exceeds the allowed size.');
case UPLOAD_ERR_PARTIAL:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The file was only partially uploaded. Please try again.');
case UPLOAD_ERR_NO_FILE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('No file was received. Please try again.');
case UPLOAD_ERR_NO_TMP_DIR:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('The PHP temporary folder is missing.');
case UPLOAD_ERR_CANT_WRITE:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('PHP failed to write to disk.');
case UPLOAD_ERR_EXTENSION:
// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php
return I18N::translate('PHP blocked the file because of its extension.');
default:
return 'Error: ' . $error_code;
}
} | [
"public",
"static",
"function",
"fileUploadErrorText",
"(",
"$",
"error_code",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"error_code",
")",
"{",
"case",
"UPLOAD_ERR_OK",
":",
"return",
"I18N",
"::",
"translate",
"(",
"'File successfully uploaded'",
")",
";",
"case",
"UPLOAD_ERR_INI_SIZE",
":",
"case",
"UPLOAD_ERR_FORM_SIZE",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'The uploaded file exceeds the allowed size.'",
")",
";",
"case",
"UPLOAD_ERR_PARTIAL",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'The file was only partially uploaded. Please try again.'",
")",
";",
"case",
"UPLOAD_ERR_NO_FILE",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'No file was received. Please try again.'",
")",
";",
"case",
"UPLOAD_ERR_NO_TMP_DIR",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'The PHP temporary folder is missing.'",
")",
";",
"case",
"UPLOAD_ERR_CANT_WRITE",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'PHP failed to write to disk.'",
")",
";",
"case",
"UPLOAD_ERR_EXTENSION",
":",
"// I18N: PHP internal error message - php.net/manual/en/features.file-upload.errors.php",
"return",
"I18N",
"::",
"translate",
"(",
"'PHP blocked the file because of its extension.'",
")",
";",
"default",
":",
"return",
"'Error: '",
".",
"$",
"error_code",
";",
"}",
"}"
] | Convert a file upload PHP error code into user-friendly text.
@param int $error_code
@return string | [
"Convert",
"a",
"file",
"upload",
"PHP",
"error",
"code",
"into",
"user",
"-",
"friendly",
"text",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/Functions.php#L38-L65 | train |
fisharebest/webtrees | app/Functions/Functions.php | Functions.getSubRecord | public static function getSubRecord($level, $tag, $gedrec, $num = 1): string
{
if (empty($gedrec)) {
return '';
}
// -- adding \n before and after gedrec
$gedrec = "\n" . $gedrec . "\n";
$tag = trim($tag);
$searchTarget = "~[\n]" . $tag . "[\s]~";
$ct = preg_match_all($searchTarget, $gedrec, $match, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
if ($ct === 0) {
return '';
}
if ($ct < $num) {
return '';
}
$pos1 = $match[$num - 1][0][1];
$pos2 = strpos($gedrec, "\n$level", $pos1 + 1);
if (!$pos2) {
$pos2 = strpos($gedrec, "\n1", $pos1 + 1);
}
if (!$pos2) {
$pos2 = strpos($gedrec, "\nWT_", $pos1 + 1); // WT_SPOUSE, WT_FAMILY_ID ...
}
if (!$pos2) {
return ltrim(substr($gedrec, $pos1));
}
$subrec = substr($gedrec, $pos1, $pos2 - $pos1);
return ltrim($subrec);
} | php | public static function getSubRecord($level, $tag, $gedrec, $num = 1): string
{
if (empty($gedrec)) {
return '';
}
// -- adding \n before and after gedrec
$gedrec = "\n" . $gedrec . "\n";
$tag = trim($tag);
$searchTarget = "~[\n]" . $tag . "[\s]~";
$ct = preg_match_all($searchTarget, $gedrec, $match, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
if ($ct === 0) {
return '';
}
if ($ct < $num) {
return '';
}
$pos1 = $match[$num - 1][0][1];
$pos2 = strpos($gedrec, "\n$level", $pos1 + 1);
if (!$pos2) {
$pos2 = strpos($gedrec, "\n1", $pos1 + 1);
}
if (!$pos2) {
$pos2 = strpos($gedrec, "\nWT_", $pos1 + 1); // WT_SPOUSE, WT_FAMILY_ID ...
}
if (!$pos2) {
return ltrim(substr($gedrec, $pos1));
}
$subrec = substr($gedrec, $pos1, $pos2 - $pos1);
return ltrim($subrec);
} | [
"public",
"static",
"function",
"getSubRecord",
"(",
"$",
"level",
",",
"$",
"tag",
",",
"$",
"gedrec",
",",
"$",
"num",
"=",
"1",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"gedrec",
")",
")",
"{",
"return",
"''",
";",
"}",
"// -- adding \\n before and after gedrec",
"$",
"gedrec",
"=",
"\"\\n\"",
".",
"$",
"gedrec",
".",
"\"\\n\"",
";",
"$",
"tag",
"=",
"trim",
"(",
"$",
"tag",
")",
";",
"$",
"searchTarget",
"=",
"\"~[\\n]\"",
".",
"$",
"tag",
".",
"\"[\\s]~\"",
";",
"$",
"ct",
"=",
"preg_match_all",
"(",
"$",
"searchTarget",
",",
"$",
"gedrec",
",",
"$",
"match",
",",
"PREG_SET_ORDER",
"|",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"$",
"ct",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"ct",
"<",
"$",
"num",
")",
"{",
"return",
"''",
";",
"}",
"$",
"pos1",
"=",
"$",
"match",
"[",
"$",
"num",
"-",
"1",
"]",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"pos2",
"=",
"strpos",
"(",
"$",
"gedrec",
",",
"\"\\n$level\"",
",",
"$",
"pos1",
"+",
"1",
")",
";",
"if",
"(",
"!",
"$",
"pos2",
")",
"{",
"$",
"pos2",
"=",
"strpos",
"(",
"$",
"gedrec",
",",
"\"\\n1\"",
",",
"$",
"pos1",
"+",
"1",
")",
";",
"}",
"if",
"(",
"!",
"$",
"pos2",
")",
"{",
"$",
"pos2",
"=",
"strpos",
"(",
"$",
"gedrec",
",",
"\"\\nWT_\"",
",",
"$",
"pos1",
"+",
"1",
")",
";",
"// WT_SPOUSE, WT_FAMILY_ID ...",
"}",
"if",
"(",
"!",
"$",
"pos2",
")",
"{",
"return",
"ltrim",
"(",
"substr",
"(",
"$",
"gedrec",
",",
"$",
"pos1",
")",
")",
";",
"}",
"$",
"subrec",
"=",
"substr",
"(",
"$",
"gedrec",
",",
"$",
"pos1",
",",
"$",
"pos2",
"-",
"$",
"pos1",
")",
";",
"return",
"ltrim",
"(",
"$",
"subrec",
")",
";",
"}"
] | get a gedcom subrecord
searches a gedcom record and returns a subrecord of it. A subrecord is defined starting at a
line with level N and all subsequent lines greater than N until the next N level is reached.
For example, the following is a BIRT subrecord:
<code>1 BIRT
2 DATE 1 JAN 1900
2 PLAC Phoenix, Maricopa, Arizona</code>
The following example is the DATE subrecord of the above BIRT subrecord:
<code>2 DATE 1 JAN 1900</code>
@param int $level the N level of the subrecord to get
@param string $tag a gedcom tag or string to search for in the record (ie 1 BIRT or 2 DATE)
@param string $gedrec the parent gedcom record to search in
@param int $num this allows you to specify which matching <var>$tag</var> to get. Oftentimes a
gedcom record will have more that 1 of the same type of subrecord. An individual may have
multiple events for example. Passing $num=1 would get the first 1. Passing $num=2 would get the
second one, etc.
@return string the subrecord that was found or an empty string "" if not found. | [
"get",
"a",
"gedcom",
"subrecord"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/Functions.php#L89-L119 | train |
fisharebest/webtrees | app/Functions/Functions.php | Functions.getCont | public static function getCont($nlevel, $nrec): string
{
$text = '';
$subrecords = explode("\n", $nrec);
foreach ($subrecords as $thisSubrecord) {
if (substr($thisSubrecord, 0, 2) !== $nlevel . ' ') {
continue;
}
$subrecordType = substr($thisSubrecord, 2, 4);
if ($subrecordType === 'CONT') {
$text .= "\n" . substr($thisSubrecord, 7);
}
}
return $text;
} | php | public static function getCont($nlevel, $nrec): string
{
$text = '';
$subrecords = explode("\n", $nrec);
foreach ($subrecords as $thisSubrecord) {
if (substr($thisSubrecord, 0, 2) !== $nlevel . ' ') {
continue;
}
$subrecordType = substr($thisSubrecord, 2, 4);
if ($subrecordType === 'CONT') {
$text .= "\n" . substr($thisSubrecord, 7);
}
}
return $text;
} | [
"public",
"static",
"function",
"getCont",
"(",
"$",
"nlevel",
",",
"$",
"nrec",
")",
":",
"string",
"{",
"$",
"text",
"=",
"''",
";",
"$",
"subrecords",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"nrec",
")",
";",
"foreach",
"(",
"$",
"subrecords",
"as",
"$",
"thisSubrecord",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"thisSubrecord",
",",
"0",
",",
"2",
")",
"!==",
"$",
"nlevel",
".",
"' '",
")",
"{",
"continue",
";",
"}",
"$",
"subrecordType",
"=",
"substr",
"(",
"$",
"thisSubrecord",
",",
"2",
",",
"4",
")",
";",
"if",
"(",
"$",
"subrecordType",
"===",
"'CONT'",
")",
"{",
"$",
"text",
".=",
"\"\\n\"",
".",
"substr",
"(",
"$",
"thisSubrecord",
",",
"7",
")",
";",
"}",
"}",
"return",
"$",
"text",
";",
"}"
] | get CONT lines
get the N+1 CONT or CONC lines of a gedcom subrecord
@param int $nlevel the level of the CONT lines to get
@param string $nrec the gedcom subrecord to search in
@return string a string with all CONT lines merged | [
"get",
"CONT",
"lines"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/Functions.php#L131-L147 | train |
fisharebest/webtrees | app/Functions/Functions.php | Functions.getCloseRelationshipName | public static function getCloseRelationshipName(Individual $individual1, Individual $individual2): string
{
if ($individual1 === $individual2) {
return self::reflexivePronoun($individual1);
}
try {
$relationship = self::getRelationship($individual1, $individual2);
return self::getRelationshipName($relationship);
} catch (Exception $ex) {
return '';
}
} | php | public static function getCloseRelationshipName(Individual $individual1, Individual $individual2): string
{
if ($individual1 === $individual2) {
return self::reflexivePronoun($individual1);
}
try {
$relationship = self::getRelationship($individual1, $individual2);
return self::getRelationshipName($relationship);
} catch (Exception $ex) {
return '';
}
} | [
"public",
"static",
"function",
"getCloseRelationshipName",
"(",
"Individual",
"$",
"individual1",
",",
"Individual",
"$",
"individual2",
")",
":",
"string",
"{",
"if",
"(",
"$",
"individual1",
"===",
"$",
"individual2",
")",
"{",
"return",
"self",
"::",
"reflexivePronoun",
"(",
"$",
"individual1",
")",
";",
"}",
"try",
"{",
"$",
"relationship",
"=",
"self",
"::",
"getRelationship",
"(",
"$",
"individual1",
",",
"$",
"individual2",
")",
";",
"return",
"self",
"::",
"getRelationshipName",
"(",
"$",
"relationship",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"return",
"''",
";",
"}",
"}"
] | For close family relationships, such as the families tab and the family navigator
Display a tick if both individuals are the same.
@param Individual $individual1
@param Individual $individual2
@return string | [
"For",
"close",
"family",
"relationships",
"such",
"as",
"the",
"families",
"tab",
"and",
"the",
"family",
"navigator",
"Display",
"a",
"tick",
"if",
"both",
"individuals",
"are",
"the",
"same",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/Functions.php#L158-L171 | train |
fisharebest/webtrees | app/Functions/Functions.php | Functions.reflexivePronoun | private static function reflexivePronoun(Individual $individual): string
{
switch ($individual->sex()) {
case 'M':
/* I18N: reflexive pronoun */
return I18N::translate('himself');
case 'F':
/* I18N: reflexive pronoun */
return I18N::translate('herself');
default:
/* I18N: reflexive pronoun - gender neutral version of himself/herself */
return I18N::translate('themself');
}
} | php | private static function reflexivePronoun(Individual $individual): string
{
switch ($individual->sex()) {
case 'M':
/* I18N: reflexive pronoun */
return I18N::translate('himself');
case 'F':
/* I18N: reflexive pronoun */
return I18N::translate('herself');
default:
/* I18N: reflexive pronoun - gender neutral version of himself/herself */
return I18N::translate('themself');
}
} | [
"private",
"static",
"function",
"reflexivePronoun",
"(",
"Individual",
"$",
"individual",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"individual",
"->",
"sex",
"(",
")",
")",
"{",
"case",
"'M'",
":",
"/* I18N: reflexive pronoun */",
"return",
"I18N",
"::",
"translate",
"(",
"'himself'",
")",
";",
"case",
"'F'",
":",
"/* I18N: reflexive pronoun */",
"return",
"I18N",
"::",
"translate",
"(",
"'herself'",
")",
";",
"default",
":",
"/* I18N: reflexive pronoun - gender neutral version of himself/herself */",
"return",
"I18N",
"::",
"translate",
"(",
"'themself'",
")",
";",
"}",
"}"
] | Generate a reflexive pronoun for an individual
@param Individual $individual
@return string | [
"Generate",
"a",
"reflexive",
"pronoun",
"for",
"an",
"individual"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/Functions.php#L180-L193 | train |
fisharebest/webtrees | app/Http/Controllers/EditGedcomRecordController.php | EditGedcomRecordController.deleteFact | public function deleteFact(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$xref = $request->get('xref', '');
$fact_id = $request->get('fact_id');
$record = GedcomRecord::getInstance($xref, $tree);
Auth::checkRecordAccess($record, true);
foreach ($record->facts() as $fact) {
if ($fact->id() == $fact_id && $fact->canShow() && $fact->canEdit()) {
$record->deleteFact($fact_id, true);
break;
}
}
return response();
} | php | public function deleteFact(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$xref = $request->get('xref', '');
$fact_id = $request->get('fact_id');
$record = GedcomRecord::getInstance($xref, $tree);
Auth::checkRecordAccess($record, true);
foreach ($record->facts() as $fact) {
if ($fact->id() == $fact_id && $fact->canShow() && $fact->canEdit()) {
$record->deleteFact($fact_id, true);
break;
}
}
return response();
} | [
"public",
"function",
"deleteFact",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
")",
":",
"ResponseInterface",
"{",
"$",
"xref",
"=",
"$",
"request",
"->",
"get",
"(",
"'xref'",
",",
"''",
")",
";",
"$",
"fact_id",
"=",
"$",
"request",
"->",
"get",
"(",
"'fact_id'",
")",
";",
"$",
"record",
"=",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"Auth",
"::",
"checkRecordAccess",
"(",
"$",
"record",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"record",
"->",
"facts",
"(",
")",
"as",
"$",
"fact",
")",
"{",
"if",
"(",
"$",
"fact",
"->",
"id",
"(",
")",
"==",
"$",
"fact_id",
"&&",
"$",
"fact",
"->",
"canShow",
"(",
")",
"&&",
"$",
"fact",
"->",
"canEdit",
"(",
")",
")",
"{",
"$",
"record",
"->",
"deleteFact",
"(",
"$",
"fact_id",
",",
"true",
")",
";",
"break",
";",
"}",
"}",
"return",
"response",
"(",
")",
";",
"}"
] | Delete a fact.
@param ServerRequestInterface $request
@param Tree $tree
@return ResponseInterface | [
"Delete",
"a",
"fact",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/EditGedcomRecordController.php#L95-L112 | train |
fisharebest/webtrees | app/Http/Controllers/EditGedcomRecordController.php | EditGedcomRecordController.pasteFact | public function pasteFact(ServerRequestInterface $request, Tree $tree, ClipboardService $clipboard_service): ResponseInterface
{
$xref = $request->get('xref', '');
$fact_id = $request->get('fact_id');
$record = GedcomRecord::getInstance($xref, $tree);
Auth::checkRecordAccess($record, true);
$clipboard_service->pasteFact($fact_id, $record);
return response();
} | php | public function pasteFact(ServerRequestInterface $request, Tree $tree, ClipboardService $clipboard_service): ResponseInterface
{
$xref = $request->get('xref', '');
$fact_id = $request->get('fact_id');
$record = GedcomRecord::getInstance($xref, $tree);
Auth::checkRecordAccess($record, true);
$clipboard_service->pasteFact($fact_id, $record);
return response();
} | [
"public",
"function",
"pasteFact",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
",",
"ClipboardService",
"$",
"clipboard_service",
")",
":",
"ResponseInterface",
"{",
"$",
"xref",
"=",
"$",
"request",
"->",
"get",
"(",
"'xref'",
",",
"''",
")",
";",
"$",
"fact_id",
"=",
"$",
"request",
"->",
"get",
"(",
"'fact_id'",
")",
";",
"$",
"record",
"=",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"Auth",
"::",
"checkRecordAccess",
"(",
"$",
"record",
",",
"true",
")",
";",
"$",
"clipboard_service",
"->",
"pasteFact",
"(",
"$",
"fact_id",
",",
"$",
"record",
")",
";",
"return",
"response",
"(",
")",
";",
"}"
] | Paste a fact from the clipboard into a record.
@param ServerRequestInterface $request
@param Tree $tree
@param ClipboardService $clipboard_service
@return ResponseInterface | [
"Paste",
"a",
"fact",
"from",
"the",
"clipboard",
"into",
"a",
"record",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/EditGedcomRecordController.php#L176-L188 | train |
fisharebest/webtrees | app/Statistics/Repository/MediaRepository.php | MediaRepository.totalMediaTypeQuery | private function totalMediaTypeQuery(string $type): int
{
if (($type !== self::MEDIA_TYPE_ALL)
&& ($type !== self::MEDIA_TYPE_UNKNOWN)
&& !in_array($type, self::MEDIA_TYPES, true)
) {
return 0;
}
$query = DB::table('media')
->where('m_file', '=', $this->tree->id());
if ($type !== self::MEDIA_TYPE_ALL) {
if ($type === self::MEDIA_TYPE_UNKNOWN) {
// There has to be a better way then this :(
foreach (self::MEDIA_TYPES as $t) {
// Use function to add brackets
$query->where(static function (Builder $query) use ($t): void {
$query->where('m_gedcom', 'not like', '%3 TYPE ' . $t . '%')
->where('m_gedcom', 'not like', '%1 _TYPE ' . $t . '%');
});
}
} else {
// Use function to add brackets
$query->where(static function (Builder $query) use ($type): void {
$query->where('m_gedcom', 'like', '%3 TYPE ' . $type . '%')
->orWhere('m_gedcom', 'like', '%1 _TYPE ' . $type . '%');
});
}
}
return $query->count();
} | php | private function totalMediaTypeQuery(string $type): int
{
if (($type !== self::MEDIA_TYPE_ALL)
&& ($type !== self::MEDIA_TYPE_UNKNOWN)
&& !in_array($type, self::MEDIA_TYPES, true)
) {
return 0;
}
$query = DB::table('media')
->where('m_file', '=', $this->tree->id());
if ($type !== self::MEDIA_TYPE_ALL) {
if ($type === self::MEDIA_TYPE_UNKNOWN) {
// There has to be a better way then this :(
foreach (self::MEDIA_TYPES as $t) {
// Use function to add brackets
$query->where(static function (Builder $query) use ($t): void {
$query->where('m_gedcom', 'not like', '%3 TYPE ' . $t . '%')
->where('m_gedcom', 'not like', '%1 _TYPE ' . $t . '%');
});
}
} else {
// Use function to add brackets
$query->where(static function (Builder $query) use ($type): void {
$query->where('m_gedcom', 'like', '%3 TYPE ' . $type . '%')
->orWhere('m_gedcom', 'like', '%1 _TYPE ' . $type . '%');
});
}
}
return $query->count();
} | [
"private",
"function",
"totalMediaTypeQuery",
"(",
"string",
"$",
"type",
")",
":",
"int",
"{",
"if",
"(",
"(",
"$",
"type",
"!==",
"self",
"::",
"MEDIA_TYPE_ALL",
")",
"&&",
"(",
"$",
"type",
"!==",
"self",
"::",
"MEDIA_TYPE_UNKNOWN",
")",
"&&",
"!",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"MEDIA_TYPES",
",",
"true",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'media'",
")",
"->",
"where",
"(",
"'m_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
";",
"if",
"(",
"$",
"type",
"!==",
"self",
"::",
"MEDIA_TYPE_ALL",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"self",
"::",
"MEDIA_TYPE_UNKNOWN",
")",
"{",
"// There has to be a better way then this :(",
"foreach",
"(",
"self",
"::",
"MEDIA_TYPES",
"as",
"$",
"t",
")",
"{",
"// Use function to add brackets",
"$",
"query",
"->",
"where",
"(",
"static",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"t",
")",
":",
"void",
"{",
"$",
"query",
"->",
"where",
"(",
"'m_gedcom'",
",",
"'not like'",
",",
"'%3 TYPE '",
".",
"$",
"t",
".",
"'%'",
")",
"->",
"where",
"(",
"'m_gedcom'",
",",
"'not like'",
",",
"'%1 _TYPE '",
".",
"$",
"t",
".",
"'%'",
")",
";",
"}",
")",
";",
"}",
"}",
"else",
"{",
"// Use function to add brackets",
"$",
"query",
"->",
"where",
"(",
"static",
"function",
"(",
"Builder",
"$",
"query",
")",
"use",
"(",
"$",
"type",
")",
":",
"void",
"{",
"$",
"query",
"->",
"where",
"(",
"'m_gedcom'",
",",
"'like'",
",",
"'%3 TYPE '",
".",
"$",
"type",
".",
"'%'",
")",
"->",
"orWhere",
"(",
"'m_gedcom'",
",",
"'like'",
",",
"'%1 _TYPE '",
".",
"$",
"type",
".",
"'%'",
")",
";",
"}",
")",
";",
"}",
"}",
"return",
"$",
"query",
"->",
"count",
"(",
")",
";",
"}"
] | Returns the number of media records of the given type.
@param string $type The media type to query
@return int | [
"Returns",
"the",
"number",
"of",
"media",
"records",
"of",
"the",
"given",
"type",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/MediaRepository.php#L107-L139 | train |
fisharebest/webtrees | app/Statistics/Repository/MediaRepository.php | MediaRepository.getSortedMediaTypeList | private function getSortedMediaTypeList(int $tot): array
{
$media = [];
$c = 0;
$max = 0;
foreach (self::MEDIA_TYPES as $type) {
$count = $this->totalMediaTypeQuery($type);
if ($count > 0) {
$media[$type] = $count;
if ($count > $max) {
$max = $count;
}
$c += $count;
}
}
$count = $this->totalMediaTypeQuery(self::MEDIA_TYPE_UNKNOWN);
if ($count > 0) {
$media[self::MEDIA_TYPE_UNKNOWN] = $tot - $c;
if ($tot - $c > $max) {
$max = $count;
}
}
if (count($media) > 10 && ($max / $tot) > 0.6) {
arsort($media);
$media = array_slice($media, 0, 10);
$c = $tot;
foreach ($media as $cm) {
$c -= $cm;
}
if (isset($media[self::MEDIA_TYPE_OTHER])) {
$media[self::MEDIA_TYPE_OTHER] += $c;
} else {
$media[self::MEDIA_TYPE_OTHER] = $c;
}
}
asort($media);
return $media;
} | php | private function getSortedMediaTypeList(int $tot): array
{
$media = [];
$c = 0;
$max = 0;
foreach (self::MEDIA_TYPES as $type) {
$count = $this->totalMediaTypeQuery($type);
if ($count > 0) {
$media[$type] = $count;
if ($count > $max) {
$max = $count;
}
$c += $count;
}
}
$count = $this->totalMediaTypeQuery(self::MEDIA_TYPE_UNKNOWN);
if ($count > 0) {
$media[self::MEDIA_TYPE_UNKNOWN] = $tot - $c;
if ($tot - $c > $max) {
$max = $count;
}
}
if (count($media) > 10 && ($max / $tot) > 0.6) {
arsort($media);
$media = array_slice($media, 0, 10);
$c = $tot;
foreach ($media as $cm) {
$c -= $cm;
}
if (isset($media[self::MEDIA_TYPE_OTHER])) {
$media[self::MEDIA_TYPE_OTHER] += $c;
} else {
$media[self::MEDIA_TYPE_OTHER] = $c;
}
}
asort($media);
return $media;
} | [
"private",
"function",
"getSortedMediaTypeList",
"(",
"int",
"$",
"tot",
")",
":",
"array",
"{",
"$",
"media",
"=",
"[",
"]",
";",
"$",
"c",
"=",
"0",
";",
"$",
"max",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"MEDIA_TYPES",
"as",
"$",
"type",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"totalMediaTypeQuery",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"media",
"[",
"$",
"type",
"]",
"=",
"$",
"count",
";",
"if",
"(",
"$",
"count",
">",
"$",
"max",
")",
"{",
"$",
"max",
"=",
"$",
"count",
";",
"}",
"$",
"c",
"+=",
"$",
"count",
";",
"}",
"}",
"$",
"count",
"=",
"$",
"this",
"->",
"totalMediaTypeQuery",
"(",
"self",
"::",
"MEDIA_TYPE_UNKNOWN",
")",
";",
"if",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"media",
"[",
"self",
"::",
"MEDIA_TYPE_UNKNOWN",
"]",
"=",
"$",
"tot",
"-",
"$",
"c",
";",
"if",
"(",
"$",
"tot",
"-",
"$",
"c",
">",
"$",
"max",
")",
"{",
"$",
"max",
"=",
"$",
"count",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"media",
")",
">",
"10",
"&&",
"(",
"$",
"max",
"/",
"$",
"tot",
")",
">",
"0.6",
")",
"{",
"arsort",
"(",
"$",
"media",
")",
";",
"$",
"media",
"=",
"array_slice",
"(",
"$",
"media",
",",
"0",
",",
"10",
")",
";",
"$",
"c",
"=",
"$",
"tot",
";",
"foreach",
"(",
"$",
"media",
"as",
"$",
"cm",
")",
"{",
"$",
"c",
"-=",
"$",
"cm",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"media",
"[",
"self",
"::",
"MEDIA_TYPE_OTHER",
"]",
")",
")",
"{",
"$",
"media",
"[",
"self",
"::",
"MEDIA_TYPE_OTHER",
"]",
"+=",
"$",
"c",
";",
"}",
"else",
"{",
"$",
"media",
"[",
"self",
"::",
"MEDIA_TYPE_OTHER",
"]",
"=",
"$",
"c",
";",
"}",
"}",
"asort",
"(",
"$",
"media",
")",
";",
"return",
"$",
"media",
";",
"}"
] | Returns a sorted list of media types and their total counts.
@param int $tot The total number of media files
@return array | [
"Returns",
"a",
"sorted",
"list",
"of",
"media",
"types",
"and",
"their",
"total",
"counts",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/MediaRepository.php#L308-L355 | train |
fisharebest/webtrees | app/Http/Controllers/IndividualController.php | IndividualController.formatSexRecord | private function formatSexRecord(Fact $fact): string
{
$individual = $fact->record();
switch ($fact->value()) {
case 'M':
$sex = I18N::translate('Male');
break;
case 'F':
$sex = I18N::translate('Female');
break;
default:
$sex = I18N::translateContext('unknown gender', 'Unknown');
break;
}
$container_class = 'card';
if ($fact->isPendingDeletion()) {
$container_class .= ' old';
} elseif ($fact->isPendingAddition()) {
$container_class .= ' new';
}
if ($individual->canEdit()) {
$edit_links = '<a class="btn btn-link" href="' . e(route('edit-fact', ['xref' => $individual->xref(), 'fact_id' => $fact->id(), 'ged' => $individual->tree()->name()])) . '" title="' . I18N::translate('Edit the gender') . '">' . view('icons/edit') . '<span class="sr-only">' . I18N::translate('Edit the gender') . '</span></a>';
} else {
$edit_links = '';
}
return '
<div class="' . $container_class . '">
<div class="card-header" role="tab" id="name-header-add">
<div class="card-title mb-0">
<b>' . I18N::translate('Gender') . '</b> ' . $sex . $edit_links . '
</div>
</div>
</div>';
} | php | private function formatSexRecord(Fact $fact): string
{
$individual = $fact->record();
switch ($fact->value()) {
case 'M':
$sex = I18N::translate('Male');
break;
case 'F':
$sex = I18N::translate('Female');
break;
default:
$sex = I18N::translateContext('unknown gender', 'Unknown');
break;
}
$container_class = 'card';
if ($fact->isPendingDeletion()) {
$container_class .= ' old';
} elseif ($fact->isPendingAddition()) {
$container_class .= ' new';
}
if ($individual->canEdit()) {
$edit_links = '<a class="btn btn-link" href="' . e(route('edit-fact', ['xref' => $individual->xref(), 'fact_id' => $fact->id(), 'ged' => $individual->tree()->name()])) . '" title="' . I18N::translate('Edit the gender') . '">' . view('icons/edit') . '<span class="sr-only">' . I18N::translate('Edit the gender') . '</span></a>';
} else {
$edit_links = '';
}
return '
<div class="' . $container_class . '">
<div class="card-header" role="tab" id="name-header-add">
<div class="card-title mb-0">
<b>' . I18N::translate('Gender') . '</b> ' . $sex . $edit_links . '
</div>
</div>
</div>';
} | [
"private",
"function",
"formatSexRecord",
"(",
"Fact",
"$",
"fact",
")",
":",
"string",
"{",
"$",
"individual",
"=",
"$",
"fact",
"->",
"record",
"(",
")",
";",
"switch",
"(",
"$",
"fact",
"->",
"value",
"(",
")",
")",
"{",
"case",
"'M'",
":",
"$",
"sex",
"=",
"I18N",
"::",
"translate",
"(",
"'Male'",
")",
";",
"break",
";",
"case",
"'F'",
":",
"$",
"sex",
"=",
"I18N",
"::",
"translate",
"(",
"'Female'",
")",
";",
"break",
";",
"default",
":",
"$",
"sex",
"=",
"I18N",
"::",
"translateContext",
"(",
"'unknown gender'",
",",
"'Unknown'",
")",
";",
"break",
";",
"}",
"$",
"container_class",
"=",
"'card'",
";",
"if",
"(",
"$",
"fact",
"->",
"isPendingDeletion",
"(",
")",
")",
"{",
"$",
"container_class",
".=",
"' old'",
";",
"}",
"elseif",
"(",
"$",
"fact",
"->",
"isPendingAddition",
"(",
")",
")",
"{",
"$",
"container_class",
".=",
"' new'",
";",
"}",
"if",
"(",
"$",
"individual",
"->",
"canEdit",
"(",
")",
")",
"{",
"$",
"edit_links",
"=",
"'<a class=\"btn btn-link\" href=\"'",
".",
"e",
"(",
"route",
"(",
"'edit-fact'",
",",
"[",
"'xref'",
"=>",
"$",
"individual",
"->",
"xref",
"(",
")",
",",
"'fact_id'",
"=>",
"$",
"fact",
"->",
"id",
"(",
")",
",",
"'ged'",
"=>",
"$",
"individual",
"->",
"tree",
"(",
")",
"->",
"name",
"(",
")",
"]",
")",
")",
".",
"'\" title=\"'",
".",
"I18N",
"::",
"translate",
"(",
"'Edit the gender'",
")",
".",
"'\">'",
".",
"view",
"(",
"'icons/edit'",
")",
".",
"'<span class=\"sr-only\">'",
".",
"I18N",
"::",
"translate",
"(",
"'Edit the gender'",
")",
".",
"'</span></a>'",
";",
"}",
"else",
"{",
"$",
"edit_links",
"=",
"''",
";",
"}",
"return",
"'\n\t\t<div class=\"'",
".",
"$",
"container_class",
".",
"'\">\n\t\t\t<div class=\"card-header\" role=\"tab\" id=\"name-header-add\">\n\t\t\t\t<div class=\"card-title mb-0\">\n\t\t\t\t\t<b>'",
".",
"I18N",
"::",
"translate",
"(",
"'Gender'",
")",
".",
"'</b> '",
".",
"$",
"sex",
".",
"$",
"edit_links",
".",
"'\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>'",
";",
"}"
] | print information for a sex record
@param Fact $fact
@return string | [
"print",
"information",
"for",
"a",
"sex",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/IndividualController.php#L296-L333 | train |
fisharebest/webtrees | app/Report/ReportHtmlText.php | ReportHtmlText.getWidth | public function getWidth($renderer)
{
// Setup the style name, a font must be selected to calculate the width
if ($renderer->getCurrentStyle() != $this->styleName) {
$renderer->setCurrentStyle($this->styleName);
}
// Check for the largest font size in the box
$fsize = $renderer->getCurrentStyleHeight();
if ($fsize > $renderer->largestFontHeight) {
$renderer->largestFontHeight = $fsize;
}
// Get the line width for the text in points
$lw = $renderer->getStringWidth($this->text);
// Line Feed counter - Number of lines in the text
$lfct = $renderer->countLines($this->text);
// If there is still remaining wrap width...
$wrapWidthRemaining = $this->wrapWidthRemaining;
if ($wrapWidthRemaining > 0) {
// Check with line counter too!
if ($lw >= $wrapWidthRemaining || $lfct > 1) {
$newtext = '';
$lines = explode("\n", $this->text);
// Go throught the text line by line
foreach ($lines as $line) {
// Line width in points + a little margin
$lw = $renderer->getStringWidth($line);
// If the line has to be wraped
if ($lw > $wrapWidthRemaining) {
$words = explode(' ', $line);
$addspace = count($words);
$lw = 0;
foreach ($words as $word) {
$addspace--;
$lw += $renderer->getStringWidth($word . ' ');
if ($lw <= $wrapWidthRemaining) {
$newtext .= $word;
if ($addspace != 0) {
$newtext .= ' ';
}
} else {
$lw = $renderer->getStringWidth($word . ' ');
$newtext .= "\n$word";
if ($addspace != 0) {
$newtext .= ' ';
}
// Reset the wrap width to the cell width
$wrapWidthRemaining = $this->wrapWidthCell;
}
}
} else {
$newtext .= $line;
}
// Check the Line Feed counter
if ($lfct > 1) {
// Add a new line as long as it’s not the last line
$newtext .= "\n";
// Reset the line width
$lw = 0;
// Reset the wrap width to the cell width
$wrapWidthRemaining = $this->wrapWidthCell;
}
$lfct--;
}
$this->text = $newtext;
$lfct = substr_count($this->text, "\n");
return [
$lw,
1,
$lfct,
];
}
}
$l = 0;
$lfct = substr_count($this->text, "\n");
if ($lfct > 0) {
$l = 2;
}
return [
$lw,
$l,
$lfct,
];
} | php | public function getWidth($renderer)
{
// Setup the style name, a font must be selected to calculate the width
if ($renderer->getCurrentStyle() != $this->styleName) {
$renderer->setCurrentStyle($this->styleName);
}
// Check for the largest font size in the box
$fsize = $renderer->getCurrentStyleHeight();
if ($fsize > $renderer->largestFontHeight) {
$renderer->largestFontHeight = $fsize;
}
// Get the line width for the text in points
$lw = $renderer->getStringWidth($this->text);
// Line Feed counter - Number of lines in the text
$lfct = $renderer->countLines($this->text);
// If there is still remaining wrap width...
$wrapWidthRemaining = $this->wrapWidthRemaining;
if ($wrapWidthRemaining > 0) {
// Check with line counter too!
if ($lw >= $wrapWidthRemaining || $lfct > 1) {
$newtext = '';
$lines = explode("\n", $this->text);
// Go throught the text line by line
foreach ($lines as $line) {
// Line width in points + a little margin
$lw = $renderer->getStringWidth($line);
// If the line has to be wraped
if ($lw > $wrapWidthRemaining) {
$words = explode(' ', $line);
$addspace = count($words);
$lw = 0;
foreach ($words as $word) {
$addspace--;
$lw += $renderer->getStringWidth($word . ' ');
if ($lw <= $wrapWidthRemaining) {
$newtext .= $word;
if ($addspace != 0) {
$newtext .= ' ';
}
} else {
$lw = $renderer->getStringWidth($word . ' ');
$newtext .= "\n$word";
if ($addspace != 0) {
$newtext .= ' ';
}
// Reset the wrap width to the cell width
$wrapWidthRemaining = $this->wrapWidthCell;
}
}
} else {
$newtext .= $line;
}
// Check the Line Feed counter
if ($lfct > 1) {
// Add a new line as long as it’s not the last line
$newtext .= "\n";
// Reset the line width
$lw = 0;
// Reset the wrap width to the cell width
$wrapWidthRemaining = $this->wrapWidthCell;
}
$lfct--;
}
$this->text = $newtext;
$lfct = substr_count($this->text, "\n");
return [
$lw,
1,
$lfct,
];
}
}
$l = 0;
$lfct = substr_count($this->text, "\n");
if ($lfct > 0) {
$l = 2;
}
return [
$lw,
$l,
$lfct,
];
} | [
"public",
"function",
"getWidth",
"(",
"$",
"renderer",
")",
"{",
"// Setup the style name, a font must be selected to calculate the width",
"if",
"(",
"$",
"renderer",
"->",
"getCurrentStyle",
"(",
")",
"!=",
"$",
"this",
"->",
"styleName",
")",
"{",
"$",
"renderer",
"->",
"setCurrentStyle",
"(",
"$",
"this",
"->",
"styleName",
")",
";",
"}",
"// Check for the largest font size in the box",
"$",
"fsize",
"=",
"$",
"renderer",
"->",
"getCurrentStyleHeight",
"(",
")",
";",
"if",
"(",
"$",
"fsize",
">",
"$",
"renderer",
"->",
"largestFontHeight",
")",
"{",
"$",
"renderer",
"->",
"largestFontHeight",
"=",
"$",
"fsize",
";",
"}",
"// Get the line width for the text in points",
"$",
"lw",
"=",
"$",
"renderer",
"->",
"getStringWidth",
"(",
"$",
"this",
"->",
"text",
")",
";",
"// Line Feed counter - Number of lines in the text",
"$",
"lfct",
"=",
"$",
"renderer",
"->",
"countLines",
"(",
"$",
"this",
"->",
"text",
")",
";",
"// If there is still remaining wrap width...",
"$",
"wrapWidthRemaining",
"=",
"$",
"this",
"->",
"wrapWidthRemaining",
";",
"if",
"(",
"$",
"wrapWidthRemaining",
">",
"0",
")",
"{",
"// Check with line counter too!",
"if",
"(",
"$",
"lw",
">=",
"$",
"wrapWidthRemaining",
"||",
"$",
"lfct",
">",
"1",
")",
"{",
"$",
"newtext",
"=",
"''",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"text",
")",
";",
"// Go throught the text line by line",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"// Line width in points + a little margin",
"$",
"lw",
"=",
"$",
"renderer",
"->",
"getStringWidth",
"(",
"$",
"line",
")",
";",
"// If the line has to be wraped",
"if",
"(",
"$",
"lw",
">",
"$",
"wrapWidthRemaining",
")",
"{",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"line",
")",
";",
"$",
"addspace",
"=",
"count",
"(",
"$",
"words",
")",
";",
"$",
"lw",
"=",
"0",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"$",
"addspace",
"--",
";",
"$",
"lw",
"+=",
"$",
"renderer",
"->",
"getStringWidth",
"(",
"$",
"word",
".",
"' '",
")",
";",
"if",
"(",
"$",
"lw",
"<=",
"$",
"wrapWidthRemaining",
")",
"{",
"$",
"newtext",
".=",
"$",
"word",
";",
"if",
"(",
"$",
"addspace",
"!=",
"0",
")",
"{",
"$",
"newtext",
".=",
"' '",
";",
"}",
"}",
"else",
"{",
"$",
"lw",
"=",
"$",
"renderer",
"->",
"getStringWidth",
"(",
"$",
"word",
".",
"' '",
")",
";",
"$",
"newtext",
".=",
"\"\\n$word\"",
";",
"if",
"(",
"$",
"addspace",
"!=",
"0",
")",
"{",
"$",
"newtext",
".=",
"' '",
";",
"}",
"// Reset the wrap width to the cell width",
"$",
"wrapWidthRemaining",
"=",
"$",
"this",
"->",
"wrapWidthCell",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"newtext",
".=",
"$",
"line",
";",
"}",
"// Check the Line Feed counter",
"if",
"(",
"$",
"lfct",
">",
"1",
")",
"{",
"// Add a new line as long as it’s not the last line",
"$",
"newtext",
".=",
"\"\\n\"",
";",
"// Reset the line width",
"$",
"lw",
"=",
"0",
";",
"// Reset the wrap width to the cell width",
"$",
"wrapWidthRemaining",
"=",
"$",
"this",
"->",
"wrapWidthCell",
";",
"}",
"$",
"lfct",
"--",
";",
"}",
"$",
"this",
"->",
"text",
"=",
"$",
"newtext",
";",
"$",
"lfct",
"=",
"substr_count",
"(",
"$",
"this",
"->",
"text",
",",
"\"\\n\"",
")",
";",
"return",
"[",
"$",
"lw",
",",
"1",
",",
"$",
"lfct",
",",
"]",
";",
"}",
"}",
"$",
"l",
"=",
"0",
";",
"$",
"lfct",
"=",
"substr_count",
"(",
"$",
"this",
"->",
"text",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"lfct",
">",
"0",
")",
"{",
"$",
"l",
"=",
"2",
";",
"}",
"return",
"[",
"$",
"lw",
",",
"$",
"l",
",",
"$",
"lfct",
",",
"]",
";",
"}"
] | Get the width of text and wrap it too
@param ReportHtml $renderer
@return float|array | [
"Get",
"the",
"width",
"of",
"text",
"and",
"wrap",
"it",
"too"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtmlText.php#L110-L196 | train |
fisharebest/webtrees | app/Services/TimeoutService.php | TimeoutService.isTimeNearlyUp | public function isTimeNearlyUp(float $threshold = self::TIME_UP_THRESHOLD): bool
{
$max_execution_time = (int) ini_get('max_execution_time');
// If there's no time limit, then we can't run out of time.
if ($max_execution_time === 0) {
return false;
}
$now = microtime(true);
return $now + $threshold > $this->start_time + (float) $max_execution_time;
} | php | public function isTimeNearlyUp(float $threshold = self::TIME_UP_THRESHOLD): bool
{
$max_execution_time = (int) ini_get('max_execution_time');
// If there's no time limit, then we can't run out of time.
if ($max_execution_time === 0) {
return false;
}
$now = microtime(true);
return $now + $threshold > $this->start_time + (float) $max_execution_time;
} | [
"public",
"function",
"isTimeNearlyUp",
"(",
"float",
"$",
"threshold",
"=",
"self",
"::",
"TIME_UP_THRESHOLD",
")",
":",
"bool",
"{",
"$",
"max_execution_time",
"=",
"(",
"int",
")",
"ini_get",
"(",
"'max_execution_time'",
")",
";",
"// If there's no time limit, then we can't run out of time.",
"if",
"(",
"$",
"max_execution_time",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"now",
"=",
"microtime",
"(",
"true",
")",
";",
"return",
"$",
"now",
"+",
"$",
"threshold",
">",
"$",
"this",
"->",
"start_time",
"+",
"(",
"float",
")",
"$",
"max_execution_time",
";",
"}"
] | Some long-running scripts need to know when to stop.
@param float $threshold
@return bool | [
"Some",
"long",
"-",
"running",
"scripts",
"need",
"to",
"know",
"when",
"to",
"stop",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/TimeoutService.php#L54-L66 | train |
fisharebest/webtrees | app/Services/TimeoutService.php | TimeoutService.isTimeLimitUp | public function isTimeLimitUp(float $limit = self::TIME_LIMIT): bool
{
$now = microtime(true);
return $now > $this->start_time + $limit;
} | php | public function isTimeLimitUp(float $limit = self::TIME_LIMIT): bool
{
$now = microtime(true);
return $now > $this->start_time + $limit;
} | [
"public",
"function",
"isTimeLimitUp",
"(",
"float",
"$",
"limit",
"=",
"self",
"::",
"TIME_LIMIT",
")",
":",
"bool",
"{",
"$",
"now",
"=",
"microtime",
"(",
"true",
")",
";",
"return",
"$",
"now",
">",
"$",
"this",
"->",
"start_time",
"+",
"$",
"limit",
";",
"}"
] | Some long running scripts are broken down into small chunks.
@param float $limit
@return bool | [
"Some",
"long",
"running",
"scripts",
"are",
"broken",
"down",
"into",
"small",
"chunks",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/TimeoutService.php#L75-L80 | train |
fisharebest/webtrees | app/I18N.php | I18N.activeLocales | public static function activeLocales(): array
{
$locales = app(ModuleService::class)
->findByInterface(ModuleLanguageInterface::class, false, true)
->map(static function (ModuleLanguageInterface $module): LocaleInterface {
return $module->locale();
});
if ($locales->isEmpty()) {
return [new LocaleEnUs()];
}
return $locales->all();
} | php | public static function activeLocales(): array
{
$locales = app(ModuleService::class)
->findByInterface(ModuleLanguageInterface::class, false, true)
->map(static function (ModuleLanguageInterface $module): LocaleInterface {
return $module->locale();
});
if ($locales->isEmpty()) {
return [new LocaleEnUs()];
}
return $locales->all();
} | [
"public",
"static",
"function",
"activeLocales",
"(",
")",
":",
"array",
"{",
"$",
"locales",
"=",
"app",
"(",
"ModuleService",
"::",
"class",
")",
"->",
"findByInterface",
"(",
"ModuleLanguageInterface",
"::",
"class",
",",
"false",
",",
"true",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"ModuleLanguageInterface",
"$",
"module",
")",
":",
"LocaleInterface",
"{",
"return",
"$",
"module",
"->",
"locale",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"$",
"locales",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"[",
"new",
"LocaleEnUs",
"(",
")",
"]",
";",
"}",
"return",
"$",
"locales",
"->",
"all",
"(",
")",
";",
"}"
] | The preferred locales for this site, or a default list if no preference.
@return LocaleInterface[] | [
"The",
"preferred",
"locales",
"for",
"this",
"site",
"or",
"a",
"default",
"list",
"if",
"no",
"preference",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L216-L229 | train |
fisharebest/webtrees | app/I18N.php | I18N.installedLocales | public static function installedLocales(): Collection
{
return app(ModuleService::class)
->findByInterface(ModuleLanguageInterface::class, true)
->map(static function (ModuleLanguageInterface $module): LocaleInterface {
return $module->locale();
});
} | php | public static function installedLocales(): Collection
{
return app(ModuleService::class)
->findByInterface(ModuleLanguageInterface::class, true)
->map(static function (ModuleLanguageInterface $module): LocaleInterface {
return $module->locale();
});
} | [
"public",
"static",
"function",
"installedLocales",
"(",
")",
":",
"Collection",
"{",
"return",
"app",
"(",
"ModuleService",
"::",
"class",
")",
"->",
"findByInterface",
"(",
"ModuleLanguageInterface",
"::",
"class",
",",
"true",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"ModuleLanguageInterface",
"$",
"module",
")",
":",
"LocaleInterface",
"{",
"return",
"$",
"module",
"->",
"locale",
"(",
")",
";",
"}",
")",
";",
"}"
] | All locales for which a translation file exists.
@return Collection
@return LocaleInterface[] | [
"All",
"locales",
"for",
"which",
"a",
"translation",
"file",
"exists",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L407-L414 | train |
fisharebest/webtrees | app/I18N.php | I18N.strcasecmp | public static function strcasecmp($string1, $string2): int
{
if (self::$collator instanceof Collator) {
return self::$collator->compare($string1, $string2);
}
return strcmp(self::strtolower($string1), self::strtolower($string2));
} | php | public static function strcasecmp($string1, $string2): int
{
if (self::$collator instanceof Collator) {
return self::$collator->compare($string1, $string2);
}
return strcmp(self::strtolower($string1), self::strtolower($string2));
} | [
"public",
"static",
"function",
"strcasecmp",
"(",
"$",
"string1",
",",
"$",
"string2",
")",
":",
"int",
"{",
"if",
"(",
"self",
"::",
"$",
"collator",
"instanceof",
"Collator",
")",
"{",
"return",
"self",
"::",
"$",
"collator",
"->",
"compare",
"(",
"$",
"string1",
",",
"$",
"string2",
")",
";",
"}",
"return",
"strcmp",
"(",
"self",
"::",
"strtolower",
"(",
"$",
"string1",
")",
",",
"self",
"::",
"strtolower",
"(",
"$",
"string2",
")",
")",
";",
"}"
] | Perform a case-insensitive comparison of two strings.
@param string $string1
@param string $string2
@return int | [
"Perform",
"a",
"case",
"-",
"insensitive",
"comparison",
"of",
"two",
"strings",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L566-L573 | train |
fisharebest/webtrees | app/I18N.php | I18N.strtolower | public static function strtolower($string): string
{
if (in_array(self::$locale->language()->code(), self::DOTLESS_I_LOCALES, true)) {
$string = strtr($string, self::DOTLESS_I_TOLOWER);
}
return mb_strtolower($string);
} | php | public static function strtolower($string): string
{
if (in_array(self::$locale->language()->code(), self::DOTLESS_I_LOCALES, true)) {
$string = strtr($string, self::DOTLESS_I_TOLOWER);
}
return mb_strtolower($string);
} | [
"public",
"static",
"function",
"strtolower",
"(",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"$",
"locale",
"->",
"language",
"(",
")",
"->",
"code",
"(",
")",
",",
"self",
"::",
"DOTLESS_I_LOCALES",
",",
"true",
")",
")",
"{",
"$",
"string",
"=",
"strtr",
"(",
"$",
"string",
",",
"self",
"::",
"DOTLESS_I_TOLOWER",
")",
";",
"}",
"return",
"mb_strtolower",
"(",
"$",
"string",
")",
";",
"}"
] | Convert a string to lower case.
@param string $string
@return string | [
"Convert",
"a",
"string",
"to",
"lower",
"case",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L582-L589 | train |
fisharebest/webtrees | app/I18N.php | I18N.strtoupper | public static function strtoupper($string): string
{
if (in_array(self::$locale->language()->code(), self::DOTLESS_I_LOCALES, true)) {
$string = strtr($string, self::DOTLESS_I_TOUPPER);
}
return mb_strtoupper($string);
} | php | public static function strtoupper($string): string
{
if (in_array(self::$locale->language()->code(), self::DOTLESS_I_LOCALES, true)) {
$string = strtr($string, self::DOTLESS_I_TOUPPER);
}
return mb_strtoupper($string);
} | [
"public",
"static",
"function",
"strtoupper",
"(",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"in_array",
"(",
"self",
"::",
"$",
"locale",
"->",
"language",
"(",
")",
"->",
"code",
"(",
")",
",",
"self",
"::",
"DOTLESS_I_LOCALES",
",",
"true",
")",
")",
"{",
"$",
"string",
"=",
"strtr",
"(",
"$",
"string",
",",
"self",
"::",
"DOTLESS_I_TOUPPER",
")",
";",
"}",
"return",
"mb_strtoupper",
"(",
"$",
"string",
")",
";",
"}"
] | Convert a string to upper case.
@param string $string
@return string | [
"Convert",
"a",
"string",
"to",
"upper",
"case",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L598-L605 | train |
fisharebest/webtrees | app/I18N.php | I18N.textScript | public static function textScript($string): string
{
$string = strip_tags($string); // otherwise HTML tags show up as latin
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); // otherwise HTML entities show up as latin
$string = str_replace([
'@N.N.',
'@P.N.',
], '', $string); // otherwise unknown names show up as latin
$pos = 0;
$strlen = strlen($string);
while ($pos < $strlen) {
// get the Unicode Code Point for the character at position $pos
$byte1 = ord($string[$pos]);
if ($byte1 < 0x80) {
$code_point = $byte1;
$chrlen = 1;
} elseif ($byte1 < 0xC0) {
// Invalid continuation character
return 'Latn';
} elseif ($byte1 < 0xE0) {
$code_point = (($byte1 & 0x1F) << 6) + (ord($string[$pos + 1]) & 0x3F);
$chrlen = 2;
} elseif ($byte1 < 0xF0) {
$code_point = (($byte1 & 0x0F) << 12) + ((ord($string[$pos + 1]) & 0x3F) << 6) + (ord($string[$pos + 2]) & 0x3F);
$chrlen = 3;
} elseif ($byte1 < 0xF8) {
$code_point = (($byte1 & 0x07) << 24) + ((ord($string[$pos + 1]) & 0x3F) << 12) + ((ord($string[$pos + 2]) & 0x3F) << 6) + (ord($string[$pos + 3]) & 0x3F);
$chrlen = 3;
} else {
// Invalid UTF
return 'Latn';
}
foreach (self::SCRIPT_CHARACTER_RANGES as $range) {
if ($code_point >= $range[1] && $code_point <= $range[2]) {
return $range[0];
}
}
// Not a recognised script. Maybe punctuation, spacing, etc. Keep looking.
$pos += $chrlen;
}
return 'Latn';
} | php | public static function textScript($string): string
{
$string = strip_tags($string); // otherwise HTML tags show up as latin
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); // otherwise HTML entities show up as latin
$string = str_replace([
'@N.N.',
'@P.N.',
], '', $string); // otherwise unknown names show up as latin
$pos = 0;
$strlen = strlen($string);
while ($pos < $strlen) {
// get the Unicode Code Point for the character at position $pos
$byte1 = ord($string[$pos]);
if ($byte1 < 0x80) {
$code_point = $byte1;
$chrlen = 1;
} elseif ($byte1 < 0xC0) {
// Invalid continuation character
return 'Latn';
} elseif ($byte1 < 0xE0) {
$code_point = (($byte1 & 0x1F) << 6) + (ord($string[$pos + 1]) & 0x3F);
$chrlen = 2;
} elseif ($byte1 < 0xF0) {
$code_point = (($byte1 & 0x0F) << 12) + ((ord($string[$pos + 1]) & 0x3F) << 6) + (ord($string[$pos + 2]) & 0x3F);
$chrlen = 3;
} elseif ($byte1 < 0xF8) {
$code_point = (($byte1 & 0x07) << 24) + ((ord($string[$pos + 1]) & 0x3F) << 12) + ((ord($string[$pos + 2]) & 0x3F) << 6) + (ord($string[$pos + 3]) & 0x3F);
$chrlen = 3;
} else {
// Invalid UTF
return 'Latn';
}
foreach (self::SCRIPT_CHARACTER_RANGES as $range) {
if ($code_point >= $range[1] && $code_point <= $range[2]) {
return $range[0];
}
}
// Not a recognised script. Maybe punctuation, spacing, etc. Keep looking.
$pos += $chrlen;
}
return 'Latn';
} | [
"public",
"static",
"function",
"textScript",
"(",
"$",
"string",
")",
":",
"string",
"{",
"$",
"string",
"=",
"strip_tags",
"(",
"$",
"string",
")",
";",
"// otherwise HTML tags show up as latin",
"$",
"string",
"=",
"html_entity_decode",
"(",
"$",
"string",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
";",
"// otherwise HTML entities show up as latin",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"'@N.N.'",
",",
"'@P.N.'",
",",
"]",
",",
"''",
",",
"$",
"string",
")",
";",
"// otherwise unknown names show up as latin",
"$",
"pos",
"=",
"0",
";",
"$",
"strlen",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"while",
"(",
"$",
"pos",
"<",
"$",
"strlen",
")",
"{",
"// get the Unicode Code Point for the character at position $pos",
"$",
"byte1",
"=",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"]",
")",
";",
"if",
"(",
"$",
"byte1",
"<",
"0x80",
")",
"{",
"$",
"code_point",
"=",
"$",
"byte1",
";",
"$",
"chrlen",
"=",
"1",
";",
"}",
"elseif",
"(",
"$",
"byte1",
"<",
"0xC0",
")",
"{",
"// Invalid continuation character",
"return",
"'Latn'",
";",
"}",
"elseif",
"(",
"$",
"byte1",
"<",
"0xE0",
")",
"{",
"$",
"code_point",
"=",
"(",
"(",
"$",
"byte1",
"&",
"0x1F",
")",
"<<",
"6",
")",
"+",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"1",
"]",
")",
"&",
"0x3F",
")",
";",
"$",
"chrlen",
"=",
"2",
";",
"}",
"elseif",
"(",
"$",
"byte1",
"<",
"0xF0",
")",
"{",
"$",
"code_point",
"=",
"(",
"(",
"$",
"byte1",
"&",
"0x0F",
")",
"<<",
"12",
")",
"+",
"(",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"1",
"]",
")",
"&",
"0x3F",
")",
"<<",
"6",
")",
"+",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"2",
"]",
")",
"&",
"0x3F",
")",
";",
"$",
"chrlen",
"=",
"3",
";",
"}",
"elseif",
"(",
"$",
"byte1",
"<",
"0xF8",
")",
"{",
"$",
"code_point",
"=",
"(",
"(",
"$",
"byte1",
"&",
"0x07",
")",
"<<",
"24",
")",
"+",
"(",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"1",
"]",
")",
"&",
"0x3F",
")",
"<<",
"12",
")",
"+",
"(",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"2",
"]",
")",
"&",
"0x3F",
")",
"<<",
"6",
")",
"+",
"(",
"ord",
"(",
"$",
"string",
"[",
"$",
"pos",
"+",
"3",
"]",
")",
"&",
"0x3F",
")",
";",
"$",
"chrlen",
"=",
"3",
";",
"}",
"else",
"{",
"// Invalid UTF",
"return",
"'Latn'",
";",
"}",
"foreach",
"(",
"self",
"::",
"SCRIPT_CHARACTER_RANGES",
"as",
"$",
"range",
")",
"{",
"if",
"(",
"$",
"code_point",
">=",
"$",
"range",
"[",
"1",
"]",
"&&",
"$",
"code_point",
"<=",
"$",
"range",
"[",
"2",
"]",
")",
"{",
"return",
"$",
"range",
"[",
"0",
"]",
";",
"}",
"}",
"// Not a recognised script. Maybe punctuation, spacing, etc. Keep looking.",
"$",
"pos",
"+=",
"$",
"chrlen",
";",
"}",
"return",
"'Latn'",
";",
"}"
] | Identify the script used for a piece of text
@param string $string
@return string | [
"Identify",
"the",
"script",
"used",
"for",
"a",
"piece",
"of",
"text"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/I18N.php#L614-L657 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.find | public function find($user_id): ?User
{
return app('cache.array')->rememberForever(__CLASS__ . $user_id, static function () use ($user_id): ?User {
return DB::table('user')
->where('user_id', '=', $user_id)
->get()
->map(User::rowMapper())
->first();
});
} | php | public function find($user_id): ?User
{
return app('cache.array')->rememberForever(__CLASS__ . $user_id, static function () use ($user_id): ?User {
return DB::table('user')
->where('user_id', '=', $user_id)
->get()
->map(User::rowMapper())
->first();
});
} | [
"public",
"function",
"find",
"(",
"$",
"user_id",
")",
":",
"?",
"User",
"{",
"return",
"app",
"(",
"'cache.array'",
")",
"->",
"rememberForever",
"(",
"__CLASS__",
".",
"$",
"user_id",
",",
"static",
"function",
"(",
")",
"use",
"(",
"$",
"user_id",
")",
":",
"?",
"User",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"where",
"(",
"'user_id'",
",",
"'='",
",",
"$",
"user_id",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"}",
")",
";",
"}"
] | Find the user with a specified user_id.
@param int|null $user_id
@return User|null | [
"Find",
"the",
"user",
"with",
"a",
"specified",
"user_id",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L43-L52 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.findByEmail | public function findByEmail($email): ?User
{
return DB::table('user')
->where('email', '=', $email)
->get()
->map(User::rowMapper())
->first();
} | php | public function findByEmail($email): ?User
{
return DB::table('user')
->where('email', '=', $email)
->get()
->map(User::rowMapper())
->first();
} | [
"public",
"function",
"findByEmail",
"(",
"$",
"email",
")",
":",
"?",
"User",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"where",
"(",
"'email'",
",",
"'='",
",",
"$",
"email",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Find the user with a specified email address.
@param string $email
@return User|null | [
"Find",
"the",
"user",
"with",
"a",
"specified",
"email",
"address",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L61-L68 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.findByIdentifier | public function findByIdentifier($identifier): ?User
{
return DB::table('user')
->where('user_name', '=', $identifier)
->orWhere('email', '=', $identifier)
->get()
->map(User::rowMapper())
->first();
} | php | public function findByIdentifier($identifier): ?User
{
return DB::table('user')
->where('user_name', '=', $identifier)
->orWhere('email', '=', $identifier)
->get()
->map(User::rowMapper())
->first();
} | [
"public",
"function",
"findByIdentifier",
"(",
"$",
"identifier",
")",
":",
"?",
"User",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"where",
"(",
"'user_name'",
",",
"'='",
",",
"$",
"identifier",
")",
"->",
"orWhere",
"(",
"'email'",
",",
"'='",
",",
"$",
"identifier",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Find the user with a specified user_name or email address.
@param string $identifier
@return User|null | [
"Find",
"the",
"user",
"with",
"a",
"specified",
"user_name",
"or",
"email",
"address",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L77-L85 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.findByUserName | public function findByUserName($user_name): ?User
{
return DB::table('user')
->where('user_name', '=', $user_name)
->get()
->map(User::rowMapper())
->first();
} | php | public function findByUserName($user_name): ?User
{
return DB::table('user')
->where('user_name', '=', $user_name)
->get()
->map(User::rowMapper())
->first();
} | [
"public",
"function",
"findByUserName",
"(",
"$",
"user_name",
")",
":",
"?",
"User",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"where",
"(",
"'user_name'",
",",
"'='",
",",
"$",
"user_name",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Find the user with a specified user_name.
@param string $user_name
@return User|null | [
"Find",
"the",
"user",
"with",
"a",
"specified",
"user_name",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L114-L121 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.administrators | public function administrators(): Collection
{
return DB::table('user')
->join('user_setting', static function (JoinClause $join): void {
$join
->on('user_setting.user_id', '=', 'user.user_id')
->where('user_setting.setting_name', '=', 'canadmin')
->where('user_setting.setting_value', '=', '1');
})
->where('user.user_id', '>', 0)
->orderBy('real_name')
->select(['user.*'])
->get()
->map(User::rowMapper());
} | php | public function administrators(): Collection
{
return DB::table('user')
->join('user_setting', static function (JoinClause $join): void {
$join
->on('user_setting.user_id', '=', 'user.user_id')
->where('user_setting.setting_name', '=', 'canadmin')
->where('user_setting.setting_value', '=', '1');
})
->where('user.user_id', '>', 0)
->orderBy('real_name')
->select(['user.*'])
->get()
->map(User::rowMapper());
} | [
"public",
"function",
"administrators",
"(",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"join",
"(",
"'user_setting'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'user_setting.user_id'",
",",
"'='",
",",
"'user.user_id'",
")",
"->",
"where",
"(",
"'user_setting.setting_name'",
",",
"'='",
",",
"'canadmin'",
")",
"->",
"where",
"(",
"'user_setting.setting_value'",
",",
"'='",
",",
"'1'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'user.user_id'",
",",
"'>'",
",",
"0",
")",
"->",
"orderBy",
"(",
"'real_name'",
")",
"->",
"select",
"(",
"[",
"'user.*'",
"]",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
";",
"}"
] | Get a list of all administrators.
@return Collection
@return User[] | [
"Get",
"a",
"list",
"of",
"all",
"administrators",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L144-L158 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.allLoggedIn | public function allLoggedIn(): Collection
{
return DB::table('user')
->join('session', 'session.user_id', '=', 'user.user_id')
->where('user.user_id', '>', 0)
->orderBy('real_name')
->select(['user.*'])
->distinct()
->get()
->map(User::rowMapper());
} | php | public function allLoggedIn(): Collection
{
return DB::table('user')
->join('session', 'session.user_id', '=', 'user.user_id')
->where('user.user_id', '>', 0)
->orderBy('real_name')
->select(['user.*'])
->distinct()
->get()
->map(User::rowMapper());
} | [
"public",
"function",
"allLoggedIn",
"(",
")",
":",
"Collection",
"{",
"return",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"join",
"(",
"'session'",
",",
"'session.user_id'",
",",
"'='",
",",
"'user.user_id'",
")",
"->",
"where",
"(",
"'user.user_id'",
",",
"'>'",
",",
"0",
")",
"->",
"orderBy",
"(",
"'real_name'",
")",
"->",
"select",
"(",
"[",
"'user.*'",
"]",
")",
"->",
"distinct",
"(",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"User",
"::",
"rowMapper",
"(",
")",
")",
";",
"}"
] | Get a list of all users who are currently logged in.
@return Collection
@return User[] | [
"Get",
"a",
"list",
"of",
"all",
"users",
"who",
"are",
"currently",
"logged",
"in",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L254-L264 | train |
fisharebest/webtrees | app/Services/UserService.php | UserService.create | public function create(string $user_name, string $real_name, string $email, string $password): User
{
DB::table('user')->insert([
'user_name' => $user_name,
'real_name' => $real_name,
'email' => $email,
'password' => password_hash($password, PASSWORD_DEFAULT),
]);
$user_id = (int) DB::connection()->getPdo()->lastInsertId();
return new User($user_id, $user_name, $real_name, $email);
} | php | public function create(string $user_name, string $real_name, string $email, string $password): User
{
DB::table('user')->insert([
'user_name' => $user_name,
'real_name' => $real_name,
'email' => $email,
'password' => password_hash($password, PASSWORD_DEFAULT),
]);
$user_id = (int) DB::connection()->getPdo()->lastInsertId();
return new User($user_id, $user_name, $real_name, $email);
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"user_name",
",",
"string",
"$",
"real_name",
",",
"string",
"$",
"email",
",",
"string",
"$",
"password",
")",
":",
"User",
"{",
"DB",
"::",
"table",
"(",
"'user'",
")",
"->",
"insert",
"(",
"[",
"'user_name'",
"=>",
"$",
"user_name",
",",
"'real_name'",
"=>",
"$",
"real_name",
",",
"'email'",
"=>",
"$",
"email",
",",
"'password'",
"=>",
"password_hash",
"(",
"$",
"password",
",",
"PASSWORD_DEFAULT",
")",
",",
"]",
")",
";",
"$",
"user_id",
"=",
"(",
"int",
")",
"DB",
"::",
"connection",
"(",
")",
"->",
"getPdo",
"(",
")",
"->",
"lastInsertId",
"(",
")",
";",
"return",
"new",
"User",
"(",
"$",
"user_id",
",",
"$",
"user_name",
",",
"$",
"real_name",
",",
"$",
"email",
")",
";",
"}"
] | Create a new user.
The calling code needs to check for duplicates identifiers before calling
this function.
@param string $user_name
@param string $real_name
@param string $email
@param string $password
@return User | [
"Create",
"a",
"new",
"user",
".",
"The",
"calling",
"code",
"needs",
"to",
"check",
"for",
"duplicates",
"identifiers",
"before",
"calling",
"this",
"function",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UserService.php#L278-L290 | train |
fisharebest/webtrees | app/Statistics/Repository/PlaceRepository.php | PlaceRepository.statsPlaces | public function statsPlaces(string $what = 'ALL', string $fact = '', int $parent = 0, bool $country = false): array
{
if ($fact) {
return $this->queryFactPlaces($fact, $what, $country);
}
$query = DB::table('places')
->join('placelinks', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'p_file')
->on('pl_p_id', '=', 'p_id');
})
->where('p_file', '=', $this->tree->id());
if ($parent > 0) {
// Used by placehierarchy map modules
$query->select(['p_place AS place'])
->selectRaw('COUNT(*) AS tot')
->where('p_id', '=', $parent)
->groupBy(['place']);
} else {
$query->select(['p_place AS country'])
->selectRaw('COUNT(*) AS tot')
->where('p_parent_id', '=', 0)
->groupBy(['country'])
->orderByDesc('tot')
->orderBy('country');
}
if ($what === 'INDI') {
$query->join('individuals', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'i_file')
->on('pl_gid', '=', 'i_id');
});
} elseif ($what === 'FAM') {
$query->join('families', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'f_file')
->on('pl_gid', '=', 'f_id');
});
}
return $query->get()->all();
} | php | public function statsPlaces(string $what = 'ALL', string $fact = '', int $parent = 0, bool $country = false): array
{
if ($fact) {
return $this->queryFactPlaces($fact, $what, $country);
}
$query = DB::table('places')
->join('placelinks', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'p_file')
->on('pl_p_id', '=', 'p_id');
})
->where('p_file', '=', $this->tree->id());
if ($parent > 0) {
// Used by placehierarchy map modules
$query->select(['p_place AS place'])
->selectRaw('COUNT(*) AS tot')
->where('p_id', '=', $parent)
->groupBy(['place']);
} else {
$query->select(['p_place AS country'])
->selectRaw('COUNT(*) AS tot')
->where('p_parent_id', '=', 0)
->groupBy(['country'])
->orderByDesc('tot')
->orderBy('country');
}
if ($what === 'INDI') {
$query->join('individuals', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'i_file')
->on('pl_gid', '=', 'i_id');
});
} elseif ($what === 'FAM') {
$query->join('families', static function (JoinClause $join): void {
$join->on('pl_file', '=', 'f_file')
->on('pl_gid', '=', 'f_id');
});
}
return $query->get()->all();
} | [
"public",
"function",
"statsPlaces",
"(",
"string",
"$",
"what",
"=",
"'ALL'",
",",
"string",
"$",
"fact",
"=",
"''",
",",
"int",
"$",
"parent",
"=",
"0",
",",
"bool",
"$",
"country",
"=",
"false",
")",
":",
"array",
"{",
"if",
"(",
"$",
"fact",
")",
"{",
"return",
"$",
"this",
"->",
"queryFactPlaces",
"(",
"$",
"fact",
",",
"$",
"what",
",",
"$",
"country",
")",
";",
"}",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'places'",
")",
"->",
"join",
"(",
"'placelinks'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'pl_file'",
",",
"'='",
",",
"'p_file'",
")",
"->",
"on",
"(",
"'pl_p_id'",
",",
"'='",
",",
"'p_id'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'p_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
";",
"if",
"(",
"$",
"parent",
">",
"0",
")",
"{",
"// Used by placehierarchy map modules",
"$",
"query",
"->",
"select",
"(",
"[",
"'p_place AS place'",
"]",
")",
"->",
"selectRaw",
"(",
"'COUNT(*) AS tot'",
")",
"->",
"where",
"(",
"'p_id'",
",",
"'='",
",",
"$",
"parent",
")",
"->",
"groupBy",
"(",
"[",
"'place'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"select",
"(",
"[",
"'p_place AS country'",
"]",
")",
"->",
"selectRaw",
"(",
"'COUNT(*) AS tot'",
")",
"->",
"where",
"(",
"'p_parent_id'",
",",
"'='",
",",
"0",
")",
"->",
"groupBy",
"(",
"[",
"'country'",
"]",
")",
"->",
"orderByDesc",
"(",
"'tot'",
")",
"->",
"orderBy",
"(",
"'country'",
")",
";",
"}",
"if",
"(",
"$",
"what",
"===",
"'INDI'",
")",
"{",
"$",
"query",
"->",
"join",
"(",
"'individuals'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'pl_file'",
",",
"'='",
",",
"'i_file'",
")",
"->",
"on",
"(",
"'pl_gid'",
",",
"'='",
",",
"'i_id'",
")",
";",
"}",
")",
";",
"}",
"elseif",
"(",
"$",
"what",
"===",
"'FAM'",
")",
"{",
"$",
"query",
"->",
"join",
"(",
"'families'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'pl_file'",
",",
"'='",
",",
"'f_file'",
")",
"->",
"on",
"(",
"'pl_gid'",
",",
"'='",
",",
"'f_id'",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"query",
"->",
"get",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Query places.
@param string $what
@param string $fact
@param int $parent
@param bool $country
@return int[]|stdClass[] | [
"Query",
"places",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/PlaceRepository.php#L125-L166 | train |
fisharebest/webtrees | app/Statistics/Repository/PlaceRepository.php | PlaceRepository.getTop10Places | private function getTop10Places(array $places): array
{
$top10 = [];
$i = 0;
arsort($places);
foreach ($places as $place => $count) {
$tmp = new Place($place, $this->tree);
$top10[] = [
'place' => $tmp,
'count' => $count,
];
++$i;
if ($i === 10) {
break;
}
}
return $top10;
} | php | private function getTop10Places(array $places): array
{
$top10 = [];
$i = 0;
arsort($places);
foreach ($places as $place => $count) {
$tmp = new Place($place, $this->tree);
$top10[] = [
'place' => $tmp,
'count' => $count,
];
++$i;
if ($i === 10) {
break;
}
}
return $top10;
} | [
"private",
"function",
"getTop10Places",
"(",
"array",
"$",
"places",
")",
":",
"array",
"{",
"$",
"top10",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"arsort",
"(",
"$",
"places",
")",
";",
"foreach",
"(",
"$",
"places",
"as",
"$",
"place",
"=>",
"$",
"count",
")",
"{",
"$",
"tmp",
"=",
"new",
"Place",
"(",
"$",
"place",
",",
"$",
"this",
"->",
"tree",
")",
";",
"$",
"top10",
"[",
"]",
"=",
"[",
"'place'",
"=>",
"$",
"tmp",
",",
"'count'",
"=>",
"$",
"count",
",",
"]",
";",
"++",
"$",
"i",
";",
"if",
"(",
"$",
"i",
"===",
"10",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"top10",
";",
"}"
] | Get the top 10 places list.
@param array $places
@return array | [
"Get",
"the",
"top",
"10",
"places",
"list",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/PlaceRepository.php#L175-L197 | train |
fisharebest/webtrees | app/Statistics/Repository/PlaceRepository.php | PlaceRepository.commonCountriesList | public function commonCountriesList(): string
{
$countries = $this->statsPlaces();
if (empty($countries)) {
return '';
}
$top10 = [];
$i = 1;
// Get the country names for each language
$country_names = [];
foreach (I18N::activeLocales() as $locale) {
I18N::init($locale->languageTag());
$all_countries = $this->country_service->getAllCountries();
foreach ($all_countries as $country_code => $country_name) {
$country_names[$country_name] = $country_code;
}
}
I18N::init(WT_LOCALE);
$all_db_countries = [];
foreach ($countries as $place) {
$country = trim($place->country);
if (array_key_exists($country, $country_names)) {
if (isset($all_db_countries[$country_names[$country]][$country])) {
$all_db_countries[$country_names[$country]][$country] += (int) $place->tot;
} else {
$all_db_countries[$country_names[$country]][$country] = (int) $place->tot;
}
}
}
// get all the user’s countries names
$all_countries = $this->country_service->getAllCountries();
foreach ($all_db_countries as $country_code => $country) {
foreach ($country as $country_name => $tot) {
$tmp = new Place($country_name, $this->tree);
$top10[] = [
'place' => $tmp,
'count' => $tot,
'name' => $all_countries[$country_code],
];
}
if ($i++ === 10) {
break;
}
}
return view(
'statistics/other/top10-list',
[
'records' => $top10,
]
);
} | php | public function commonCountriesList(): string
{
$countries = $this->statsPlaces();
if (empty($countries)) {
return '';
}
$top10 = [];
$i = 1;
// Get the country names for each language
$country_names = [];
foreach (I18N::activeLocales() as $locale) {
I18N::init($locale->languageTag());
$all_countries = $this->country_service->getAllCountries();
foreach ($all_countries as $country_code => $country_name) {
$country_names[$country_name] = $country_code;
}
}
I18N::init(WT_LOCALE);
$all_db_countries = [];
foreach ($countries as $place) {
$country = trim($place->country);
if (array_key_exists($country, $country_names)) {
if (isset($all_db_countries[$country_names[$country]][$country])) {
$all_db_countries[$country_names[$country]][$country] += (int) $place->tot;
} else {
$all_db_countries[$country_names[$country]][$country] = (int) $place->tot;
}
}
}
// get all the user’s countries names
$all_countries = $this->country_service->getAllCountries();
foreach ($all_db_countries as $country_code => $country) {
foreach ($country as $country_name => $tot) {
$tmp = new Place($country_name, $this->tree);
$top10[] = [
'place' => $tmp,
'count' => $tot,
'name' => $all_countries[$country_code],
];
}
if ($i++ === 10) {
break;
}
}
return view(
'statistics/other/top10-list',
[
'records' => $top10,
]
);
} | [
"public",
"function",
"commonCountriesList",
"(",
")",
":",
"string",
"{",
"$",
"countries",
"=",
"$",
"this",
"->",
"statsPlaces",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"countries",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"top10",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"1",
";",
"// Get the country names for each language",
"$",
"country_names",
"=",
"[",
"]",
";",
"foreach",
"(",
"I18N",
"::",
"activeLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"I18N",
"::",
"init",
"(",
"$",
"locale",
"->",
"languageTag",
"(",
")",
")",
";",
"$",
"all_countries",
"=",
"$",
"this",
"->",
"country_service",
"->",
"getAllCountries",
"(",
")",
";",
"foreach",
"(",
"$",
"all_countries",
"as",
"$",
"country_code",
"=>",
"$",
"country_name",
")",
"{",
"$",
"country_names",
"[",
"$",
"country_name",
"]",
"=",
"$",
"country_code",
";",
"}",
"}",
"I18N",
"::",
"init",
"(",
"WT_LOCALE",
")",
";",
"$",
"all_db_countries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"countries",
"as",
"$",
"place",
")",
"{",
"$",
"country",
"=",
"trim",
"(",
"$",
"place",
"->",
"country",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"country",
",",
"$",
"country_names",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"all_db_countries",
"[",
"$",
"country_names",
"[",
"$",
"country",
"]",
"]",
"[",
"$",
"country",
"]",
")",
")",
"{",
"$",
"all_db_countries",
"[",
"$",
"country_names",
"[",
"$",
"country",
"]",
"]",
"[",
"$",
"country",
"]",
"+=",
"(",
"int",
")",
"$",
"place",
"->",
"tot",
";",
"}",
"else",
"{",
"$",
"all_db_countries",
"[",
"$",
"country_names",
"[",
"$",
"country",
"]",
"]",
"[",
"$",
"country",
"]",
"=",
"(",
"int",
")",
"$",
"place",
"->",
"tot",
";",
"}",
"}",
"}",
"// get all the user’s countries names",
"$",
"all_countries",
"=",
"$",
"this",
"->",
"country_service",
"->",
"getAllCountries",
"(",
")",
";",
"foreach",
"(",
"$",
"all_db_countries",
"as",
"$",
"country_code",
"=>",
"$",
"country",
")",
"{",
"foreach",
"(",
"$",
"country",
"as",
"$",
"country_name",
"=>",
"$",
"tot",
")",
"{",
"$",
"tmp",
"=",
"new",
"Place",
"(",
"$",
"country_name",
",",
"$",
"this",
"->",
"tree",
")",
";",
"$",
"top10",
"[",
"]",
"=",
"[",
"'place'",
"=>",
"$",
"tmp",
",",
"'count'",
"=>",
"$",
"tot",
",",
"'name'",
"=>",
"$",
"all_countries",
"[",
"$",
"country_code",
"]",
",",
"]",
";",
"}",
"if",
"(",
"$",
"i",
"++",
"===",
"10",
")",
"{",
"break",
";",
"}",
"}",
"return",
"view",
"(",
"'statistics/other/top10-list'",
",",
"[",
"'records'",
"=>",
"$",
"top10",
",",
"]",
")",
";",
"}"
] | A list of common countries.
@return string | [
"A",
"list",
"of",
"common",
"countries",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/PlaceRepository.php#L256-L316 | train |
fisharebest/webtrees | app/Report/AbstractReport.php | AbstractReport.setup | public function setup(): void
{
$this->rtl = I18N::direction() === 'rtl';
$this->rkeywords = '';
// I18N: This is a report footer. %s is the name of the application.
$this->generated_by = I18N::translate('Generated by %s', Webtrees::NAME . ' ' . Webtrees::VERSION);
// Paper size - defaults to A4 if the report fails to define a size.
[$this->page_width, $this->page_height] = self::PAPER_SIZES[$this->page_format] ?? self::PAPER_SIZES['A4'];
} | php | public function setup(): void
{
$this->rtl = I18N::direction() === 'rtl';
$this->rkeywords = '';
// I18N: This is a report footer. %s is the name of the application.
$this->generated_by = I18N::translate('Generated by %s', Webtrees::NAME . ' ' . Webtrees::VERSION);
// Paper size - defaults to A4 if the report fails to define a size.
[$this->page_width, $this->page_height] = self::PAPER_SIZES[$this->page_format] ?? self::PAPER_SIZES['A4'];
} | [
"public",
"function",
"setup",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"rtl",
"=",
"I18N",
"::",
"direction",
"(",
")",
"===",
"'rtl'",
";",
"$",
"this",
"->",
"rkeywords",
"=",
"''",
";",
"// I18N: This is a report footer. %s is the name of the application.",
"$",
"this",
"->",
"generated_by",
"=",
"I18N",
"::",
"translate",
"(",
"'Generated by %s'",
",",
"Webtrees",
"::",
"NAME",
".",
"' '",
".",
"Webtrees",
"::",
"VERSION",
")",
";",
"// Paper size - defaults to A4 if the report fails to define a size.",
"[",
"$",
"this",
"->",
"page_width",
",",
"$",
"this",
"->",
"page_height",
"]",
"=",
"self",
"::",
"PAPER_SIZES",
"[",
"$",
"this",
"->",
"page_format",
"]",
"??",
"self",
"::",
"PAPER_SIZES",
"[",
"'A4'",
"]",
";",
"}"
] | Initial Setup
Setting up document wide defaults that will be inherited of the report modules
As DEFAULT A4 and Portrait will be used if not set
@return void | [
"Initial",
"Setup",
"Setting",
"up",
"document",
"wide",
"defaults",
"that",
"will",
"be",
"inherited",
"of",
"the",
"report",
"modules",
"As",
"DEFAULT",
"A4",
"and",
"Portrait",
"will",
"be",
"used",
"if",
"not",
"set"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/AbstractReport.php#L277-L288 | train |
fisharebest/webtrees | app/Report/AbstractReport.php | AbstractReport.getStyle | public function getStyle(string $s): array
{
if (!isset($this->styles[$s])) {
return current($this->styles);
}
return $this->styles[$s];
} | php | public function getStyle(string $s): array
{
if (!isset($this->styles[$s])) {
return current($this->styles);
}
return $this->styles[$s];
} | [
"public",
"function",
"getStyle",
"(",
"string",
"$",
"s",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"styles",
"[",
"$",
"s",
"]",
")",
")",
"{",
"return",
"current",
"(",
"$",
"this",
"->",
"styles",
")",
";",
"}",
"return",
"$",
"this",
"->",
"styles",
"[",
"$",
"s",
"]",
";",
"}"
] | Get a style from the Styles array
@param string $s Style name
@return array | [
"Get",
"a",
"style",
"from",
"the",
"Styles",
"array"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/AbstractReport.php#L345-L352 | train |
fisharebest/webtrees | app/Http/Middleware/UpdateDatabaseSchema.php | UpdateDatabaseSchema.process | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$this->migration_service
->updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION);
return $handler->handle($request);
} | php | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$this->migration_service
->updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION);
return $handler->handle($request);
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"migration_service",
"->",
"updateSchema",
"(",
"'\\Fisharebest\\Webtrees\\Schema'",
",",
"'WT_SCHEMA_VERSION'",
",",
"Webtrees",
"::",
"SCHEMA_VERSION",
")",
";",
"return",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"}"
] | Update the database schema, if necessary.
@param ServerRequestInterface $request
@param RequestHandlerInterface $handler
@return ResponseInterface | [
"Update",
"the",
"database",
"schema",
"if",
"necessary",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Middleware/UpdateDatabaseSchema.php#L51-L57 | train |
fisharebest/webtrees | app/Http/Controllers/AdminSiteController.php | AdminSiteController.cleanData | public function cleanData(ServerRequestInterface $request, FilesystemInterface $filesystem): ResponseInterface
{
$protected = [
'.htaccess',
'.gitignore',
'index.php',
'config.ini.php',
];
if ($request->getAttribute('dbtype') === 'sqlite') {
$protected[] = $request->getAttribute('dbname') . '.sqlite';
}
// Protect the media folders
foreach (Tree::getAll() as $tree) {
$media_directory = $tree->getPreference('MEDIA_DIRECTORY');
[$folder] = explode('/', $media_directory);
$protected[] = $folder;
}
// List the top-level contents of the data folder
$entries = array_map(static function (array $content) {
return $content['path'];
}, $filesystem->listContents());
return $this->viewResponse('admin/clean-data', [
'title' => I18N::translate('Clean up data folder'),
'entries' => $entries,
'protected' => $protected,
]);
} | php | public function cleanData(ServerRequestInterface $request, FilesystemInterface $filesystem): ResponseInterface
{
$protected = [
'.htaccess',
'.gitignore',
'index.php',
'config.ini.php',
];
if ($request->getAttribute('dbtype') === 'sqlite') {
$protected[] = $request->getAttribute('dbname') . '.sqlite';
}
// Protect the media folders
foreach (Tree::getAll() as $tree) {
$media_directory = $tree->getPreference('MEDIA_DIRECTORY');
[$folder] = explode('/', $media_directory);
$protected[] = $folder;
}
// List the top-level contents of the data folder
$entries = array_map(static function (array $content) {
return $content['path'];
}, $filesystem->listContents());
return $this->viewResponse('admin/clean-data', [
'title' => I18N::translate('Clean up data folder'),
'entries' => $entries,
'protected' => $protected,
]);
} | [
"public",
"function",
"cleanData",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"FilesystemInterface",
"$",
"filesystem",
")",
":",
"ResponseInterface",
"{",
"$",
"protected",
"=",
"[",
"'.htaccess'",
",",
"'.gitignore'",
",",
"'index.php'",
",",
"'config.ini.php'",
",",
"]",
";",
"if",
"(",
"$",
"request",
"->",
"getAttribute",
"(",
"'dbtype'",
")",
"===",
"'sqlite'",
")",
"{",
"$",
"protected",
"[",
"]",
"=",
"$",
"request",
"->",
"getAttribute",
"(",
"'dbname'",
")",
".",
"'.sqlite'",
";",
"}",
"// Protect the media folders",
"foreach",
"(",
"Tree",
"::",
"getAll",
"(",
")",
"as",
"$",
"tree",
")",
"{",
"$",
"media_directory",
"=",
"$",
"tree",
"->",
"getPreference",
"(",
"'MEDIA_DIRECTORY'",
")",
";",
"[",
"$",
"folder",
"]",
"=",
"explode",
"(",
"'/'",
",",
"$",
"media_directory",
")",
";",
"$",
"protected",
"[",
"]",
"=",
"$",
"folder",
";",
"}",
"// List the top-level contents of the data folder",
"$",
"entries",
"=",
"array_map",
"(",
"static",
"function",
"(",
"array",
"$",
"content",
")",
"{",
"return",
"$",
"content",
"[",
"'path'",
"]",
";",
"}",
",",
"$",
"filesystem",
"->",
"listContents",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'admin/clean-data'",
",",
"[",
"'title'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Clean up data folder'",
")",
",",
"'entries'",
"=>",
"$",
"entries",
",",
"'protected'",
"=>",
"$",
"protected",
",",
"]",
")",
";",
"}"
] | Show old user files in the data folder.
@param ServerRequestInterface $request
@param FilesystemInterface $filesystem
@return ResponseInterface | [
"Show",
"old",
"user",
"files",
"in",
"the",
"data",
"folder",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AdminSiteController.php#L78-L109 | train |
fisharebest/webtrees | app/Http/Controllers/AdminSiteController.php | AdminSiteController.cleanDataAction | public function cleanDataAction(ServerRequestInterface $request, FilesystemInterface $filesystem): ResponseInterface
{
$to_delete = (array) $request->get('to_delete');
$to_delete = array_filter($to_delete);
foreach ($to_delete as $path) {
$metadata = $filesystem->getMetadata($path);
if ($metadata === false) {
// Already deleted?
continue;
}
if ($metadata['type'] === 'dir') {
try {
$filesystem->deleteDir($path);
FlashMessages::addMessage(I18N::translate('The folder %s has been deleted.', e($path)), 'success');
} catch (Exception $ex) {
FlashMessages::addMessage(I18N::translate('The folder %s could not be deleted.', e($path)), 'danger');
}
}
if ($metadata['type'] === 'file') {
try {
$filesystem->delete($path);
FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', e($path)), 'success');
} catch (Exception $ex) {
FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', e($path)), 'danger');
}
}
}
return redirect(route('admin-clean-data'));
} | php | public function cleanDataAction(ServerRequestInterface $request, FilesystemInterface $filesystem): ResponseInterface
{
$to_delete = (array) $request->get('to_delete');
$to_delete = array_filter($to_delete);
foreach ($to_delete as $path) {
$metadata = $filesystem->getMetadata($path);
if ($metadata === false) {
// Already deleted?
continue;
}
if ($metadata['type'] === 'dir') {
try {
$filesystem->deleteDir($path);
FlashMessages::addMessage(I18N::translate('The folder %s has been deleted.', e($path)), 'success');
} catch (Exception $ex) {
FlashMessages::addMessage(I18N::translate('The folder %s could not be deleted.', e($path)), 'danger');
}
}
if ($metadata['type'] === 'file') {
try {
$filesystem->delete($path);
FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', e($path)), 'success');
} catch (Exception $ex) {
FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', e($path)), 'danger');
}
}
}
return redirect(route('admin-clean-data'));
} | [
"public",
"function",
"cleanDataAction",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"FilesystemInterface",
"$",
"filesystem",
")",
":",
"ResponseInterface",
"{",
"$",
"to_delete",
"=",
"(",
"array",
")",
"$",
"request",
"->",
"get",
"(",
"'to_delete'",
")",
";",
"$",
"to_delete",
"=",
"array_filter",
"(",
"$",
"to_delete",
")",
";",
"foreach",
"(",
"$",
"to_delete",
"as",
"$",
"path",
")",
"{",
"$",
"metadata",
"=",
"$",
"filesystem",
"->",
"getMetadata",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"metadata",
"===",
"false",
")",
"{",
"// Already deleted?",
"continue",
";",
"}",
"if",
"(",
"$",
"metadata",
"[",
"'type'",
"]",
"===",
"'dir'",
")",
"{",
"try",
"{",
"$",
"filesystem",
"->",
"deleteDir",
"(",
"$",
"path",
")",
";",
"FlashMessages",
"::",
"addMessage",
"(",
"I18N",
"::",
"translate",
"(",
"'The folder %s has been deleted.'",
",",
"e",
"(",
"$",
"path",
")",
")",
",",
"'success'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"FlashMessages",
"::",
"addMessage",
"(",
"I18N",
"::",
"translate",
"(",
"'The folder %s could not be deleted.'",
",",
"e",
"(",
"$",
"path",
")",
")",
",",
"'danger'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"metadata",
"[",
"'type'",
"]",
"===",
"'file'",
")",
"{",
"try",
"{",
"$",
"filesystem",
"->",
"delete",
"(",
"$",
"path",
")",
";",
"FlashMessages",
"::",
"addMessage",
"(",
"I18N",
"::",
"translate",
"(",
"'The file %s has been deleted.'",
",",
"e",
"(",
"$",
"path",
")",
")",
",",
"'success'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"FlashMessages",
"::",
"addMessage",
"(",
"I18N",
"::",
"translate",
"(",
"'The file %s could not be deleted.'",
",",
"e",
"(",
"$",
"path",
")",
")",
",",
"'danger'",
")",
";",
"}",
"}",
"}",
"return",
"redirect",
"(",
"route",
"(",
"'admin-clean-data'",
")",
")",
";",
"}"
] | Delete old user files in the data folder.
@param ServerRequestInterface $request
@param FilesystemInterface $filesystem
@return ResponseInterface | [
"Delete",
"old",
"user",
"files",
"in",
"the",
"data",
"folder",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AdminSiteController.php#L119-L154 | train |
fisharebest/webtrees | app/Http/Controllers/AdminSiteController.php | AdminSiteController.logsQuery | private function logsQuery(ServerRequestInterface $request): Builder
{
$from = $request->get('from');
$to = $request->get('to');
$type = $request->get('type', '');
$text = $request->get('text', '');
$ip = $request->get('ip', '');
$username = $request->get('username', '');
$gedc = $request->get('gedc');
$query = DB::table('log')
->leftJoin('user', 'user.user_id', '=', 'log.user_id')
->leftJoin('gedcom', 'gedcom.gedcom_id', '=', 'log.gedcom_id')
->select(['log.*', DB::raw("COALESCE(user_name, '<none>') AS user_name"), DB::raw("COALESCE(gedcom_name, '<none>') AS gedcom_name")]);
if ($from !== '') {
$query->where('log_time', '>=', $from);
}
if ($to !== '') {
// before end of the day
$query->where('log_time', '<', Carbon::make($to)->addDay());
}
if ($type !== '') {
$query->where('log_type', '=', $type);
}
if ($text) {
$query->whereContains('log_message', $text);
}
if ($ip) {
$query->whereContains('ip_address', $ip);
}
if ($username) {
$query->whereContains('user_name', $ip);
}
if ($gedc) {
$query->where('gedcom_name', '=', $gedc);
}
return $query;
} | php | private function logsQuery(ServerRequestInterface $request): Builder
{
$from = $request->get('from');
$to = $request->get('to');
$type = $request->get('type', '');
$text = $request->get('text', '');
$ip = $request->get('ip', '');
$username = $request->get('username', '');
$gedc = $request->get('gedc');
$query = DB::table('log')
->leftJoin('user', 'user.user_id', '=', 'log.user_id')
->leftJoin('gedcom', 'gedcom.gedcom_id', '=', 'log.gedcom_id')
->select(['log.*', DB::raw("COALESCE(user_name, '<none>') AS user_name"), DB::raw("COALESCE(gedcom_name, '<none>') AS gedcom_name")]);
if ($from !== '') {
$query->where('log_time', '>=', $from);
}
if ($to !== '') {
// before end of the day
$query->where('log_time', '<', Carbon::make($to)->addDay());
}
if ($type !== '') {
$query->where('log_type', '=', $type);
}
if ($text) {
$query->whereContains('log_message', $text);
}
if ($ip) {
$query->whereContains('ip_address', $ip);
}
if ($username) {
$query->whereContains('user_name', $ip);
}
if ($gedc) {
$query->where('gedcom_name', '=', $gedc);
}
return $query;
} | [
"private",
"function",
"logsQuery",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"Builder",
"{",
"$",
"from",
"=",
"$",
"request",
"->",
"get",
"(",
"'from'",
")",
";",
"$",
"to",
"=",
"$",
"request",
"->",
"get",
"(",
"'to'",
")",
";",
"$",
"type",
"=",
"$",
"request",
"->",
"get",
"(",
"'type'",
",",
"''",
")",
";",
"$",
"text",
"=",
"$",
"request",
"->",
"get",
"(",
"'text'",
",",
"''",
")",
";",
"$",
"ip",
"=",
"$",
"request",
"->",
"get",
"(",
"'ip'",
",",
"''",
")",
";",
"$",
"username",
"=",
"$",
"request",
"->",
"get",
"(",
"'username'",
",",
"''",
")",
";",
"$",
"gedc",
"=",
"$",
"request",
"->",
"get",
"(",
"'gedc'",
")",
";",
"$",
"query",
"=",
"DB",
"::",
"table",
"(",
"'log'",
")",
"->",
"leftJoin",
"(",
"'user'",
",",
"'user.user_id'",
",",
"'='",
",",
"'log.user_id'",
")",
"->",
"leftJoin",
"(",
"'gedcom'",
",",
"'gedcom.gedcom_id'",
",",
"'='",
",",
"'log.gedcom_id'",
")",
"->",
"select",
"(",
"[",
"'log.*'",
",",
"DB",
"::",
"raw",
"(",
"\"COALESCE(user_name, '<none>') AS user_name\"",
")",
",",
"DB",
"::",
"raw",
"(",
"\"COALESCE(gedcom_name, '<none>') AS gedcom_name\"",
")",
"]",
")",
";",
"if",
"(",
"$",
"from",
"!==",
"''",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'log_time'",
",",
"'>='",
",",
"$",
"from",
")",
";",
"}",
"if",
"(",
"$",
"to",
"!==",
"''",
")",
"{",
"// before end of the day",
"$",
"query",
"->",
"where",
"(",
"'log_time'",
",",
"'<'",
",",
"Carbon",
"::",
"make",
"(",
"$",
"to",
")",
"->",
"addDay",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"type",
"!==",
"''",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'log_type'",
",",
"'='",
",",
"$",
"type",
")",
";",
"}",
"if",
"(",
"$",
"text",
")",
"{",
"$",
"query",
"->",
"whereContains",
"(",
"'log_message'",
",",
"$",
"text",
")",
";",
"}",
"if",
"(",
"$",
"ip",
")",
"{",
"$",
"query",
"->",
"whereContains",
"(",
"'ip_address'",
",",
"$",
"ip",
")",
";",
"}",
"if",
"(",
"$",
"username",
")",
"{",
"$",
"query",
"->",
"whereContains",
"(",
"'user_name'",
",",
"$",
"ip",
")",
";",
"}",
"if",
"(",
"$",
"gedc",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'gedcom_name'",
",",
"'='",
",",
"$",
"gedc",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Generate a query for filtering the site log.
@param ServerRequestInterface $request
@return Builder | [
"Generate",
"a",
"query",
"for",
"filtering",
"the",
"site",
"log",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AdminSiteController.php#L240-L285 | train |
fisharebest/webtrees | app/Http/Controllers/AdminSiteController.php | AdminSiteController.serverInformation | public function serverInformation(): ResponseInterface
{
ob_start();
phpinfo(INFO_ALL & ~INFO_CREDITS & ~INFO_LICENSE);
$phpinfo = ob_get_clean();
preg_match('%<body>(.*)</body>%s', $phpinfo, $matches);
$phpinfo = $matches[1];
return $this->viewResponse('admin/server-information', [
'title' => I18N::translate('Server information'),
'phpinfo' => $phpinfo,
]);
} | php | public function serverInformation(): ResponseInterface
{
ob_start();
phpinfo(INFO_ALL & ~INFO_CREDITS & ~INFO_LICENSE);
$phpinfo = ob_get_clean();
preg_match('%<body>(.*)</body>%s', $phpinfo, $matches);
$phpinfo = $matches[1];
return $this->viewResponse('admin/server-information', [
'title' => I18N::translate('Server information'),
'phpinfo' => $phpinfo,
]);
} | [
"public",
"function",
"serverInformation",
"(",
")",
":",
"ResponseInterface",
"{",
"ob_start",
"(",
")",
";",
"phpinfo",
"(",
"INFO_ALL",
"&",
"~",
"INFO_CREDITS",
"&",
"~",
"INFO_LICENSE",
")",
";",
"$",
"phpinfo",
"=",
"ob_get_clean",
"(",
")",
";",
"preg_match",
"(",
"'%<body>(.*)</body>%s'",
",",
"$",
"phpinfo",
",",
"$",
"matches",
")",
";",
"$",
"phpinfo",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'admin/server-information'",
",",
"[",
"'title'",
"=>",
"I18N",
"::",
"translate",
"(",
"'Server information'",
")",
",",
"'phpinfo'",
"=>",
"$",
"phpinfo",
",",
"]",
")",
";",
"}"
] | Show the server information page.
@return ResponseInterface | [
"Show",
"the",
"server",
"information",
"page",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/AdminSiteController.php#L513-L525 | train |
fisharebest/webtrees | app/Module/ContactsFooterModule.php | ContactsFooterModule.contactLinkTechnical | public function contactLinkTechnical(User $user): string
{
return I18N::translate('For technical support and information contact %s.', $this->user_service->contactLink($user));
} | php | public function contactLinkTechnical(User $user): string
{
return I18N::translate('For technical support and information contact %s.', $this->user_service->contactLink($user));
} | [
"public",
"function",
"contactLinkTechnical",
"(",
"User",
"$",
"user",
")",
":",
"string",
"{",
"return",
"I18N",
"::",
"translate",
"(",
"'For technical support and information contact %s.'",
",",
"$",
"this",
"->",
"user_service",
"->",
"contactLink",
"(",
"$",
"user",
")",
")",
";",
"}"
] | Create contact link for technical support.
@param User $user
@return string | [
"Create",
"contact",
"link",
"for",
"technical",
"support",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ContactsFooterModule.php#L153-L156 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.nameComparator | public static function nameComparator(): Closure
{
return static function (GedcomRecord $x, GedcomRecord $y): int {
if ($x->canShowName()) {
if ($y->canShowName()) {
return I18N::strcasecmp($x->sortName(), $y->sortName());
}
return -1; // only $y is private
}
if ($y->canShowName()) {
return 1; // only $x is private
}
return 0; // both $x and $y private
};
} | php | public static function nameComparator(): Closure
{
return static function (GedcomRecord $x, GedcomRecord $y): int {
if ($x->canShowName()) {
if ($y->canShowName()) {
return I18N::strcasecmp($x->sortName(), $y->sortName());
}
return -1; // only $y is private
}
if ($y->canShowName()) {
return 1; // only $x is private
}
return 0; // both $x and $y private
};
} | [
"public",
"static",
"function",
"nameComparator",
"(",
")",
":",
"Closure",
"{",
"return",
"static",
"function",
"(",
"GedcomRecord",
"$",
"x",
",",
"GedcomRecord",
"$",
"y",
")",
":",
"int",
"{",
"if",
"(",
"$",
"x",
"->",
"canShowName",
"(",
")",
")",
"{",
"if",
"(",
"$",
"y",
"->",
"canShowName",
"(",
")",
")",
"{",
"return",
"I18N",
"::",
"strcasecmp",
"(",
"$",
"x",
"->",
"sortName",
"(",
")",
",",
"$",
"y",
"->",
"sortName",
"(",
")",
")",
";",
"}",
"return",
"-",
"1",
";",
"// only $y is private",
"}",
"if",
"(",
"$",
"y",
"->",
"canShowName",
"(",
")",
")",
"{",
"return",
"1",
";",
"// only $x is private",
"}",
"return",
"0",
";",
"// both $x and $y private",
"}",
";",
"}"
] | A closure which will compare records by name.
@return Closure | [
"A",
"closure",
"which",
"will",
"compare",
"records",
"by",
"name",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L116-L133 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.lastChangeComparator | public static function lastChangeComparator(int $direction = 1): Closure
{
return static function (GedcomRecord $x, GedcomRecord $y) use ($direction): int {
return $direction * ($x->lastChangeTimestamp() <=> $y->lastChangeTimestamp());
};
} | php | public static function lastChangeComparator(int $direction = 1): Closure
{
return static function (GedcomRecord $x, GedcomRecord $y) use ($direction): int {
return $direction * ($x->lastChangeTimestamp() <=> $y->lastChangeTimestamp());
};
} | [
"public",
"static",
"function",
"lastChangeComparator",
"(",
"int",
"$",
"direction",
"=",
"1",
")",
":",
"Closure",
"{",
"return",
"static",
"function",
"(",
"GedcomRecord",
"$",
"x",
",",
"GedcomRecord",
"$",
"y",
")",
"use",
"(",
"$",
"direction",
")",
":",
"int",
"{",
"return",
"$",
"direction",
"*",
"(",
"$",
"x",
"->",
"lastChangeTimestamp",
"(",
")",
"<=>",
"$",
"y",
"->",
"lastChangeTimestamp",
"(",
")",
")",
";",
"}",
";",
"}"
] | A closure which will compare records by change time.
@param int $direction +1 to sort ascending, -1 to sort descending
@return Closure | [
"A",
"closure",
"which",
"will",
"compare",
"records",
"by",
"change",
"time",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L142-L147 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.parseFacts | private function parseFacts(): void
{
// Split the record into facts
if ($this->gedcom) {
$gedcom_facts = preg_split('/\n(?=1)/s', $this->gedcom);
array_shift($gedcom_facts);
} else {
$gedcom_facts = [];
}
if ($this->pending) {
$pending_facts = preg_split('/\n(?=1)/s', $this->pending);
array_shift($pending_facts);
} else {
$pending_facts = [];
}
$this->facts = [];
foreach ($gedcom_facts as $gedcom_fact) {
$fact = new Fact($gedcom_fact, $this, md5($gedcom_fact));
if ($this->pending !== null && !in_array($gedcom_fact, $pending_facts, true)) {
$fact->setPendingDeletion();
}
$this->facts[] = $fact;
}
foreach ($pending_facts as $pending_fact) {
if (!in_array($pending_fact, $gedcom_facts, true)) {
$fact = new Fact($pending_fact, $this, md5($pending_fact));
$fact->setPendingAddition();
$this->facts[] = $fact;
}
}
} | php | private function parseFacts(): void
{
// Split the record into facts
if ($this->gedcom) {
$gedcom_facts = preg_split('/\n(?=1)/s', $this->gedcom);
array_shift($gedcom_facts);
} else {
$gedcom_facts = [];
}
if ($this->pending) {
$pending_facts = preg_split('/\n(?=1)/s', $this->pending);
array_shift($pending_facts);
} else {
$pending_facts = [];
}
$this->facts = [];
foreach ($gedcom_facts as $gedcom_fact) {
$fact = new Fact($gedcom_fact, $this, md5($gedcom_fact));
if ($this->pending !== null && !in_array($gedcom_fact, $pending_facts, true)) {
$fact->setPendingDeletion();
}
$this->facts[] = $fact;
}
foreach ($pending_facts as $pending_fact) {
if (!in_array($pending_fact, $gedcom_facts, true)) {
$fact = new Fact($pending_fact, $this, md5($pending_fact));
$fact->setPendingAddition();
$this->facts[] = $fact;
}
}
} | [
"private",
"function",
"parseFacts",
"(",
")",
":",
"void",
"{",
"// Split the record into facts",
"if",
"(",
"$",
"this",
"->",
"gedcom",
")",
"{",
"$",
"gedcom_facts",
"=",
"preg_split",
"(",
"'/\\n(?=1)/s'",
",",
"$",
"this",
"->",
"gedcom",
")",
";",
"array_shift",
"(",
"$",
"gedcom_facts",
")",
";",
"}",
"else",
"{",
"$",
"gedcom_facts",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"$",
"pending_facts",
"=",
"preg_split",
"(",
"'/\\n(?=1)/s'",
",",
"$",
"this",
"->",
"pending",
")",
";",
"array_shift",
"(",
"$",
"pending_facts",
")",
";",
"}",
"else",
"{",
"$",
"pending_facts",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"facts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"gedcom_facts",
"as",
"$",
"gedcom_fact",
")",
"{",
"$",
"fact",
"=",
"new",
"Fact",
"(",
"$",
"gedcom_fact",
",",
"$",
"this",
",",
"md5",
"(",
"$",
"gedcom_fact",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pending",
"!==",
"null",
"&&",
"!",
"in_array",
"(",
"$",
"gedcom_fact",
",",
"$",
"pending_facts",
",",
"true",
")",
")",
"{",
"$",
"fact",
"->",
"setPendingDeletion",
"(",
")",
";",
"}",
"$",
"this",
"->",
"facts",
"[",
"]",
"=",
"$",
"fact",
";",
"}",
"foreach",
"(",
"$",
"pending_facts",
"as",
"$",
"pending_fact",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"pending_fact",
",",
"$",
"gedcom_facts",
",",
"true",
")",
")",
"{",
"$",
"fact",
"=",
"new",
"Fact",
"(",
"$",
"pending_fact",
",",
"$",
"this",
",",
"md5",
"(",
"$",
"pending_fact",
")",
")",
";",
"$",
"fact",
"->",
"setPendingAddition",
"(",
")",
";",
"$",
"this",
"->",
"facts",
"[",
"]",
"=",
"$",
"fact",
";",
"}",
"}",
"}"
] | Split the record into facts
@return void | [
"Split",
"the",
"record",
"into",
"facts"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L154-L186 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.canShowRecord | private function canShowRecord(int $access_level): bool
{
// This setting would better be called "$ENABLE_PRIVACY"
if (!$this->tree->getPreference('HIDE_LIVE_PEOPLE')) {
return true;
}
// We should always be able to see our own record (unless an admin is applying download restrictions)
if ($this->xref() === $this->tree->getUserPreference(Auth::user(), 'gedcomid') && $access_level === Auth::accessLevel($this->tree)) {
return true;
}
// Does this record have a RESN?
if (strpos($this->gedcom, "\n1 RESN confidential") !== false) {
return Auth::PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN privacy") !== false) {
return Auth::PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN none") !== false) {
return true;
}
// Does this record have a default RESN?
$individual_privacy = $this->tree->getIndividualPrivacy();
if (isset($individual_privacy[$this->xref()])) {
return $individual_privacy[$this->xref()] >= $access_level;
}
// Privacy rules do not apply to admins
if (Auth::PRIV_NONE >= $access_level) {
return true;
}
// Different types of record have different privacy rules
return $this->canShowByType($access_level);
} | php | private function canShowRecord(int $access_level): bool
{
// This setting would better be called "$ENABLE_PRIVACY"
if (!$this->tree->getPreference('HIDE_LIVE_PEOPLE')) {
return true;
}
// We should always be able to see our own record (unless an admin is applying download restrictions)
if ($this->xref() === $this->tree->getUserPreference(Auth::user(), 'gedcomid') && $access_level === Auth::accessLevel($this->tree)) {
return true;
}
// Does this record have a RESN?
if (strpos($this->gedcom, "\n1 RESN confidential") !== false) {
return Auth::PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN privacy") !== false) {
return Auth::PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN none") !== false) {
return true;
}
// Does this record have a default RESN?
$individual_privacy = $this->tree->getIndividualPrivacy();
if (isset($individual_privacy[$this->xref()])) {
return $individual_privacy[$this->xref()] >= $access_level;
}
// Privacy rules do not apply to admins
if (Auth::PRIV_NONE >= $access_level) {
return true;
}
// Different types of record have different privacy rules
return $this->canShowByType($access_level);
} | [
"private",
"function",
"canShowRecord",
"(",
"int",
"$",
"access_level",
")",
":",
"bool",
"{",
"// This setting would better be called \"$ENABLE_PRIVACY\"",
"if",
"(",
"!",
"$",
"this",
"->",
"tree",
"->",
"getPreference",
"(",
"'HIDE_LIVE_PEOPLE'",
")",
")",
"{",
"return",
"true",
";",
"}",
"// We should always be able to see our own record (unless an admin is applying download restrictions)",
"if",
"(",
"$",
"this",
"->",
"xref",
"(",
")",
"===",
"$",
"this",
"->",
"tree",
"->",
"getUserPreference",
"(",
"Auth",
"::",
"user",
"(",
")",
",",
"'gedcomid'",
")",
"&&",
"$",
"access_level",
"===",
"Auth",
"::",
"accessLevel",
"(",
"$",
"this",
"->",
"tree",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Does this record have a RESN?",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n1 RESN confidential\"",
")",
"!==",
"false",
")",
"{",
"return",
"Auth",
"::",
"PRIV_NONE",
">=",
"$",
"access_level",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n1 RESN privacy\"",
")",
"!==",
"false",
")",
"{",
"return",
"Auth",
"::",
"PRIV_USER",
">=",
"$",
"access_level",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"gedcom",
",",
"\"\\n1 RESN none\"",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// Does this record have a default RESN?",
"$",
"individual_privacy",
"=",
"$",
"this",
"->",
"tree",
"->",
"getIndividualPrivacy",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"individual_privacy",
"[",
"$",
"this",
"->",
"xref",
"(",
")",
"]",
")",
")",
"{",
"return",
"$",
"individual_privacy",
"[",
"$",
"this",
"->",
"xref",
"(",
")",
"]",
">=",
"$",
"access_level",
";",
"}",
"// Privacy rules do not apply to admins",
"if",
"(",
"Auth",
"::",
"PRIV_NONE",
">=",
"$",
"access_level",
")",
"{",
"return",
"true",
";",
"}",
"// Different types of record have different privacy rules",
"return",
"$",
"this",
"->",
"canShowByType",
"(",
"$",
"access_level",
")",
";",
"}"
] | Work out whether this record can be shown to a user with a given access level
@param int $access_level
@return bool | [
"Work",
"out",
"whether",
"this",
"record",
"can",
"be",
"shown",
"to",
"a",
"user",
"with",
"a",
"given",
"access",
"level"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L405-L441 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.canShow | public function canShow(int $access_level = null): bool
{
$access_level = $access_level ?? Auth::accessLevel($this->tree);
// We use this value to bypass privacy checks. For example,
// when downloading data or when calculating privacy itself.
if ($access_level === Auth::PRIV_HIDE) {
return true;
}
$cache_key = 'canShow' . $this->xref . ':' . $this->tree->id() . ':' . $access_level;
return app('cache.array')->rememberForever($cache_key, function () use ($access_level) {
return $this->canShowRecord($access_level);
});
} | php | public function canShow(int $access_level = null): bool
{
$access_level = $access_level ?? Auth::accessLevel($this->tree);
// We use this value to bypass privacy checks. For example,
// when downloading data or when calculating privacy itself.
if ($access_level === Auth::PRIV_HIDE) {
return true;
}
$cache_key = 'canShow' . $this->xref . ':' . $this->tree->id() . ':' . $access_level;
return app('cache.array')->rememberForever($cache_key, function () use ($access_level) {
return $this->canShowRecord($access_level);
});
} | [
"public",
"function",
"canShow",
"(",
"int",
"$",
"access_level",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"access_level",
"=",
"$",
"access_level",
"??",
"Auth",
"::",
"accessLevel",
"(",
"$",
"this",
"->",
"tree",
")",
";",
"// We use this value to bypass privacy checks. For example,",
"// when downloading data or when calculating privacy itself.",
"if",
"(",
"$",
"access_level",
"===",
"Auth",
"::",
"PRIV_HIDE",
")",
"{",
"return",
"true",
";",
"}",
"$",
"cache_key",
"=",
"'canShow'",
".",
"$",
"this",
"->",
"xref",
".",
"':'",
".",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
".",
"':'",
".",
"$",
"access_level",
";",
"return",
"app",
"(",
"'cache.array'",
")",
"->",
"rememberForever",
"(",
"$",
"cache_key",
",",
"function",
"(",
")",
"use",
"(",
"$",
"access_level",
")",
"{",
"return",
"$",
"this",
"->",
"canShowRecord",
"(",
"$",
"access_level",
")",
";",
"}",
")",
";",
"}"
] | Can the details of this record be shown?
@param int|null $access_level
@return bool | [
"Can",
"the",
"details",
"of",
"this",
"record",
"be",
"shown?"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L470-L485 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.privatizeGedcom | public function privatizeGedcom(int $access_level): string
{
if ($access_level === Auth::PRIV_HIDE) {
// We may need the original record, for example when downloading a GEDCOM or clippings cart
return $this->gedcom;
}
if ($this->canShow($access_level)) {
// The record is not private, but the individual facts may be.
// Include the entire first line (for NOTE records)
[$gedrec] = explode("\n", $this->gedcom, 2);
// Check each of the facts for access
foreach ($this->facts([], false, $access_level) as $fact) {
$gedrec .= "\n" . $fact->gedcom();
}
return $gedrec;
}
// We cannot display the details, but we may be able to display
// limited data, such as links to other records.
return $this->createPrivateGedcomRecord($access_level);
} | php | public function privatizeGedcom(int $access_level): string
{
if ($access_level === Auth::PRIV_HIDE) {
// We may need the original record, for example when downloading a GEDCOM or clippings cart
return $this->gedcom;
}
if ($this->canShow($access_level)) {
// The record is not private, but the individual facts may be.
// Include the entire first line (for NOTE records)
[$gedrec] = explode("\n", $this->gedcom, 2);
// Check each of the facts for access
foreach ($this->facts([], false, $access_level) as $fact) {
$gedrec .= "\n" . $fact->gedcom();
}
return $gedrec;
}
// We cannot display the details, but we may be able to display
// limited data, such as links to other records.
return $this->createPrivateGedcomRecord($access_level);
} | [
"public",
"function",
"privatizeGedcom",
"(",
"int",
"$",
"access_level",
")",
":",
"string",
"{",
"if",
"(",
"$",
"access_level",
"===",
"Auth",
"::",
"PRIV_HIDE",
")",
"{",
"// We may need the original record, for example when downloading a GEDCOM or clippings cart",
"return",
"$",
"this",
"->",
"gedcom",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"canShow",
"(",
"$",
"access_level",
")",
")",
"{",
"// The record is not private, but the individual facts may be.",
"// Include the entire first line (for NOTE records)",
"[",
"$",
"gedrec",
"]",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"gedcom",
",",
"2",
")",
";",
"// Check each of the facts for access",
"foreach",
"(",
"$",
"this",
"->",
"facts",
"(",
"[",
"]",
",",
"false",
",",
"$",
"access_level",
")",
"as",
"$",
"fact",
")",
"{",
"$",
"gedrec",
".=",
"\"\\n\"",
".",
"$",
"fact",
"->",
"gedcom",
"(",
")",
";",
"}",
"return",
"$",
"gedrec",
";",
"}",
"// We cannot display the details, but we may be able to display",
"// limited data, such as links to other records.",
"return",
"$",
"this",
"->",
"createPrivateGedcomRecord",
"(",
"$",
"access_level",
")",
";",
"}"
] | Remove private data from the raw gedcom record.
Return both the visible and invisible data. We need the invisible data when editing.
@param int $access_level
@return string | [
"Remove",
"private",
"data",
"from",
"the",
"raw",
"gedcom",
"record",
".",
"Return",
"both",
"the",
"visible",
"and",
"invisible",
"data",
".",
"We",
"need",
"the",
"invisible",
"data",
"when",
"editing",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L525-L549 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.alternateName | public function alternateName(): ?string
{
if ($this->canShowName() && $this->getPrimaryName() !== $this->getSecondaryName()) {
$all_names = $this->getAllNames();
return $all_names[$this->getSecondaryName()]['full'];
}
return null;
} | php | public function alternateName(): ?string
{
if ($this->canShowName() && $this->getPrimaryName() !== $this->getSecondaryName()) {
$all_names = $this->getAllNames();
return $all_names[$this->getSecondaryName()]['full'];
}
return null;
} | [
"public",
"function",
"alternateName",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"canShowName",
"(",
")",
"&&",
"$",
"this",
"->",
"getPrimaryName",
"(",
")",
"!==",
"$",
"this",
"->",
"getSecondaryName",
"(",
")",
")",
"{",
"$",
"all_names",
"=",
"$",
"this",
"->",
"getAllNames",
"(",
")",
";",
"return",
"$",
"all_names",
"[",
"$",
"this",
"->",
"getSecondaryName",
"(",
")",
"]",
"[",
"'full'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get the full name in an alternative character set
@return string|null | [
"Get",
"the",
"full",
"name",
"in",
"an",
"alternative",
"character",
"set"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L781-L790 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.formatList | public function formatList(): string
{
$html = '<a href="' . e($this->url()) . '" class="list_item">';
$html .= '<b>' . $this->fullName() . '</b>';
$html .= $this->formatListDetails();
$html .= '</a>';
return $html;
} | php | public function formatList(): string
{
$html = '<a href="' . e($this->url()) . '" class="list_item">';
$html .= '<b>' . $this->fullName() . '</b>';
$html .= $this->formatListDetails();
$html .= '</a>';
return $html;
} | [
"public",
"function",
"formatList",
"(",
")",
":",
"string",
"{",
"$",
"html",
"=",
"'<a href=\"'",
".",
"e",
"(",
"$",
"this",
"->",
"url",
"(",
")",
")",
".",
"'\" class=\"list_item\">'",
";",
"$",
"html",
".=",
"'<b>'",
".",
"$",
"this",
"->",
"fullName",
"(",
")",
".",
"'</b>'",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"formatListDetails",
"(",
")",
";",
"$",
"html",
".=",
"'</a>'",
";",
"return",
"$",
"html",
";",
"}"
] | Format this object for display in a list
@return string | [
"Format",
"this",
"object",
"for",
"display",
"in",
"a",
"list"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L797-L805 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.linkedRepositories | public function linkedRepositories(string $link): array
{
$rows = DB::table('other')
->join('link', static function (JoinClause $join): void {
$join->on('l_file', '=', 'o_file')->on('l_from', '=', 'o_id');
})
->where('o_file', '=', $this->tree->id())
->where('o_type', '=', 'REPO')
->where('l_type', '=', $link)
->where('l_to', '=', $this->xref)
->select(['o_id AS xref', 'o_gedcom AS gedcom'])
->get();
$list = [];
foreach ($rows as $row) {
$record = Repository::getInstance($row->xref, $this->tree, $row->gedcom);
if ($record->canShowName()) {
$list[] = $record;
}
}
return $list;
} | php | public function linkedRepositories(string $link): array
{
$rows = DB::table('other')
->join('link', static function (JoinClause $join): void {
$join->on('l_file', '=', 'o_file')->on('l_from', '=', 'o_id');
})
->where('o_file', '=', $this->tree->id())
->where('o_type', '=', 'REPO')
->where('l_type', '=', $link)
->where('l_to', '=', $this->xref)
->select(['o_id AS xref', 'o_gedcom AS gedcom'])
->get();
$list = [];
foreach ($rows as $row) {
$record = Repository::getInstance($row->xref, $this->tree, $row->gedcom);
if ($record->canShowName()) {
$list[] = $record;
}
}
return $list;
} | [
"public",
"function",
"linkedRepositories",
"(",
"string",
"$",
"link",
")",
":",
"array",
"{",
"$",
"rows",
"=",
"DB",
"::",
"table",
"(",
"'other'",
")",
"->",
"join",
"(",
"'link'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l_file'",
",",
"'='",
",",
"'o_file'",
")",
"->",
"on",
"(",
"'l_from'",
",",
"'='",
",",
"'o_id'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'o_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'o_type'",
",",
"'='",
",",
"'REPO'",
")",
"->",
"where",
"(",
"'l_type'",
",",
"'='",
",",
"$",
"link",
")",
"->",
"where",
"(",
"'l_to'",
",",
"'='",
",",
"$",
"this",
"->",
"xref",
")",
"->",
"select",
"(",
"[",
"'o_id AS xref'",
",",
"'o_gedcom AS gedcom'",
"]",
")",
"->",
"get",
"(",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"record",
"=",
"Repository",
"::",
"getInstance",
"(",
"$",
"row",
"->",
"xref",
",",
"$",
"this",
"->",
"tree",
",",
"$",
"row",
"->",
"gedcom",
")",
";",
"if",
"(",
"$",
"record",
"->",
"canShowName",
"(",
")",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] | Find repositories linked to this record.
@param string $link
@return Repository[] | [
"Find",
"repositories",
"linked",
"to",
"this",
"record",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1006-L1028 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.getAllEventPlaces | public function getAllEventPlaces(array $events): array
{
$places = [];
foreach ($this->facts($events) as $event) {
if (preg_match_all('/\n(?:2 PLAC|3 (?:ROMN|FONE|_HEB)) +(.+)/', $event->gedcom(), $ged_places)) {
foreach ($ged_places[1] as $ged_place) {
$places[] = new Place($ged_place, $this->tree);
}
}
}
return $places;
} | php | public function getAllEventPlaces(array $events): array
{
$places = [];
foreach ($this->facts($events) as $event) {
if (preg_match_all('/\n(?:2 PLAC|3 (?:ROMN|FONE|_HEB)) +(.+)/', $event->gedcom(), $ged_places)) {
foreach ($ged_places[1] as $ged_place) {
$places[] = new Place($ged_place, $this->tree);
}
}
}
return $places;
} | [
"public",
"function",
"getAllEventPlaces",
"(",
"array",
"$",
"events",
")",
":",
"array",
"{",
"$",
"places",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"facts",
"(",
"$",
"events",
")",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"preg_match_all",
"(",
"'/\\n(?:2 PLAC|3 (?:ROMN|FONE|_HEB)) +(.+)/'",
",",
"$",
"event",
"->",
"gedcom",
"(",
")",
",",
"$",
"ged_places",
")",
")",
"{",
"foreach",
"(",
"$",
"ged_places",
"[",
"1",
"]",
"as",
"$",
"ged_place",
")",
"{",
"$",
"places",
"[",
"]",
"=",
"new",
"Place",
"(",
"$",
"ged_place",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}",
"}",
"}",
"return",
"$",
"places",
";",
"}"
] | Get all the places for a particular type of event
@param string[] $events
@return Place[] | [
"Get",
"all",
"the",
"places",
"for",
"a",
"particular",
"type",
"of",
"event"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1060-L1072 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.facts | public function facts(array $filter = [], bool $sort = false, int $access_level = null, bool $override = false): Collection
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->tree);
}
$facts = new Collection();
if ($this->canShow($access_level) || $override) {
foreach ($this->facts as $fact) {
if (($filter === [] || in_array($fact->getTag(), $filter, true)) && $fact->canShow($access_level)) {
$facts->push($fact);
}
}
}
if ($sort) {
$facts = Fact::sortFacts($facts);
}
return new Collection($facts);
} | php | public function facts(array $filter = [], bool $sort = false, int $access_level = null, bool $override = false): Collection
{
if ($access_level === null) {
$access_level = Auth::accessLevel($this->tree);
}
$facts = new Collection();
if ($this->canShow($access_level) || $override) {
foreach ($this->facts as $fact) {
if (($filter === [] || in_array($fact->getTag(), $filter, true)) && $fact->canShow($access_level)) {
$facts->push($fact);
}
}
}
if ($sort) {
$facts = Fact::sortFacts($facts);
}
return new Collection($facts);
} | [
"public",
"function",
"facts",
"(",
"array",
"$",
"filter",
"=",
"[",
"]",
",",
"bool",
"$",
"sort",
"=",
"false",
",",
"int",
"$",
"access_level",
"=",
"null",
",",
"bool",
"$",
"override",
"=",
"false",
")",
":",
"Collection",
"{",
"if",
"(",
"$",
"access_level",
"===",
"null",
")",
"{",
"$",
"access_level",
"=",
"Auth",
"::",
"accessLevel",
"(",
"$",
"this",
"->",
"tree",
")",
";",
"}",
"$",
"facts",
"=",
"new",
"Collection",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"canShow",
"(",
"$",
"access_level",
")",
"||",
"$",
"override",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"facts",
"as",
"$",
"fact",
")",
"{",
"if",
"(",
"(",
"$",
"filter",
"===",
"[",
"]",
"||",
"in_array",
"(",
"$",
"fact",
"->",
"getTag",
"(",
")",
",",
"$",
"filter",
",",
"true",
")",
")",
"&&",
"$",
"fact",
"->",
"canShow",
"(",
"$",
"access_level",
")",
")",
"{",
"$",
"facts",
"->",
"push",
"(",
"$",
"fact",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"sort",
")",
"{",
"$",
"facts",
"=",
"Fact",
"::",
"sortFacts",
"(",
"$",
"facts",
")",
";",
"}",
"return",
"new",
"Collection",
"(",
"$",
"facts",
")",
";",
"}"
] | The facts and events for this record.
@param string[] $filter
@param bool $sort
@param int|null $access_level
@param bool $override Include private records, to allow us to implement $SHOW_PRIVATE_RELATIONSHIPS and $SHOW_LIVING_NAMES.
@return Collection
@return Fact[] | [
"The",
"facts",
"and",
"events",
"for",
"this",
"record",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1085-L1105 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.lastChangeTimestamp | public function lastChangeTimestamp(): Carbon
{
/** @var Fact|null $chan */
$chan = $this->facts(['CHAN'])->first();
if ($chan instanceof Fact) {
// The record does have a CHAN event
$d = $chan->date()->minimumDate();
if (preg_match('/\n3 TIME (\d\d):(\d\d):(\d\d)/', $chan->gedcom(), $match)) {
return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2], (int) $match[3]);
}
if (preg_match('/\n3 TIME (\d\d):(\d\d)/', $chan->gedcom(), $match)) {
return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2]);
}
return Carbon::create($d->year(), $d->month(), $d->day());
}
// The record does not have a CHAN event
return Carbon::createFromTimestamp(0);
} | php | public function lastChangeTimestamp(): Carbon
{
/** @var Fact|null $chan */
$chan = $this->facts(['CHAN'])->first();
if ($chan instanceof Fact) {
// The record does have a CHAN event
$d = $chan->date()->minimumDate();
if (preg_match('/\n3 TIME (\d\d):(\d\d):(\d\d)/', $chan->gedcom(), $match)) {
return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2], (int) $match[3]);
}
if (preg_match('/\n3 TIME (\d\d):(\d\d)/', $chan->gedcom(), $match)) {
return Carbon::create($d->year(), $d->month(), $d->day(), (int) $match[1], (int) $match[2]);
}
return Carbon::create($d->year(), $d->month(), $d->day());
}
// The record does not have a CHAN event
return Carbon::createFromTimestamp(0);
} | [
"public",
"function",
"lastChangeTimestamp",
"(",
")",
":",
"Carbon",
"{",
"/** @var Fact|null $chan */",
"$",
"chan",
"=",
"$",
"this",
"->",
"facts",
"(",
"[",
"'CHAN'",
"]",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"chan",
"instanceof",
"Fact",
")",
"{",
"// The record does have a CHAN event",
"$",
"d",
"=",
"$",
"chan",
"->",
"date",
"(",
")",
"->",
"minimumDate",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/\\n3 TIME (\\d\\d):(\\d\\d):(\\d\\d)/'",
",",
"$",
"chan",
"->",
"gedcom",
"(",
")",
",",
"$",
"match",
")",
")",
"{",
"return",
"Carbon",
"::",
"create",
"(",
"$",
"d",
"->",
"year",
"(",
")",
",",
"$",
"d",
"->",
"month",
"(",
")",
",",
"$",
"d",
"->",
"day",
"(",
")",
",",
"(",
"int",
")",
"$",
"match",
"[",
"1",
"]",
",",
"(",
"int",
")",
"$",
"match",
"[",
"2",
"]",
",",
"(",
"int",
")",
"$",
"match",
"[",
"3",
"]",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/\\n3 TIME (\\d\\d):(\\d\\d)/'",
",",
"$",
"chan",
"->",
"gedcom",
"(",
")",
",",
"$",
"match",
")",
")",
"{",
"return",
"Carbon",
"::",
"create",
"(",
"$",
"d",
"->",
"year",
"(",
")",
",",
"$",
"d",
"->",
"month",
"(",
")",
",",
"$",
"d",
"->",
"day",
"(",
")",
",",
"(",
"int",
")",
"$",
"match",
"[",
"1",
"]",
",",
"(",
"int",
")",
"$",
"match",
"[",
"2",
"]",
")",
";",
"}",
"return",
"Carbon",
"::",
"create",
"(",
"$",
"d",
"->",
"year",
"(",
")",
",",
"$",
"d",
"->",
"month",
"(",
")",
",",
"$",
"d",
"->",
"day",
"(",
")",
")",
";",
"}",
"// The record does not have a CHAN event",
"return",
"Carbon",
"::",
"createFromTimestamp",
"(",
"0",
")",
";",
"}"
] | Get the last-change timestamp for this record
@return Carbon | [
"Get",
"the",
"last",
"-",
"change",
"timestamp",
"for",
"this",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1112-L1134 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.lastChangeUser | public function lastChangeUser(): string
{
$chan = $this->facts(['CHAN'])->first();
if ($chan === null) {
return I18N::translate('Unknown');
}
$chan_user = $chan->attribute('_WT_USER');
if ($chan_user === '') {
return I18N::translate('Unknown');
}
return $chan_user;
} | php | public function lastChangeUser(): string
{
$chan = $this->facts(['CHAN'])->first();
if ($chan === null) {
return I18N::translate('Unknown');
}
$chan_user = $chan->attribute('_WT_USER');
if ($chan_user === '') {
return I18N::translate('Unknown');
}
return $chan_user;
} | [
"public",
"function",
"lastChangeUser",
"(",
")",
":",
"string",
"{",
"$",
"chan",
"=",
"$",
"this",
"->",
"facts",
"(",
"[",
"'CHAN'",
"]",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"chan",
"===",
"null",
")",
"{",
"return",
"I18N",
"::",
"translate",
"(",
"'Unknown'",
")",
";",
"}",
"$",
"chan_user",
"=",
"$",
"chan",
"->",
"attribute",
"(",
"'_WT_USER'",
")",
";",
"if",
"(",
"$",
"chan_user",
"===",
"''",
")",
"{",
"return",
"I18N",
"::",
"translate",
"(",
"'Unknown'",
")",
";",
"}",
"return",
"$",
"chan_user",
";",
"}"
] | Get the last-change user for this record
@return string | [
"Get",
"the",
"last",
"-",
"change",
"user",
"for",
"this",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1141-L1155 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.createFact | public function createFact(string $gedcom, bool $update_chan): void
{
$this->updateFact('', $gedcom, $update_chan);
} | php | public function createFact(string $gedcom, bool $update_chan): void
{
$this->updateFact('', $gedcom, $update_chan);
} | [
"public",
"function",
"createFact",
"(",
"string",
"$",
"gedcom",
",",
"bool",
"$",
"update_chan",
")",
":",
"void",
"{",
"$",
"this",
"->",
"updateFact",
"(",
"''",
",",
"$",
"gedcom",
",",
"$",
"update_chan",
")",
";",
"}"
] | Add a new fact to this record
@param string $gedcom
@param bool $update_chan
@return void | [
"Add",
"a",
"new",
"fact",
"to",
"this",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1165-L1168 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.deleteFact | public function deleteFact(string $fact_id, bool $update_chan): void
{
$this->updateFact($fact_id, '', $update_chan);
} | php | public function deleteFact(string $fact_id, bool $update_chan): void
{
$this->updateFact($fact_id, '', $update_chan);
} | [
"public",
"function",
"deleteFact",
"(",
"string",
"$",
"fact_id",
",",
"bool",
"$",
"update_chan",
")",
":",
"void",
"{",
"$",
"this",
"->",
"updateFact",
"(",
"$",
"fact_id",
",",
"''",
",",
"$",
"update_chan",
")",
";",
"}"
] | Delete a fact from this record
@param string $fact_id
@param bool $update_chan
@return void | [
"Delete",
"a",
"fact",
"from",
"this",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1178-L1181 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.updateFact | public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
{
// MSDOS line endings will break things in horrible ways
$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
$gedcom = trim($gedcom);
if ($this->pending === '') {
throw new Exception('Cannot edit a deleted record');
}
if ($gedcom !== '' && !preg_match('/^1 ' . Gedcom::REGEX_TAG . '/', $gedcom)) {
throw new Exception('Invalid GEDCOM data passed to GedcomRecord::updateFact(' . $gedcom . ')');
}
if ($this->pending) {
$old_gedcom = $this->pending;
} else {
$old_gedcom = $this->gedcom;
}
// First line of record may contain data - e.g. NOTE records.
[$new_gedcom] = explode("\n", $old_gedcom, 2);
// Replacing (or deleting) an existing fact
foreach ($this->facts([], false, Auth::PRIV_HIDE) as $fact) {
if (!$fact->isPendingDeletion()) {
if ($fact->id() === $fact_id) {
if ($gedcom !== '') {
$new_gedcom .= "\n" . $gedcom;
}
$fact_id = 'NOT A VALID FACT ID'; // Only replace/delete one copy of a duplicate fact
} elseif ($fact->getTag() !== 'CHAN' || !$update_chan) {
$new_gedcom .= "\n" . $fact->gedcom();
}
}
}
if ($update_chan) {
$new_gedcom .= "\n1 CHAN\n2 DATE " . strtoupper(date('d M Y')) . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
}
// Adding a new fact
if ($fact_id === '') {
$new_gedcom .= "\n" . $gedcom;
}
if ($new_gedcom !== $old_gedcom) {
// Save the changes
DB::table('change')->insert([
'gedcom_id' => $this->tree->id(),
'xref' => $this->xref,
'old_gedcom' => $old_gedcom,
'new_gedcom' => $new_gedcom,
'user_id' => Auth::id(),
]);
$this->pending = $new_gedcom;
if (Auth::user()->getPreference('auto_accept')) {
FunctionsImport::acceptAllChanges($this->xref, $this->tree);
$this->gedcom = $new_gedcom;
$this->pending = null;
}
}
$this->parseFacts();
} | php | public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
{
// MSDOS line endings will break things in horrible ways
$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
$gedcom = trim($gedcom);
if ($this->pending === '') {
throw new Exception('Cannot edit a deleted record');
}
if ($gedcom !== '' && !preg_match('/^1 ' . Gedcom::REGEX_TAG . '/', $gedcom)) {
throw new Exception('Invalid GEDCOM data passed to GedcomRecord::updateFact(' . $gedcom . ')');
}
if ($this->pending) {
$old_gedcom = $this->pending;
} else {
$old_gedcom = $this->gedcom;
}
// First line of record may contain data - e.g. NOTE records.
[$new_gedcom] = explode("\n", $old_gedcom, 2);
// Replacing (or deleting) an existing fact
foreach ($this->facts([], false, Auth::PRIV_HIDE) as $fact) {
if (!$fact->isPendingDeletion()) {
if ($fact->id() === $fact_id) {
if ($gedcom !== '') {
$new_gedcom .= "\n" . $gedcom;
}
$fact_id = 'NOT A VALID FACT ID'; // Only replace/delete one copy of a duplicate fact
} elseif ($fact->getTag() !== 'CHAN' || !$update_chan) {
$new_gedcom .= "\n" . $fact->gedcom();
}
}
}
if ($update_chan) {
$new_gedcom .= "\n1 CHAN\n2 DATE " . strtoupper(date('d M Y')) . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
}
// Adding a new fact
if ($fact_id === '') {
$new_gedcom .= "\n" . $gedcom;
}
if ($new_gedcom !== $old_gedcom) {
// Save the changes
DB::table('change')->insert([
'gedcom_id' => $this->tree->id(),
'xref' => $this->xref,
'old_gedcom' => $old_gedcom,
'new_gedcom' => $new_gedcom,
'user_id' => Auth::id(),
]);
$this->pending = $new_gedcom;
if (Auth::user()->getPreference('auto_accept')) {
FunctionsImport::acceptAllChanges($this->xref, $this->tree);
$this->gedcom = $new_gedcom;
$this->pending = null;
}
}
$this->parseFacts();
} | [
"public",
"function",
"updateFact",
"(",
"string",
"$",
"fact_id",
",",
"string",
"$",
"gedcom",
",",
"bool",
"$",
"update_chan",
")",
":",
"void",
"{",
"// MSDOS line endings will break things in horrible ways",
"$",
"gedcom",
"=",
"preg_replace",
"(",
"'/[\\r\\n]+/'",
",",
"\"\\n\"",
",",
"$",
"gedcom",
")",
";",
"$",
"gedcom",
"=",
"trim",
"(",
"$",
"gedcom",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pending",
"===",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot edit a deleted record'",
")",
";",
"}",
"if",
"(",
"$",
"gedcom",
"!==",
"''",
"&&",
"!",
"preg_match",
"(",
"'/^1 '",
".",
"Gedcom",
"::",
"REGEX_TAG",
".",
"'/'",
",",
"$",
"gedcom",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid GEDCOM data passed to GedcomRecord::updateFact('",
".",
"$",
"gedcom",
".",
"')'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pending",
")",
"{",
"$",
"old_gedcom",
"=",
"$",
"this",
"->",
"pending",
";",
"}",
"else",
"{",
"$",
"old_gedcom",
"=",
"$",
"this",
"->",
"gedcom",
";",
"}",
"// First line of record may contain data - e.g. NOTE records.",
"[",
"$",
"new_gedcom",
"]",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"old_gedcom",
",",
"2",
")",
";",
"// Replacing (or deleting) an existing fact",
"foreach",
"(",
"$",
"this",
"->",
"facts",
"(",
"[",
"]",
",",
"false",
",",
"Auth",
"::",
"PRIV_HIDE",
")",
"as",
"$",
"fact",
")",
"{",
"if",
"(",
"!",
"$",
"fact",
"->",
"isPendingDeletion",
"(",
")",
")",
"{",
"if",
"(",
"$",
"fact",
"->",
"id",
"(",
")",
"===",
"$",
"fact_id",
")",
"{",
"if",
"(",
"$",
"gedcom",
"!==",
"''",
")",
"{",
"$",
"new_gedcom",
".=",
"\"\\n\"",
".",
"$",
"gedcom",
";",
"}",
"$",
"fact_id",
"=",
"'NOT A VALID FACT ID'",
";",
"// Only replace/delete one copy of a duplicate fact",
"}",
"elseif",
"(",
"$",
"fact",
"->",
"getTag",
"(",
")",
"!==",
"'CHAN'",
"||",
"!",
"$",
"update_chan",
")",
"{",
"$",
"new_gedcom",
".=",
"\"\\n\"",
".",
"$",
"fact",
"->",
"gedcom",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"update_chan",
")",
"{",
"$",
"new_gedcom",
".=",
"\"\\n1 CHAN\\n2 DATE \"",
".",
"strtoupper",
"(",
"date",
"(",
"'d M Y'",
")",
")",
".",
"\"\\n3 TIME \"",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"\"\\n2 _WT_USER \"",
".",
"Auth",
"::",
"user",
"(",
")",
"->",
"userName",
"(",
")",
";",
"}",
"// Adding a new fact",
"if",
"(",
"$",
"fact_id",
"===",
"''",
")",
"{",
"$",
"new_gedcom",
".=",
"\"\\n\"",
".",
"$",
"gedcom",
";",
"}",
"if",
"(",
"$",
"new_gedcom",
"!==",
"$",
"old_gedcom",
")",
"{",
"// Save the changes",
"DB",
"::",
"table",
"(",
"'change'",
")",
"->",
"insert",
"(",
"[",
"'gedcom_id'",
"=>",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
",",
"'xref'",
"=>",
"$",
"this",
"->",
"xref",
",",
"'old_gedcom'",
"=>",
"$",
"old_gedcom",
",",
"'new_gedcom'",
"=>",
"$",
"new_gedcom",
",",
"'user_id'",
"=>",
"Auth",
"::",
"id",
"(",
")",
",",
"]",
")",
";",
"$",
"this",
"->",
"pending",
"=",
"$",
"new_gedcom",
";",
"if",
"(",
"Auth",
"::",
"user",
"(",
")",
"->",
"getPreference",
"(",
"'auto_accept'",
")",
")",
"{",
"FunctionsImport",
"::",
"acceptAllChanges",
"(",
"$",
"this",
"->",
"xref",
",",
"$",
"this",
"->",
"tree",
")",
";",
"$",
"this",
"->",
"gedcom",
"=",
"$",
"new_gedcom",
";",
"$",
"this",
"->",
"pending",
"=",
"null",
";",
"}",
"}",
"$",
"this",
"->",
"parseFacts",
"(",
")",
";",
"}"
] | Replace a fact with a new gedcom data.
@param string $fact_id
@param string $gedcom
@param bool $update_chan
@return void
@throws Exception | [
"Replace",
"a",
"fact",
"with",
"a",
"new",
"gedcom",
"data",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1193-L1256 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.updateRecord | public function updateRecord(string $gedcom, bool $update_chan): void
{
// MSDOS line endings will break things in horrible ways
$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
$gedcom = trim($gedcom);
// Update the CHAN record
if ($update_chan) {
$gedcom = preg_replace('/\n1 CHAN(\n[2-9].*)*/', '', $gedcom);
$gedcom .= "\n1 CHAN\n2 DATE " . date('d M Y') . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
}
// Create a pending change
DB::table('change')->insert([
'gedcom_id' => $this->tree->id(),
'xref' => $this->xref,
'old_gedcom' => $this->gedcom(),
'new_gedcom' => $gedcom,
'user_id' => Auth::id(),
]);
// Clear the cache
$this->pending = $gedcom;
// Accept this pending change
if (Auth::user()->getPreference('auto_accept')) {
FunctionsImport::acceptAllChanges($this->xref, $this->tree);
$this->gedcom = $gedcom;
$this->pending = null;
}
$this->parseFacts();
Log::addEditLog('Update: ' . static::RECORD_TYPE . ' ' . $this->xref, $this->tree);
} | php | public function updateRecord(string $gedcom, bool $update_chan): void
{
// MSDOS line endings will break things in horrible ways
$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
$gedcom = trim($gedcom);
// Update the CHAN record
if ($update_chan) {
$gedcom = preg_replace('/\n1 CHAN(\n[2-9].*)*/', '', $gedcom);
$gedcom .= "\n1 CHAN\n2 DATE " . date('d M Y') . "\n3 TIME " . date('H:i:s') . "\n2 _WT_USER " . Auth::user()->userName();
}
// Create a pending change
DB::table('change')->insert([
'gedcom_id' => $this->tree->id(),
'xref' => $this->xref,
'old_gedcom' => $this->gedcom(),
'new_gedcom' => $gedcom,
'user_id' => Auth::id(),
]);
// Clear the cache
$this->pending = $gedcom;
// Accept this pending change
if (Auth::user()->getPreference('auto_accept')) {
FunctionsImport::acceptAllChanges($this->xref, $this->tree);
$this->gedcom = $gedcom;
$this->pending = null;
}
$this->parseFacts();
Log::addEditLog('Update: ' . static::RECORD_TYPE . ' ' . $this->xref, $this->tree);
} | [
"public",
"function",
"updateRecord",
"(",
"string",
"$",
"gedcom",
",",
"bool",
"$",
"update_chan",
")",
":",
"void",
"{",
"// MSDOS line endings will break things in horrible ways",
"$",
"gedcom",
"=",
"preg_replace",
"(",
"'/[\\r\\n]+/'",
",",
"\"\\n\"",
",",
"$",
"gedcom",
")",
";",
"$",
"gedcom",
"=",
"trim",
"(",
"$",
"gedcom",
")",
";",
"// Update the CHAN record",
"if",
"(",
"$",
"update_chan",
")",
"{",
"$",
"gedcom",
"=",
"preg_replace",
"(",
"'/\\n1 CHAN(\\n[2-9].*)*/'",
",",
"''",
",",
"$",
"gedcom",
")",
";",
"$",
"gedcom",
".=",
"\"\\n1 CHAN\\n2 DATE \"",
".",
"date",
"(",
"'d M Y'",
")",
".",
"\"\\n3 TIME \"",
".",
"date",
"(",
"'H:i:s'",
")",
".",
"\"\\n2 _WT_USER \"",
".",
"Auth",
"::",
"user",
"(",
")",
"->",
"userName",
"(",
")",
";",
"}",
"// Create a pending change",
"DB",
"::",
"table",
"(",
"'change'",
")",
"->",
"insert",
"(",
"[",
"'gedcom_id'",
"=>",
"$",
"this",
"->",
"tree",
"->",
"id",
"(",
")",
",",
"'xref'",
"=>",
"$",
"this",
"->",
"xref",
",",
"'old_gedcom'",
"=>",
"$",
"this",
"->",
"gedcom",
"(",
")",
",",
"'new_gedcom'",
"=>",
"$",
"gedcom",
",",
"'user_id'",
"=>",
"Auth",
"::",
"id",
"(",
")",
",",
"]",
")",
";",
"// Clear the cache",
"$",
"this",
"->",
"pending",
"=",
"$",
"gedcom",
";",
"// Accept this pending change",
"if",
"(",
"Auth",
"::",
"user",
"(",
")",
"->",
"getPreference",
"(",
"'auto_accept'",
")",
")",
"{",
"FunctionsImport",
"::",
"acceptAllChanges",
"(",
"$",
"this",
"->",
"xref",
",",
"$",
"this",
"->",
"tree",
")",
";",
"$",
"this",
"->",
"gedcom",
"=",
"$",
"gedcom",
";",
"$",
"this",
"->",
"pending",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"parseFacts",
"(",
")",
";",
"Log",
"::",
"addEditLog",
"(",
"'Update: '",
".",
"static",
"::",
"RECORD_TYPE",
".",
"' '",
".",
"$",
"this",
"->",
"xref",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}"
] | Update this record
@param string $gedcom
@param bool $update_chan
@return void | [
"Update",
"this",
"record"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1266-L1300 | train |
fisharebest/webtrees | app/GedcomRecord.php | GedcomRecord.linkingRecords | public function linkingRecords(): array
{
$union = DB::table('change')
->where('gedcom_id', '=', $this->tree()->id())
->whereContains('new_gedcom', '@' . $this->xref() . '@')
->where('new_gedcom', 'NOT LIKE', '0 @' . $this->xref() . '@%')
->select(['xref']);
$xrefs = DB::table('link')
->where('l_file', '=', $this->tree()->id())
->where('l_to', '=', $this->xref())
->select('l_from')
->union($union)
->pluck('l_from');
return $xrefs->map(function (string $xref): GedcomRecord {
return GedcomRecord::getInstance($xref, $this->tree);
})->all();
} | php | public function linkingRecords(): array
{
$union = DB::table('change')
->where('gedcom_id', '=', $this->tree()->id())
->whereContains('new_gedcom', '@' . $this->xref() . '@')
->where('new_gedcom', 'NOT LIKE', '0 @' . $this->xref() . '@%')
->select(['xref']);
$xrefs = DB::table('link')
->where('l_file', '=', $this->tree()->id())
->where('l_to', '=', $this->xref())
->select('l_from')
->union($union)
->pluck('l_from');
return $xrefs->map(function (string $xref): GedcomRecord {
return GedcomRecord::getInstance($xref, $this->tree);
})->all();
} | [
"public",
"function",
"linkingRecords",
"(",
")",
":",
"array",
"{",
"$",
"union",
"=",
"DB",
"::",
"table",
"(",
"'change'",
")",
"->",
"where",
"(",
"'gedcom_id'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"(",
")",
"->",
"id",
"(",
")",
")",
"->",
"whereContains",
"(",
"'new_gedcom'",
",",
"'@'",
".",
"$",
"this",
"->",
"xref",
"(",
")",
".",
"'@'",
")",
"->",
"where",
"(",
"'new_gedcom'",
",",
"'NOT LIKE'",
",",
"'0 @'",
".",
"$",
"this",
"->",
"xref",
"(",
")",
".",
"'@%'",
")",
"->",
"select",
"(",
"[",
"'xref'",
"]",
")",
";",
"$",
"xrefs",
"=",
"DB",
"::",
"table",
"(",
"'link'",
")",
"->",
"where",
"(",
"'l_file'",
",",
"'='",
",",
"$",
"this",
"->",
"tree",
"(",
")",
"->",
"id",
"(",
")",
")",
"->",
"where",
"(",
"'l_to'",
",",
"'='",
",",
"$",
"this",
"->",
"xref",
"(",
")",
")",
"->",
"select",
"(",
"'l_from'",
")",
"->",
"union",
"(",
"$",
"union",
")",
"->",
"pluck",
"(",
"'l_from'",
")",
";",
"return",
"$",
"xrefs",
"->",
"map",
"(",
"function",
"(",
"string",
"$",
"xref",
")",
":",
"GedcomRecord",
"{",
"return",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"this",
"->",
"tree",
")",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Fetch XREFs of all records linked to a record - when deleting an object, we must
also delete all links to it.
@return GedcomRecord[] | [
"Fetch",
"XREFs",
"of",
"all",
"records",
"linked",
"to",
"a",
"record",
"-",
"when",
"deleting",
"an",
"object",
"we",
"must",
"also",
"delete",
"all",
"links",
"to",
"it",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomRecord.php#L1365-L1383 | train |
fisharebest/webtrees | app/Statistics/Google/ChartSex.php | ChartSex.chartSex | public function chartSex(
int $tot_m,
int $tot_f,
int $tot_u,
string $color_female = null,
string $color_male = null,
string $color_unknown = null
): string {
$color_female = $color_female ?? '#ffd1dc';
$color_male = $color_male ?? '#84beff';
$color_unknown = $color_unknown ?? '#777777';
$data = [
[
I18N::translate('Type'),
I18N::translate('Total')
],
];
if ($tot_m || $tot_f || $tot_u) {
$data[] = [
I18N::translate('Males'),
$tot_m
];
$data[] = [
I18N::translate('Females'),
$tot_f
];
$data[] = [
I18N::translate('Unknown'),
$tot_u
];
}
return view(
'statistics/other/charts/pie',
[
'title' => null,
'data' => $data,
'colors' => [$color_male, $color_female, $color_unknown],
'labeledValueText' => 'percentage',
]
);
} | php | public function chartSex(
int $tot_m,
int $tot_f,
int $tot_u,
string $color_female = null,
string $color_male = null,
string $color_unknown = null
): string {
$color_female = $color_female ?? '#ffd1dc';
$color_male = $color_male ?? '#84beff';
$color_unknown = $color_unknown ?? '#777777';
$data = [
[
I18N::translate('Type'),
I18N::translate('Total')
],
];
if ($tot_m || $tot_f || $tot_u) {
$data[] = [
I18N::translate('Males'),
$tot_m
];
$data[] = [
I18N::translate('Females'),
$tot_f
];
$data[] = [
I18N::translate('Unknown'),
$tot_u
];
}
return view(
'statistics/other/charts/pie',
[
'title' => null,
'data' => $data,
'colors' => [$color_male, $color_female, $color_unknown],
'labeledValueText' => 'percentage',
]
);
} | [
"public",
"function",
"chartSex",
"(",
"int",
"$",
"tot_m",
",",
"int",
"$",
"tot_f",
",",
"int",
"$",
"tot_u",
",",
"string",
"$",
"color_female",
"=",
"null",
",",
"string",
"$",
"color_male",
"=",
"null",
",",
"string",
"$",
"color_unknown",
"=",
"null",
")",
":",
"string",
"{",
"$",
"color_female",
"=",
"$",
"color_female",
"??",
"'#ffd1dc'",
";",
"$",
"color_male",
"=",
"$",
"color_male",
"??",
"'#84beff'",
";",
"$",
"color_unknown",
"=",
"$",
"color_unknown",
"??",
"'#777777'",
";",
"$",
"data",
"=",
"[",
"[",
"I18N",
"::",
"translate",
"(",
"'Type'",
")",
",",
"I18N",
"::",
"translate",
"(",
"'Total'",
")",
"]",
",",
"]",
";",
"if",
"(",
"$",
"tot_m",
"||",
"$",
"tot_f",
"||",
"$",
"tot_u",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"[",
"I18N",
"::",
"translate",
"(",
"'Males'",
")",
",",
"$",
"tot_m",
"]",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"I18N",
"::",
"translate",
"(",
"'Females'",
")",
",",
"$",
"tot_f",
"]",
";",
"$",
"data",
"[",
"]",
"=",
"[",
"I18N",
"::",
"translate",
"(",
"'Unknown'",
")",
",",
"$",
"tot_u",
"]",
";",
"}",
"return",
"view",
"(",
"'statistics/other/charts/pie'",
",",
"[",
"'title'",
"=>",
"null",
",",
"'data'",
"=>",
"$",
"data",
",",
"'colors'",
"=>",
"[",
"$",
"color_male",
",",
"$",
"color_female",
",",
"$",
"color_unknown",
"]",
",",
"'labeledValueText'",
"=>",
"'percentage'",
",",
"]",
")",
";",
"}"
] | Generate a chart showing sex distribution.
@param int $tot_m The total number of male individuals
@param int $tot_f The total number of female individuals
@param int $tot_u The total number of unknown individuals
@param string|null $color_female
@param string|null $color_male
@param string|null $color_unknown
@return string | [
"Generate",
"a",
"chart",
"showing",
"sex",
"distribution",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartSex.php#L39-L84 | train |
fisharebest/webtrees | app/Http/Controllers/EditNoteController.php | EditNoteController.createNoteObjectAction | public function createNoteObjectAction(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$note = $request->get('note', '');
$privacy_restriction = $request->get('privacy-restriction', '');
$edit_restriction = $request->get('edit-restriction', '');
// Convert line endings to GEDDCOM continuations
$note = preg_replace('/\r|\r\n|\n|\r/', "\n1 CONT ", $note);
$gedcom = '0 @@ NOTE ' . $note;
if (in_array($privacy_restriction, [
'none',
'privacy',
'confidential',
])) {
$gedcom .= "\n1 RESN " . $privacy_restriction;
}
if (in_array($edit_restriction, ['locked'])) {
$gedcom .= "\n1 RESN " . $edit_restriction;
}
$record = $tree->createRecord($gedcom);
return response([
'id' => $record->xref(),
'text' => view('selects/note', [
'note' => $record,
]),
'html' => view('modals/record-created', [
'title' => I18N::translate('The note has been created'),
'name' => $record->fullName(),
'url' => $record->url(),
]),
]);
} | php | public function createNoteObjectAction(ServerRequestInterface $request, Tree $tree): ResponseInterface
{
$note = $request->get('note', '');
$privacy_restriction = $request->get('privacy-restriction', '');
$edit_restriction = $request->get('edit-restriction', '');
// Convert line endings to GEDDCOM continuations
$note = preg_replace('/\r|\r\n|\n|\r/', "\n1 CONT ", $note);
$gedcom = '0 @@ NOTE ' . $note;
if (in_array($privacy_restriction, [
'none',
'privacy',
'confidential',
])) {
$gedcom .= "\n1 RESN " . $privacy_restriction;
}
if (in_array($edit_restriction, ['locked'])) {
$gedcom .= "\n1 RESN " . $edit_restriction;
}
$record = $tree->createRecord($gedcom);
return response([
'id' => $record->xref(),
'text' => view('selects/note', [
'note' => $record,
]),
'html' => view('modals/record-created', [
'title' => I18N::translate('The note has been created'),
'name' => $record->fullName(),
'url' => $record->url(),
]),
]);
} | [
"public",
"function",
"createNoteObjectAction",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Tree",
"$",
"tree",
")",
":",
"ResponseInterface",
"{",
"$",
"note",
"=",
"$",
"request",
"->",
"get",
"(",
"'note'",
",",
"''",
")",
";",
"$",
"privacy_restriction",
"=",
"$",
"request",
"->",
"get",
"(",
"'privacy-restriction'",
",",
"''",
")",
";",
"$",
"edit_restriction",
"=",
"$",
"request",
"->",
"get",
"(",
"'edit-restriction'",
",",
"''",
")",
";",
"// Convert line endings to GEDDCOM continuations",
"$",
"note",
"=",
"preg_replace",
"(",
"'/\\r|\\r\\n|\\n|\\r/'",
",",
"\"\\n1 CONT \"",
",",
"$",
"note",
")",
";",
"$",
"gedcom",
"=",
"'0 @@ NOTE '",
".",
"$",
"note",
";",
"if",
"(",
"in_array",
"(",
"$",
"privacy_restriction",
",",
"[",
"'none'",
",",
"'privacy'",
",",
"'confidential'",
",",
"]",
")",
")",
"{",
"$",
"gedcom",
".=",
"\"\\n1 RESN \"",
".",
"$",
"privacy_restriction",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"edit_restriction",
",",
"[",
"'locked'",
"]",
")",
")",
"{",
"$",
"gedcom",
".=",
"\"\\n1 RESN \"",
".",
"$",
"edit_restriction",
";",
"}",
"$",
"record",
"=",
"$",
"tree",
"->",
"createRecord",
"(",
"$",
"gedcom",
")",
";",
"return",
"response",
"(",
"[",
"'id'",
"=>",
"$",
"record",
"->",
"xref",
"(",
")",
",",
"'text'",
"=>",
"view",
"(",
"'selects/note'",
",",
"[",
"'note'",
"=>",
"$",
"record",
",",
"]",
")",
",",
"'html'",
"=>",
"view",
"(",
"'modals/record-created'",
",",
"[",
"'title'",
"=>",
"I18N",
"::",
"translate",
"(",
"'The note has been created'",
")",
",",
"'name'",
"=>",
"$",
"record",
"->",
"fullName",
"(",
")",
",",
"'url'",
"=>",
"$",
"record",
"->",
"url",
"(",
")",
",",
"]",
")",
",",
"]",
")",
";",
"}"
] | Process a form to create a new note object.
@param ServerRequestInterface $request
@param Tree $tree
@return ResponseInterface | [
"Process",
"a",
"form",
"to",
"create",
"a",
"new",
"note",
"object",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/EditNoteController.php#L111-L147 | train |
fisharebest/webtrees | app/Module/ClippingsCartModule.php | ClippingsCartModule.allRecordsInCart | private function allRecordsInCart(Tree $tree): array
{
$cart = Session::get('cart', []);
$xrefs = array_keys($cart[$tree->name()] ?? []);
// Fetch all the records in the cart.
$records = array_map(static function (string $xref) use ($tree): GedcomRecord {
return GedcomRecord::getInstance($xref, $tree);
}, $xrefs);
// Some records may have been deleted after they were added to the cart.
$records = array_filter($records);
// Group and sort.
uasort($records, static function (GedcomRecord $x, GedcomRecord $y): int {
return $x::RECORD_TYPE <=> $y::RECORD_TYPE ?: GedcomRecord::nameComparator()($x, $y);
});
return $records;
} | php | private function allRecordsInCart(Tree $tree): array
{
$cart = Session::get('cart', []);
$xrefs = array_keys($cart[$tree->name()] ?? []);
// Fetch all the records in the cart.
$records = array_map(static function (string $xref) use ($tree): GedcomRecord {
return GedcomRecord::getInstance($xref, $tree);
}, $xrefs);
// Some records may have been deleted after they were added to the cart.
$records = array_filter($records);
// Group and sort.
uasort($records, static function (GedcomRecord $x, GedcomRecord $y): int {
return $x::RECORD_TYPE <=> $y::RECORD_TYPE ?: GedcomRecord::nameComparator()($x, $y);
});
return $records;
} | [
"private",
"function",
"allRecordsInCart",
"(",
"Tree",
"$",
"tree",
")",
":",
"array",
"{",
"$",
"cart",
"=",
"Session",
"::",
"get",
"(",
"'cart'",
",",
"[",
"]",
")",
";",
"$",
"xrefs",
"=",
"array_keys",
"(",
"$",
"cart",
"[",
"$",
"tree",
"->",
"name",
"(",
")",
"]",
"??",
"[",
"]",
")",
";",
"// Fetch all the records in the cart.",
"$",
"records",
"=",
"array_map",
"(",
"static",
"function",
"(",
"string",
"$",
"xref",
")",
"use",
"(",
"$",
"tree",
")",
":",
"GedcomRecord",
"{",
"return",
"GedcomRecord",
"::",
"getInstance",
"(",
"$",
"xref",
",",
"$",
"tree",
")",
";",
"}",
",",
"$",
"xrefs",
")",
";",
"// Some records may have been deleted after they were added to the cart.",
"$",
"records",
"=",
"array_filter",
"(",
"$",
"records",
")",
";",
"// Group and sort.",
"uasort",
"(",
"$",
"records",
",",
"static",
"function",
"(",
"GedcomRecord",
"$",
"x",
",",
"GedcomRecord",
"$",
"y",
")",
":",
"int",
"{",
"return",
"$",
"x",
"::",
"RECORD_TYPE",
"<=>",
"$",
"y",
"::",
"RECORD_TYPE",
"?",
":",
"GedcomRecord",
"::",
"nameComparator",
"(",
")",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"}",
")",
";",
"return",
"$",
"records",
";",
"}"
] | Get all the records in the cart.
@param Tree $tree
@return GedcomRecord[] | [
"Get",
"all",
"the",
"records",
"in",
"the",
"cart",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ClippingsCartModule.php#L908-L928 | train |
fisharebest/webtrees | app/Module/ClippingsCartModule.php | ClippingsCartModule.addRecordToCart | private function addRecordToCart(GedcomRecord $record): void
{
$cart = Session::get('cart', []);
$tree_name = $record->tree()->name();
// Add this record
$cart[$tree_name][$record->xref()] = true;
// Add directly linked media, notes, repositories and sources.
preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . Gedcom::REGEX_XREF . ')@/', $record->gedcom(), $matches);
foreach ($matches[1] as $match) {
$cart[$tree_name][$match] = true;
}
Session::put('cart', $cart);
} | php | private function addRecordToCart(GedcomRecord $record): void
{
$cart = Session::get('cart', []);
$tree_name = $record->tree()->name();
// Add this record
$cart[$tree_name][$record->xref()] = true;
// Add directly linked media, notes, repositories and sources.
preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . Gedcom::REGEX_XREF . ')@/', $record->gedcom(), $matches);
foreach ($matches[1] as $match) {
$cart[$tree_name][$match] = true;
}
Session::put('cart', $cart);
} | [
"private",
"function",
"addRecordToCart",
"(",
"GedcomRecord",
"$",
"record",
")",
":",
"void",
"{",
"$",
"cart",
"=",
"Session",
"::",
"get",
"(",
"'cart'",
",",
"[",
"]",
")",
";",
"$",
"tree_name",
"=",
"$",
"record",
"->",
"tree",
"(",
")",
"->",
"name",
"(",
")",
";",
"// Add this record",
"$",
"cart",
"[",
"$",
"tree_name",
"]",
"[",
"$",
"record",
"->",
"xref",
"(",
")",
"]",
"=",
"true",
";",
"// Add directly linked media, notes, repositories and sources.",
"preg_match_all",
"(",
"'/\\n\\d (?:OBJE|NOTE|SOUR|REPO) @('",
".",
"Gedcom",
"::",
"REGEX_XREF",
".",
"')@/'",
",",
"$",
"record",
"->",
"gedcom",
"(",
")",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"cart",
"[",
"$",
"tree_name",
"]",
"[",
"$",
"match",
"]",
"=",
"true",
";",
"}",
"Session",
"::",
"put",
"(",
"'cart'",
",",
"$",
"cart",
")",
";",
"}"
] | Add a record (and direclty linked sources, notes, etc. to the cart.
@param GedcomRecord $record
@return void | [
"Add",
"a",
"record",
"(",
"and",
"direclty",
"linked",
"sources",
"notes",
"etc",
".",
"to",
"the",
"cart",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ClippingsCartModule.php#L937-L954 | train |
fisharebest/webtrees | app/Module/RelationshipsChartModule.php | RelationshipsChartModule.allAncestors | private function allAncestors($xref1, $xref2, $tree_id): array
{
$ancestors = [
$xref1,
$xref2,
];
$queue = [
$xref1,
$xref2,
];
while (!empty($queue)) {
$parents = DB::table('link AS l1')
->join('link AS l2', static function (JoinClause $join): void {
$join
->on('l1.l_to', '=', 'l2.l_to')
->on('l1.l_file', '=', 'l2.l_file');
})
->where('l1.l_file', '=', $tree_id)
->where('l1.l_type', '=', 'FAMC')
->where('l2.l_type', '=', 'FAMS')
->whereIn('l1.l_from', $queue)
->pluck('l2.l_from');
$queue = [];
foreach ($parents as $parent) {
if (!in_array($parent, $ancestors, true)) {
$ancestors[] = $parent;
$queue[] = $parent;
}
}
}
return $ancestors;
} | php | private function allAncestors($xref1, $xref2, $tree_id): array
{
$ancestors = [
$xref1,
$xref2,
];
$queue = [
$xref1,
$xref2,
];
while (!empty($queue)) {
$parents = DB::table('link AS l1')
->join('link AS l2', static function (JoinClause $join): void {
$join
->on('l1.l_to', '=', 'l2.l_to')
->on('l1.l_file', '=', 'l2.l_file');
})
->where('l1.l_file', '=', $tree_id)
->where('l1.l_type', '=', 'FAMC')
->where('l2.l_type', '=', 'FAMS')
->whereIn('l1.l_from', $queue)
->pluck('l2.l_from');
$queue = [];
foreach ($parents as $parent) {
if (!in_array($parent, $ancestors, true)) {
$ancestors[] = $parent;
$queue[] = $parent;
}
}
}
return $ancestors;
} | [
"private",
"function",
"allAncestors",
"(",
"$",
"xref1",
",",
"$",
"xref2",
",",
"$",
"tree_id",
")",
":",
"array",
"{",
"$",
"ancestors",
"=",
"[",
"$",
"xref1",
",",
"$",
"xref2",
",",
"]",
";",
"$",
"queue",
"=",
"[",
"$",
"xref1",
",",
"$",
"xref2",
",",
"]",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"queue",
")",
")",
"{",
"$",
"parents",
"=",
"DB",
"::",
"table",
"(",
"'link AS l1'",
")",
"->",
"join",
"(",
"'link AS l2'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l1.l_to'",
",",
"'='",
",",
"'l2.l_to'",
")",
"->",
"on",
"(",
"'l1.l_file'",
",",
"'='",
",",
"'l2.l_file'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'l1.l_file'",
",",
"'='",
",",
"$",
"tree_id",
")",
"->",
"where",
"(",
"'l1.l_type'",
",",
"'='",
",",
"'FAMC'",
")",
"->",
"where",
"(",
"'l2.l_type'",
",",
"'='",
",",
"'FAMS'",
")",
"->",
"whereIn",
"(",
"'l1.l_from'",
",",
"$",
"queue",
")",
"->",
"pluck",
"(",
"'l2.l_from'",
")",
";",
"$",
"queue",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"parent",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"parent",
",",
"$",
"ancestors",
",",
"true",
")",
")",
"{",
"$",
"ancestors",
"[",
"]",
"=",
"$",
"parent",
";",
"$",
"queue",
"[",
"]",
"=",
"$",
"parent",
";",
"}",
"}",
"}",
"return",
"$",
"ancestors",
";",
"}"
] | Find all ancestors of a list of individuals
@param string $xref1
@param string $xref2
@param int $tree_id
@return string[] | [
"Find",
"all",
"ancestors",
"of",
"a",
"list",
"of",
"individuals"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/RelationshipsChartModule.php#L478-L512 | train |
fisharebest/webtrees | app/Module/RelationshipsChartModule.php | RelationshipsChartModule.excludeFamilies | private function excludeFamilies($xref1, $xref2, $tree_id): array
{
return DB::table('link AS l1')
->join('link AS l2', static function (JoinClause $join): void {
$join
->on('l1.l_to', '=', 'l2.l_to')
->on('l1.l_type', '=', 'l2.l_type')
->on('l1.l_file', '=', 'l2.l_file');
})
->where('l1.l_file', '=', $tree_id)
->where('l1.l_type', '=', 'FAMS')
->where('l1.l_from', '=', $xref1)
->where('l2.l_from', '=', $xref2)
->pluck('l1.l_to')
->all();
} | php | private function excludeFamilies($xref1, $xref2, $tree_id): array
{
return DB::table('link AS l1')
->join('link AS l2', static function (JoinClause $join): void {
$join
->on('l1.l_to', '=', 'l2.l_to')
->on('l1.l_type', '=', 'l2.l_type')
->on('l1.l_file', '=', 'l2.l_file');
})
->where('l1.l_file', '=', $tree_id)
->where('l1.l_type', '=', 'FAMS')
->where('l1.l_from', '=', $xref1)
->where('l2.l_from', '=', $xref2)
->pluck('l1.l_to')
->all();
} | [
"private",
"function",
"excludeFamilies",
"(",
"$",
"xref1",
",",
"$",
"xref2",
",",
"$",
"tree_id",
")",
":",
"array",
"{",
"return",
"DB",
"::",
"table",
"(",
"'link AS l1'",
")",
"->",
"join",
"(",
"'link AS l2'",
",",
"static",
"function",
"(",
"JoinClause",
"$",
"join",
")",
":",
"void",
"{",
"$",
"join",
"->",
"on",
"(",
"'l1.l_to'",
",",
"'='",
",",
"'l2.l_to'",
")",
"->",
"on",
"(",
"'l1.l_type'",
",",
"'='",
",",
"'l2.l_type'",
")",
"->",
"on",
"(",
"'l1.l_file'",
",",
"'='",
",",
"'l2.l_file'",
")",
";",
"}",
")",
"->",
"where",
"(",
"'l1.l_file'",
",",
"'='",
",",
"$",
"tree_id",
")",
"->",
"where",
"(",
"'l1.l_type'",
",",
"'='",
",",
"'FAMS'",
")",
"->",
"where",
"(",
"'l1.l_from'",
",",
"'='",
",",
"$",
"xref1",
")",
"->",
"where",
"(",
"'l2.l_from'",
",",
"'='",
",",
"$",
"xref2",
")",
"->",
"pluck",
"(",
"'l1.l_to'",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Find all families of two individuals
@param string $xref1
@param string $xref2
@param int $tree_id
@return string[] | [
"Find",
"all",
"families",
"of",
"two",
"individuals"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/RelationshipsChartModule.php#L523-L538 | train |
fisharebest/webtrees | app/Services/UpgradeService.php | UpgradeService.extractWebtreesZip | public function extractWebtreesZip(string $zip_file, string $target_folder): void
{
// The Flysystem ZIP archive adapter is painfully slow, so use the native PHP library.
$zip = new ZipArchive();
if ($zip->open($zip_file)) {
$zip->extractTo($target_folder);
$zip->close();
} else {
throw new InternalServerErrorException('Cannot read ZIP file. Is it corrupt?');
}
} | php | public function extractWebtreesZip(string $zip_file, string $target_folder): void
{
// The Flysystem ZIP archive adapter is painfully slow, so use the native PHP library.
$zip = new ZipArchive();
if ($zip->open($zip_file)) {
$zip->extractTo($target_folder);
$zip->close();
} else {
throw new InternalServerErrorException('Cannot read ZIP file. Is it corrupt?');
}
} | [
"public",
"function",
"extractWebtreesZip",
"(",
"string",
"$",
"zip_file",
",",
"string",
"$",
"target_folder",
")",
":",
"void",
"{",
"// The Flysystem ZIP archive adapter is painfully slow, so use the native PHP library.",
"$",
"zip",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zip_file",
")",
")",
"{",
"$",
"zip",
"->",
"extractTo",
"(",
"$",
"target_folder",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InternalServerErrorException",
"(",
"'Cannot read ZIP file. Is it corrupt?'",
")",
";",
"}",
"}"
] | Unpack webtrees.zip.
@param string $zip_file
@param string $target_folder
@return void | [
"Unpack",
"webtrees",
".",
"zip",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UpgradeService.php#L82-L93 | train |
fisharebest/webtrees | app/Services/UpgradeService.php | UpgradeService.webtreesZipContents | public function webtreesZipContents(string $zip_file): Collection
{
$zip_adapter = new ZipArchiveAdapter($zip_file, null, 'webtrees');
$zip_filesystem = new Filesystem(new CachedAdapter($zip_adapter, new Memory()));
$paths = new Collection($zip_filesystem->listContents('', true));
return $paths->filter(static function (array $path): bool {
return $path['type'] === 'file';
})
->map(static function (array $path): string {
return $path['path'];
});
} | php | public function webtreesZipContents(string $zip_file): Collection
{
$zip_adapter = new ZipArchiveAdapter($zip_file, null, 'webtrees');
$zip_filesystem = new Filesystem(new CachedAdapter($zip_adapter, new Memory()));
$paths = new Collection($zip_filesystem->listContents('', true));
return $paths->filter(static function (array $path): bool {
return $path['type'] === 'file';
})
->map(static function (array $path): string {
return $path['path'];
});
} | [
"public",
"function",
"webtreesZipContents",
"(",
"string",
"$",
"zip_file",
")",
":",
"Collection",
"{",
"$",
"zip_adapter",
"=",
"new",
"ZipArchiveAdapter",
"(",
"$",
"zip_file",
",",
"null",
",",
"'webtrees'",
")",
";",
"$",
"zip_filesystem",
"=",
"new",
"Filesystem",
"(",
"new",
"CachedAdapter",
"(",
"$",
"zip_adapter",
",",
"new",
"Memory",
"(",
")",
")",
")",
";",
"$",
"paths",
"=",
"new",
"Collection",
"(",
"$",
"zip_filesystem",
"->",
"listContents",
"(",
"''",
",",
"true",
")",
")",
";",
"return",
"$",
"paths",
"->",
"filter",
"(",
"static",
"function",
"(",
"array",
"$",
"path",
")",
":",
"bool",
"{",
"return",
"$",
"path",
"[",
"'type'",
"]",
"===",
"'file'",
";",
"}",
")",
"->",
"map",
"(",
"static",
"function",
"(",
"array",
"$",
"path",
")",
":",
"string",
"{",
"return",
"$",
"path",
"[",
"'path'",
"]",
";",
"}",
")",
";",
"}"
] | Create a list of all the files in a webtrees .ZIP archive
@param string $zip_file
@return Collection | [
"Create",
"a",
"list",
"of",
"all",
"the",
"files",
"in",
"a",
"webtrees",
".",
"ZIP",
"archive"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/UpgradeService.php#L102-L114 | train |
fisharebest/webtrees | app/Module/HourglassChartModule.php | HourglassChartModule.chart | protected function chart(Individual $individual, int $generations, bool $show_spouse): ResponseInterface
{
$this->layout = 'layouts/ajax';
return $this->viewResponse('modules/hourglass-chart/chart', [
'generations' => $generations,
'individual' => $individual,
'show_spouse' => $show_spouse,
]);
} | php | protected function chart(Individual $individual, int $generations, bool $show_spouse): ResponseInterface
{
$this->layout = 'layouts/ajax';
return $this->viewResponse('modules/hourglass-chart/chart', [
'generations' => $generations,
'individual' => $individual,
'show_spouse' => $show_spouse,
]);
} | [
"protected",
"function",
"chart",
"(",
"Individual",
"$",
"individual",
",",
"int",
"$",
"generations",
",",
"bool",
"$",
"show_spouse",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"layout",
"=",
"'layouts/ajax'",
";",
"return",
"$",
"this",
"->",
"viewResponse",
"(",
"'modules/hourglass-chart/chart'",
",",
"[",
"'generations'",
"=>",
"$",
"generations",
",",
"'individual'",
"=>",
"$",
"individual",
",",
"'show_spouse'",
"=>",
"$",
"show_spouse",
",",
"]",
")",
";",
"}"
] | Generate the initial generations of the chart
@param Individual $individual
@param int $generations
@param bool $show_spouse
@return ResponseInterface | [
"Generate",
"the",
"initial",
"generations",
"of",
"the",
"chart"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/HourglassChartModule.php#L149-L158 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.setup | public function setup(): void
{
parent::setup();
// Setting up the correct dimensions if Portrait (default) or Landscape
if ($this->orientation === 'landscape') {
$tmpw = $this->page_width;
$this->page_width = $this->page_height;
$this->page_height = $tmpw;
}
// Store the pagewidth without margins
$this->noMarginWidth = $this->page_width - $this->left_margin - $this->right_margin;
// If RTL
if ($this->rtl) {
$this->alignRTL = 'right';
$this->entityRTL = '‏';
}
// Change the default HTML font name
$this->default_font = 'Arial';
if ($this->show_generated_by) {
// The default style name for Generated by.... is 'genby'
$element = new ReportHtmlCell(0, 10, 0, 'C', '', 'genby', 1, ReportBaseElement::CURRENT_POSITION, ReportBaseElement::CURRENT_POSITION, 0, 0, '', '', true);
$element->addText($this->generated_by);
$element->setUrl(Webtrees::VERSION);
$this->footerElements[] = $element;
}
} | php | public function setup(): void
{
parent::setup();
// Setting up the correct dimensions if Portrait (default) or Landscape
if ($this->orientation === 'landscape') {
$tmpw = $this->page_width;
$this->page_width = $this->page_height;
$this->page_height = $tmpw;
}
// Store the pagewidth without margins
$this->noMarginWidth = $this->page_width - $this->left_margin - $this->right_margin;
// If RTL
if ($this->rtl) {
$this->alignRTL = 'right';
$this->entityRTL = '‏';
}
// Change the default HTML font name
$this->default_font = 'Arial';
if ($this->show_generated_by) {
// The default style name for Generated by.... is 'genby'
$element = new ReportHtmlCell(0, 10, 0, 'C', '', 'genby', 1, ReportBaseElement::CURRENT_POSITION, ReportBaseElement::CURRENT_POSITION, 0, 0, '', '', true);
$element->addText($this->generated_by);
$element->setUrl(Webtrees::VERSION);
$this->footerElements[] = $element;
}
} | [
"public",
"function",
"setup",
"(",
")",
":",
"void",
"{",
"parent",
"::",
"setup",
"(",
")",
";",
"// Setting up the correct dimensions if Portrait (default) or Landscape",
"if",
"(",
"$",
"this",
"->",
"orientation",
"===",
"'landscape'",
")",
"{",
"$",
"tmpw",
"=",
"$",
"this",
"->",
"page_width",
";",
"$",
"this",
"->",
"page_width",
"=",
"$",
"this",
"->",
"page_height",
";",
"$",
"this",
"->",
"page_height",
"=",
"$",
"tmpw",
";",
"}",
"// Store the pagewidth without margins",
"$",
"this",
"->",
"noMarginWidth",
"=",
"$",
"this",
"->",
"page_width",
"-",
"$",
"this",
"->",
"left_margin",
"-",
"$",
"this",
"->",
"right_margin",
";",
"// If RTL",
"if",
"(",
"$",
"this",
"->",
"rtl",
")",
"{",
"$",
"this",
"->",
"alignRTL",
"=",
"'right'",
";",
"$",
"this",
"->",
"entityRTL",
"=",
"'‏'",
";",
"}",
"// Change the default HTML font name",
"$",
"this",
"->",
"default_font",
"=",
"'Arial'",
";",
"if",
"(",
"$",
"this",
"->",
"show_generated_by",
")",
"{",
"// The default style name for Generated by.... is 'genby'",
"$",
"element",
"=",
"new",
"ReportHtmlCell",
"(",
"0",
",",
"10",
",",
"0",
",",
"'C'",
",",
"''",
",",
"'genby'",
",",
"1",
",",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
",",
"ReportBaseElement",
"::",
"CURRENT_POSITION",
",",
"0",
",",
"0",
",",
"''",
",",
"''",
",",
"true",
")",
";",
"$",
"element",
"->",
"addText",
"(",
"$",
"this",
"->",
"generated_by",
")",
";",
"$",
"element",
"->",
"setUrl",
"(",
"Webtrees",
"::",
"VERSION",
")",
";",
"$",
"this",
"->",
"footerElements",
"[",
"]",
"=",
"$",
"element",
";",
"}",
"}"
] | HTML Setup - ReportHtml
@return void | [
"HTML",
"Setup",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L142-L169 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.runPageHeader | private function runPageHeader()
{
foreach ($this->pageHeaderElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->addPage();
}
}
} | php | private function runPageHeader()
{
foreach ($this->pageHeaderElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
} elseif ($element === 'footnotetexts') {
$this->footnotes();
} elseif ($element === 'addpage') {
$this->addPage();
}
}
} | [
"private",
"function",
"runPageHeader",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pageHeaderElements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"ReportBaseElement",
")",
"{",
"$",
"element",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'footnotetexts'",
")",
"{",
"$",
"this",
"->",
"footnotes",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"===",
"'addpage'",
")",
"{",
"$",
"this",
"->",
"addPage",
"(",
")",
";",
"}",
"}",
"}"
] | Generate the page header
@return void | [
"Generate",
"the",
"page",
"header"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L194-L205 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.createCell | public function createCell($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth): ReportBaseCell
{
return new ReportHtmlCell($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth);
} | php | public function createCell($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth): ReportBaseCell
{
return new ReportHtmlCell($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth);
} | [
"public",
"function",
"createCell",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"border",
",",
"$",
"align",
",",
"$",
"bgcolor",
",",
"$",
"style",
",",
"$",
"ln",
",",
"$",
"top",
",",
"$",
"left",
",",
"$",
"fill",
",",
"$",
"stretch",
",",
"$",
"bocolor",
",",
"$",
"tcolor",
",",
"$",
"reseth",
")",
":",
"ReportBaseCell",
"{",
"return",
"new",
"ReportHtmlCell",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"border",
",",
"$",
"align",
",",
"$",
"bgcolor",
",",
"$",
"style",
",",
"$",
"ln",
",",
"$",
"top",
",",
"$",
"left",
",",
"$",
"fill",
",",
"$",
"stretch",
",",
"$",
"bocolor",
",",
"$",
"tcolor",
",",
"$",
"reseth",
")",
";",
"}"
] | Create a new Cell object.
@param int $width cell width (expressed in points)
@param int $height cell height (expressed in points)
@param mixed $border Border style
@param string $align Text alignement
@param string $bgcolor Background color code
@param string $style The name of the text style
@param int $ln Indicates where the current position should go after the call
@param mixed $top Y-position
@param mixed $left X-position
@param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 1
@param int $stretch Stretch carachter mode
@param string $bocolor Border color
@param string $tcolor Text color
@param bool $reseth
@return ReportBaseCell | [
"Create",
"a",
"new",
"Cell",
"object",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L326-L329 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.createTextBox | public function createTextBox(
float $width,
float $height,
bool $border,
string $bgcolor,
bool $newline,
float $left,
float $top,
bool $pagecheck,
string $style,
bool $fill,
bool $padding,
bool $reseth
): ReportBaseTextbox {
return new ReportHtmlTextbox($width, $height, $border, $bgcolor, $newline, $left, $top, $pagecheck, $style, $fill, $padding, $reseth);
} | php | public function createTextBox(
float $width,
float $height,
bool $border,
string $bgcolor,
bool $newline,
float $left,
float $top,
bool $pagecheck,
string $style,
bool $fill,
bool $padding,
bool $reseth
): ReportBaseTextbox {
return new ReportHtmlTextbox($width, $height, $border, $bgcolor, $newline, $left, $top, $pagecheck, $style, $fill, $padding, $reseth);
} | [
"public",
"function",
"createTextBox",
"(",
"float",
"$",
"width",
",",
"float",
"$",
"height",
",",
"bool",
"$",
"border",
",",
"string",
"$",
"bgcolor",
",",
"bool",
"$",
"newline",
",",
"float",
"$",
"left",
",",
"float",
"$",
"top",
",",
"bool",
"$",
"pagecheck",
",",
"string",
"$",
"style",
",",
"bool",
"$",
"fill",
",",
"bool",
"$",
"padding",
",",
"bool",
"$",
"reseth",
")",
":",
"ReportBaseTextbox",
"{",
"return",
"new",
"ReportHtmlTextbox",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"border",
",",
"$",
"bgcolor",
",",
"$",
"newline",
",",
"$",
"left",
",",
"$",
"top",
",",
"$",
"pagecheck",
",",
"$",
"style",
",",
"$",
"fill",
",",
"$",
"padding",
",",
"$",
"reseth",
")",
";",
"}"
] | Create a new TextBox object.
@param float $width Text box width
@param float $height Text box height
@param bool $border
@param string $bgcolor Background color code in HTML
@param bool $newline
@param float $left
@param float $top
@param bool $pagecheck
@param string $style
@param bool $fill
@param bool $padding
@param bool $reseth
@return ReportBaseTextbox | [
"Create",
"a",
"new",
"TextBox",
"object",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L349-L364 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.addPage | public function addPage()
{
$this->pageN++;
// Add a little margin to max Y "between pages"
$this->maxY += 10;
// If Y is still heigher by any reason...
if ($this->maxY < $this->Y) {
// ... update max Y
$this->maxY = $this->Y;
} else {
// else update Y so that nothing will be overwritten, like images or cells...
$this->Y = $this->maxY;
}
} | php | public function addPage()
{
$this->pageN++;
// Add a little margin to max Y "between pages"
$this->maxY += 10;
// If Y is still heigher by any reason...
if ($this->maxY < $this->Y) {
// ... update max Y
$this->maxY = $this->Y;
} else {
// else update Y so that nothing will be overwritten, like images or cells...
$this->Y = $this->maxY;
}
} | [
"public",
"function",
"addPage",
"(",
")",
"{",
"$",
"this",
"->",
"pageN",
"++",
";",
"// Add a little margin to max Y \"between pages\"",
"$",
"this",
"->",
"maxY",
"+=",
"10",
";",
"// If Y is still heigher by any reason...",
"if",
"(",
"$",
"this",
"->",
"maxY",
"<",
"$",
"this",
"->",
"Y",
")",
"{",
"// ... update max Y",
"$",
"this",
"->",
"maxY",
"=",
"$",
"this",
"->",
"Y",
";",
"}",
"else",
"{",
"// else update Y so that nothing will be overwritten, like images or cells...",
"$",
"this",
"->",
"Y",
"=",
"$",
"this",
"->",
"maxY",
";",
"}",
"}"
] | Update the Page Number and set a new Y if max Y is larger - ReportHtml
@return void | [
"Update",
"the",
"Page",
"Number",
"and",
"set",
"a",
"new",
"Y",
"if",
"max",
"Y",
"is",
"larger",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L480-L495 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.checkFootnote | public function checkFootnote(ReportHtmlFootnote $footnote)
{
$ct = count($this->printedfootnotes);
$i = 0;
$val = $footnote->getValue();
while ($i < $ct) {
if ($this->printedfootnotes[$i]->getValue() == $val) {
// If this footnote already exist then set up the numbers for this object
$footnote->setNum($i + 1);
$footnote->setAddlink((string) ($i + 1));
return $this->printedfootnotes[$i];
}
$i++;
}
// If this Footnote has not been set up yet
$footnote->setNum($ct + 1);
$footnote->setAddlink((string) ($ct + 1));
$this->printedfootnotes[] = $footnote;
return false;
} | php | public function checkFootnote(ReportHtmlFootnote $footnote)
{
$ct = count($this->printedfootnotes);
$i = 0;
$val = $footnote->getValue();
while ($i < $ct) {
if ($this->printedfootnotes[$i]->getValue() == $val) {
// If this footnote already exist then set up the numbers for this object
$footnote->setNum($i + 1);
$footnote->setAddlink((string) ($i + 1));
return $this->printedfootnotes[$i];
}
$i++;
}
// If this Footnote has not been set up yet
$footnote->setNum($ct + 1);
$footnote->setAddlink((string) ($ct + 1));
$this->printedfootnotes[] = $footnote;
return false;
} | [
"public",
"function",
"checkFootnote",
"(",
"ReportHtmlFootnote",
"$",
"footnote",
")",
"{",
"$",
"ct",
"=",
"count",
"(",
"$",
"this",
"->",
"printedfootnotes",
")",
";",
"$",
"i",
"=",
"0",
";",
"$",
"val",
"=",
"$",
"footnote",
"->",
"getValue",
"(",
")",
";",
"while",
"(",
"$",
"i",
"<",
"$",
"ct",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"printedfootnotes",
"[",
"$",
"i",
"]",
"->",
"getValue",
"(",
")",
"==",
"$",
"val",
")",
"{",
"// If this footnote already exist then set up the numbers for this object",
"$",
"footnote",
"->",
"setNum",
"(",
"$",
"i",
"+",
"1",
")",
";",
"$",
"footnote",
"->",
"setAddlink",
"(",
"(",
"string",
")",
"(",
"$",
"i",
"+",
"1",
")",
")",
";",
"return",
"$",
"this",
"->",
"printedfootnotes",
"[",
"$",
"i",
"]",
";",
"}",
"$",
"i",
"++",
";",
"}",
"// If this Footnote has not been set up yet",
"$",
"footnote",
"->",
"setNum",
"(",
"$",
"ct",
"+",
"1",
")",
";",
"$",
"footnote",
"->",
"setAddlink",
"(",
"(",
"string",
")",
"(",
"$",
"ct",
"+",
"1",
")",
")",
";",
"$",
"this",
"->",
"printedfootnotes",
"[",
"]",
"=",
"$",
"footnote",
";",
"return",
"false",
";",
"}"
] | Checks the Footnote and numbers them - ReportHtml
@param ReportHtmlFootnote $footnote
@return ReportHtmlFootnote|bool object if already numbered, false otherwise | [
"Checks",
"the",
"Footnote",
"and",
"numbers",
"them",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L530-L551 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.getCurrentStyleHeight | public function getCurrentStyleHeight(): float
{
if (empty($this->currentStyle)) {
return $this->default_font_size;
}
$style = $this->getStyle($this->currentStyle);
return $style['size'];
} | php | public function getCurrentStyleHeight(): float
{
if (empty($this->currentStyle)) {
return $this->default_font_size;
}
$style = $this->getStyle($this->currentStyle);
return $style['size'];
} | [
"public",
"function",
"getCurrentStyleHeight",
"(",
")",
":",
"float",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"currentStyle",
")",
")",
"{",
"return",
"$",
"this",
"->",
"default_font_size",
";",
"}",
"$",
"style",
"=",
"$",
"this",
"->",
"getStyle",
"(",
"$",
"this",
"->",
"currentStyle",
")",
";",
"return",
"$",
"style",
"[",
"'size'",
"]",
";",
"}"
] | Get the current style height.
@return float | [
"Get",
"the",
"current",
"style",
"height",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L594-L602 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.getFootnotesHeight | public function getFootnotesHeight(float $cellWidth): float
{
$h = 0;
foreach ($this->printedfootnotes as $element) {
$h += $element->getFootnoteHeight($this, $cellWidth);
}
return $h;
} | php | public function getFootnotesHeight(float $cellWidth): float
{
$h = 0;
foreach ($this->printedfootnotes as $element) {
$h += $element->getFootnoteHeight($this, $cellWidth);
}
return $h;
} | [
"public",
"function",
"getFootnotesHeight",
"(",
"float",
"$",
"cellWidth",
")",
":",
"float",
"{",
"$",
"h",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"printedfootnotes",
"as",
"$",
"element",
")",
"{",
"$",
"h",
"+=",
"$",
"element",
"->",
"getFootnoteHeight",
"(",
"$",
"this",
",",
"$",
"cellWidth",
")",
";",
"}",
"return",
"$",
"h",
";",
"}"
] | Get the current footnotes height.
@param float $cellWidth
@return float | [
"Get",
"the",
"current",
"footnotes",
"height",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L611-L619 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.getStringWidth | public function getStringWidth(string $text): float
{
$style = $this->getStyle($this->currentStyle);
return mb_strlen($text) * ($style['size'] / 2);
} | php | public function getStringWidth(string $text): float
{
$style = $this->getStyle($this->currentStyle);
return mb_strlen($text) * ($style['size'] / 2);
} | [
"public",
"function",
"getStringWidth",
"(",
"string",
"$",
"text",
")",
":",
"float",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"getStyle",
"(",
"$",
"this",
"->",
"currentStyle",
")",
";",
"return",
"mb_strlen",
"(",
"$",
"text",
")",
"*",
"(",
"$",
"style",
"[",
"'size'",
"]",
"/",
"2",
")",
";",
"}"
] | Get the width of a string.
@param string $text
@return float | [
"Get",
"the",
"width",
"of",
"a",
"string",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L648-L653 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.getTextCellHeight | public function getTextCellHeight(string $str): float
{
// Count the number of lines to calculate the height
$nl = $this->countLines($str);
// Calculate the cell height
return ceil(($this->getCurrentStyleHeight() * $this->cellHeightRatio) * $nl);
} | php | public function getTextCellHeight(string $str): float
{
// Count the number of lines to calculate the height
$nl = $this->countLines($str);
// Calculate the cell height
return ceil(($this->getCurrentStyleHeight() * $this->cellHeightRatio) * $nl);
} | [
"public",
"function",
"getTextCellHeight",
"(",
"string",
"$",
"str",
")",
":",
"float",
"{",
"// Count the number of lines to calculate the height",
"$",
"nl",
"=",
"$",
"this",
"->",
"countLines",
"(",
"$",
"str",
")",
";",
"// Calculate the cell height",
"return",
"ceil",
"(",
"(",
"$",
"this",
"->",
"getCurrentStyleHeight",
"(",
")",
"*",
"$",
"this",
"->",
"cellHeightRatio",
")",
"*",
"$",
"nl",
")",
";",
"}"
] | Get a text height in points - ReportHtml
@param string $str
@return float | [
"Get",
"a",
"text",
"height",
"in",
"points",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L662-L669 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.setY | public function setY($y)
{
$this->Y = $y;
if ($this->maxY < $y) {
$this->maxY = $y;
}
} | php | public function setY($y)
{
$this->Y = $y;
if ($this->maxY < $y) {
$this->maxY = $y;
}
} | [
"public",
"function",
"setY",
"(",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"Y",
"=",
"$",
"y",
";",
"if",
"(",
"$",
"this",
"->",
"maxY",
"<",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"maxY",
"=",
"$",
"y",
";",
"}",
"}"
] | Set the Y position - ReportHtml
Also updates Max Y position
@param float $y
@return void | [
"Set",
"the",
"Y",
"position",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L734-L740 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.textWrap | public function textWrap(string $str, float $width): string
{
// Calculate the line width
$lw = (int) ($width / ($this->getCurrentStyleHeight() / 2));
// Wordwrap each line
$lines = explode("\n", $str);
// Line Feed counter
$lfct = count($lines);
$wraptext = '';
foreach ($lines as $line) {
$wtext = FunctionsRtl::utf8WordWrap($line, $lw, "\n", true);
$wraptext .= $wtext;
// Add a new line as long as it’s not the last line
if ($lfct > 1) {
$wraptext .= "\n";
}
$lfct--;
}
return $wraptext;
} | php | public function textWrap(string $str, float $width): string
{
// Calculate the line width
$lw = (int) ($width / ($this->getCurrentStyleHeight() / 2));
// Wordwrap each line
$lines = explode("\n", $str);
// Line Feed counter
$lfct = count($lines);
$wraptext = '';
foreach ($lines as $line) {
$wtext = FunctionsRtl::utf8WordWrap($line, $lw, "\n", true);
$wraptext .= $wtext;
// Add a new line as long as it’s not the last line
if ($lfct > 1) {
$wraptext .= "\n";
}
$lfct--;
}
return $wraptext;
} | [
"public",
"function",
"textWrap",
"(",
"string",
"$",
"str",
",",
"float",
"$",
"width",
")",
":",
"string",
"{",
"// Calculate the line width",
"$",
"lw",
"=",
"(",
"int",
")",
"(",
"$",
"width",
"/",
"(",
"$",
"this",
"->",
"getCurrentStyleHeight",
"(",
")",
"/",
"2",
")",
")",
";",
"// Wordwrap each line",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"str",
")",
";",
"// Line Feed counter",
"$",
"lfct",
"=",
"count",
"(",
"$",
"lines",
")",
";",
"$",
"wraptext",
"=",
"''",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"wtext",
"=",
"FunctionsRtl",
"::",
"utf8WordWrap",
"(",
"$",
"line",
",",
"$",
"lw",
",",
"\"\\n\"",
",",
"true",
")",
";",
"$",
"wraptext",
".=",
"$",
"wtext",
";",
"// Add a new line as long as it’s not the last line",
"if",
"(",
"$",
"lfct",
">",
"1",
")",
"{",
"$",
"wraptext",
".=",
"\"\\n\"",
";",
"}",
"$",
"lfct",
"--",
";",
"}",
"return",
"$",
"wraptext",
";",
"}"
] | Wrap text - ReportHtml
@param string $str Text to wrap
@param float $width Width in points the text has to fit into
@return string | [
"Wrap",
"text",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L766-L786 | train |
fisharebest/webtrees | app/Report/ReportHtml.php | ReportHtml.write | public function write($text, $color = '', $useclass = true)
{
$style = $this->getStyle($this->getCurrentStyle());
$htmlcode = '<span dir="' . I18N::direction() . '"';
if ($useclass) {
$htmlcode .= ' class="' . $style['name'] . '"';
}
if (!empty($color)) {
// Check if Text Color is set and if it’s valid HTML color
if (preg_match('/#?(..)(..)(..)/', $color)) {
$htmlcode .= ' style="color:' . $color . ';"';
}
}
$htmlcode .= '>' . $text . '</span>';
$htmlcode = str_replace([
"\n",
'> ',
' <',
], [
'<br>',
'> ',
' <',
], $htmlcode);
echo $htmlcode;
} | php | public function write($text, $color = '', $useclass = true)
{
$style = $this->getStyle($this->getCurrentStyle());
$htmlcode = '<span dir="' . I18N::direction() . '"';
if ($useclass) {
$htmlcode .= ' class="' . $style['name'] . '"';
}
if (!empty($color)) {
// Check if Text Color is set and if it’s valid HTML color
if (preg_match('/#?(..)(..)(..)/', $color)) {
$htmlcode .= ' style="color:' . $color . ';"';
}
}
$htmlcode .= '>' . $text . '</span>';
$htmlcode = str_replace([
"\n",
'> ',
' <',
], [
'<br>',
'> ',
' <',
], $htmlcode);
echo $htmlcode;
} | [
"public",
"function",
"write",
"(",
"$",
"text",
",",
"$",
"color",
"=",
"''",
",",
"$",
"useclass",
"=",
"true",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"getStyle",
"(",
"$",
"this",
"->",
"getCurrentStyle",
"(",
")",
")",
";",
"$",
"htmlcode",
"=",
"'<span dir=\"'",
".",
"I18N",
"::",
"direction",
"(",
")",
".",
"'\"'",
";",
"if",
"(",
"$",
"useclass",
")",
"{",
"$",
"htmlcode",
".=",
"' class=\"'",
".",
"$",
"style",
"[",
"'name'",
"]",
".",
"'\"'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"color",
")",
")",
"{",
"// Check if Text Color is set and if it’s valid HTML color",
"if",
"(",
"preg_match",
"(",
"'/#?(..)(..)(..)/'",
",",
"$",
"color",
")",
")",
"{",
"$",
"htmlcode",
".=",
"' style=\"color:'",
".",
"$",
"color",
".",
"';\"'",
";",
"}",
"}",
"$",
"htmlcode",
".=",
"'>'",
".",
"$",
"text",
".",
"'</span>'",
";",
"$",
"htmlcode",
"=",
"str_replace",
"(",
"[",
"\"\\n\"",
",",
"'> '",
",",
"' <'",
",",
"]",
",",
"[",
"'<br>'",
",",
"'> '",
",",
"' <'",
",",
"]",
",",
"$",
"htmlcode",
")",
";",
"echo",
"$",
"htmlcode",
";",
"}"
] | Write text - ReportHtml
@param string $text Text to print
@param string $color HTML RGB color code (Ex: #001122)
@param bool $useclass
@return void | [
"Write",
"text",
"-",
"ReportHtml"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtml.php#L797-L822 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/UpgradeController.php | UpgradeController.step | public function step(ServerRequestInterface $request, ?Tree $tree): ResponseInterface
{
$step = $request->getQueryParams()['step'] ?? self::STEP_CHECK;
switch ($step) {
case self::STEP_CHECK:
return $this->wizardStepCheck();
case self::STEP_PREPARE:
return $this->wizardStepPrepare();
case self::STEP_PENDING:
return $this->wizardStepPending();
case self::STEP_EXPORT:
if ($tree === null) {
throw new RuntimeException('Exporting a non-existant tree?');
}
return $this->wizardStepExport($tree);
case self::STEP_DOWNLOAD:
return $this->wizardStepDownload();
case self::STEP_UNZIP:
return $this->wizardStepUnzip();
case self::STEP_COPY:
return $this->wizardStepCopy();
case self::STEP_CLEANUP:
return $this->wizardStepCleanup();
}
throw new NotFoundHttpException();
} | php | public function step(ServerRequestInterface $request, ?Tree $tree): ResponseInterface
{
$step = $request->getQueryParams()['step'] ?? self::STEP_CHECK;
switch ($step) {
case self::STEP_CHECK:
return $this->wizardStepCheck();
case self::STEP_PREPARE:
return $this->wizardStepPrepare();
case self::STEP_PENDING:
return $this->wizardStepPending();
case self::STEP_EXPORT:
if ($tree === null) {
throw new RuntimeException('Exporting a non-existant tree?');
}
return $this->wizardStepExport($tree);
case self::STEP_DOWNLOAD:
return $this->wizardStepDownload();
case self::STEP_UNZIP:
return $this->wizardStepUnzip();
case self::STEP_COPY:
return $this->wizardStepCopy();
case self::STEP_CLEANUP:
return $this->wizardStepCleanup();
}
throw new NotFoundHttpException();
} | [
"public",
"function",
"step",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"?",
"Tree",
"$",
"tree",
")",
":",
"ResponseInterface",
"{",
"$",
"step",
"=",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
"[",
"'step'",
"]",
"??",
"self",
"::",
"STEP_CHECK",
";",
"switch",
"(",
"$",
"step",
")",
"{",
"case",
"self",
"::",
"STEP_CHECK",
":",
"return",
"$",
"this",
"->",
"wizardStepCheck",
"(",
")",
";",
"case",
"self",
"::",
"STEP_PREPARE",
":",
"return",
"$",
"this",
"->",
"wizardStepPrepare",
"(",
")",
";",
"case",
"self",
"::",
"STEP_PENDING",
":",
"return",
"$",
"this",
"->",
"wizardStepPending",
"(",
")",
";",
"case",
"self",
"::",
"STEP_EXPORT",
":",
"if",
"(",
"$",
"tree",
"===",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Exporting a non-existant tree?'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"wizardStepExport",
"(",
"$",
"tree",
")",
";",
"case",
"self",
"::",
"STEP_DOWNLOAD",
":",
"return",
"$",
"this",
"->",
"wizardStepDownload",
"(",
")",
";",
"case",
"self",
"::",
"STEP_UNZIP",
":",
"return",
"$",
"this",
"->",
"wizardStepUnzip",
"(",
")",
";",
"case",
"self",
"::",
"STEP_COPY",
":",
"return",
"$",
"this",
"->",
"wizardStepCopy",
"(",
")",
";",
"case",
"self",
"::",
"STEP_CLEANUP",
":",
"return",
"$",
"this",
"->",
"wizardStepCleanup",
"(",
")",
";",
"}",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}"
] | Perform one step of the wizard
@param ServerRequestInterface $request
@param Tree|null $tree
@return ResponseInterface | [
"Perform",
"one",
"step",
"of",
"the",
"wizard"
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/UpgradeController.php#L160-L195 | train |
fisharebest/webtrees | app/Http/Controllers/Admin/UpgradeController.php | UpgradeController.wizardStepPrepare | private function wizardStepPrepare(): ResponseInterface
{
$this->filesystem->deleteDir(self::UPGRADE_FOLDER);
$this->filesystem->createDir(self::UPGRADE_FOLDER);
return response(view('components/alert-success', [
'alert' => I18N::translate('The folder %s has been created.', e(self::UPGRADE_FOLDER)),
]));
} | php | private function wizardStepPrepare(): ResponseInterface
{
$this->filesystem->deleteDir(self::UPGRADE_FOLDER);
$this->filesystem->createDir(self::UPGRADE_FOLDER);
return response(view('components/alert-success', [
'alert' => I18N::translate('The folder %s has been created.', e(self::UPGRADE_FOLDER)),
]));
} | [
"private",
"function",
"wizardStepPrepare",
"(",
")",
":",
"ResponseInterface",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"deleteDir",
"(",
"self",
"::",
"UPGRADE_FOLDER",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"createDir",
"(",
"self",
"::",
"UPGRADE_FOLDER",
")",
";",
"return",
"response",
"(",
"view",
"(",
"'components/alert-success'",
",",
"[",
"'alert'",
"=>",
"I18N",
"::",
"translate",
"(",
"'The folder %s has been created.'",
",",
"e",
"(",
"self",
"::",
"UPGRADE_FOLDER",
")",
")",
",",
"]",
")",
")",
";",
"}"
] | Make sure the temporary folder exists.
@return ResponseInterface | [
"Make",
"sure",
"the",
"temporary",
"folder",
"exists",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/UpgradeController.php#L226-L234 | train |
fisharebest/webtrees | app/FlashMessages.php | FlashMessages.addMessage | public static function addMessage($text, $status = 'info'): void
{
$message = new stdClass();
$message->text = $text;
$message->status = $status;
$messages = Session::get(self::FLASH_KEY, []);
$messages[] = $message;
Session::put(self::FLASH_KEY, $messages);
} | php | public static function addMessage($text, $status = 'info'): void
{
$message = new stdClass();
$message->text = $text;
$message->status = $status;
$messages = Session::get(self::FLASH_KEY, []);
$messages[] = $message;
Session::put(self::FLASH_KEY, $messages);
} | [
"public",
"static",
"function",
"addMessage",
"(",
"$",
"text",
",",
"$",
"status",
"=",
"'info'",
")",
":",
"void",
"{",
"$",
"message",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"message",
"->",
"text",
"=",
"$",
"text",
";",
"$",
"message",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"messages",
"=",
"Session",
"::",
"get",
"(",
"self",
"::",
"FLASH_KEY",
",",
"[",
"]",
")",
";",
"$",
"messages",
"[",
"]",
"=",
"$",
"message",
";",
"Session",
"::",
"put",
"(",
"self",
"::",
"FLASH_KEY",
",",
"$",
"messages",
")",
";",
"}"
] | Add a message to the session storage.
@param string $text
@param string $status "success", "info", "warning" or "danger"
@return void | [
"Add",
"a",
"message",
"to",
"the",
"session",
"storage",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/FlashMessages.php#L38-L47 | train |
fisharebest/webtrees | app/FlashMessages.php | FlashMessages.getMessages | public static function getMessages(): array
{
$messages = Session::get(self::FLASH_KEY, []);
Session::forget(self::FLASH_KEY);
return $messages;
} | php | public static function getMessages(): array
{
$messages = Session::get(self::FLASH_KEY, []);
Session::forget(self::FLASH_KEY);
return $messages;
} | [
"public",
"static",
"function",
"getMessages",
"(",
")",
":",
"array",
"{",
"$",
"messages",
"=",
"Session",
"::",
"get",
"(",
"self",
"::",
"FLASH_KEY",
",",
"[",
"]",
")",
";",
"Session",
"::",
"forget",
"(",
"self",
"::",
"FLASH_KEY",
")",
";",
"return",
"$",
"messages",
";",
"}"
] | Get the current messages, and remove them from session storage.
@return stdClass[] | [
"Get",
"the",
"current",
"messages",
"and",
"remove",
"them",
"from",
"session",
"storage",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/FlashMessages.php#L54-L60 | train |
fisharebest/webtrees | app/Services/HousekeepingService.php | HousekeepingService.deleteOldWebtreesFiles | public function deleteOldWebtreesFiles(Filesystem $filesystem): array
{
$paths_to_delete = [];
foreach (self::OLD_PATHS as $path) {
if (!$this->deleteFileOrFolder($filesystem, $path)) {
$paths_to_delete[] = $path;
}
}
return $paths_to_delete;
} | php | public function deleteOldWebtreesFiles(Filesystem $filesystem): array
{
$paths_to_delete = [];
foreach (self::OLD_PATHS as $path) {
if (!$this->deleteFileOrFolder($filesystem, $path)) {
$paths_to_delete[] = $path;
}
}
return $paths_to_delete;
} | [
"public",
"function",
"deleteOldWebtreesFiles",
"(",
"Filesystem",
"$",
"filesystem",
")",
":",
"array",
"{",
"$",
"paths_to_delete",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"OLD_PATHS",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deleteFileOrFolder",
"(",
"$",
"filesystem",
",",
"$",
"path",
")",
")",
"{",
"$",
"paths_to_delete",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"}",
"return",
"$",
"paths_to_delete",
";",
"}"
] | Delete files and folders that belonged to an earlier version of webtrees.
Return a list of those that we could not delete.
@param Filesystem $filesystem
@return array | [
"Delete",
"files",
"and",
"folders",
"that",
"belonged",
"to",
"an",
"earlier",
"version",
"of",
"webtrees",
".",
"Return",
"a",
"list",
"of",
"those",
"that",
"we",
"could",
"not",
"delete",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/HousekeepingService.php#L382-L393 | train |
fisharebest/webtrees | app/Services/HousekeepingService.php | HousekeepingService.deleteOldFiles | public function deleteOldFiles(Filesystem $filesystem, string $path, int $max_age): void
{
$list = $filesystem->listContents($path, true);
$timestamp = Carbon::now()->unix();
foreach ($list as $metadata) {
if ($metadata['timestamp'] ?? $timestamp < $timestamp - $max_age) {
$this->deleteFileOrFolder($filesystem, $metadata['path']);
}
}
} | php | public function deleteOldFiles(Filesystem $filesystem, string $path, int $max_age): void
{
$list = $filesystem->listContents($path, true);
$timestamp = Carbon::now()->unix();
foreach ($list as $metadata) {
if ($metadata['timestamp'] ?? $timestamp < $timestamp - $max_age) {
$this->deleteFileOrFolder($filesystem, $metadata['path']);
}
}
} | [
"public",
"function",
"deleteOldFiles",
"(",
"Filesystem",
"$",
"filesystem",
",",
"string",
"$",
"path",
",",
"int",
"$",
"max_age",
")",
":",
"void",
"{",
"$",
"list",
"=",
"$",
"filesystem",
"->",
"listContents",
"(",
"$",
"path",
",",
"true",
")",
";",
"$",
"timestamp",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"unix",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"metadata",
")",
"{",
"if",
"(",
"$",
"metadata",
"[",
"'timestamp'",
"]",
"??",
"$",
"timestamp",
"<",
"$",
"timestamp",
"-",
"$",
"max_age",
")",
"{",
"$",
"this",
"->",
"deleteFileOrFolder",
"(",
"$",
"filesystem",
",",
"$",
"metadata",
"[",
"'path'",
"]",
")",
";",
"}",
"}",
"}"
] | Delete old cache files.
@param Filesystem $filesystem
@param string $path
@param int $max_age Seconds
@return void | [
"Delete",
"old",
"cache",
"files",
"."
] | 840bd0d721dc479520ec24a065996bc6becb8348 | https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/HousekeepingService.php#L404-L415 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.