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
jeremykenedy/laravel-roles
src/RolesServiceProvider.php
RolesServiceProvider.loadSeedsFrom
private function loadSeedsFrom() { if (config('roles.defaultSeeds.PermissionsTableSeeder')) { $this->app['seed.handler']->register( DefaultPermissionsTableSeeder::class ); } if (config('roles.defaultSeeds.RolesTableSeeder')) { $this->app['seed.handler']->register( DefaultRolesTableSeeder::class ); } if (config('roles.defaultSeeds.ConnectRelationshipsSeeder')) { $this->app['seed.handler']->register( DefaultConnectRelationshipsSeeder::class ); } if (config('roles.defaultSeeds.UsersTableSeeder')) { $this->app['seed.handler']->register( DefaultUsersTableSeeder::class ); } }
php
private function loadSeedsFrom() { if (config('roles.defaultSeeds.PermissionsTableSeeder')) { $this->app['seed.handler']->register( DefaultPermissionsTableSeeder::class ); } if (config('roles.defaultSeeds.RolesTableSeeder')) { $this->app['seed.handler']->register( DefaultRolesTableSeeder::class ); } if (config('roles.defaultSeeds.ConnectRelationshipsSeeder')) { $this->app['seed.handler']->register( DefaultConnectRelationshipsSeeder::class ); } if (config('roles.defaultSeeds.UsersTableSeeder')) { $this->app['seed.handler']->register( DefaultUsersTableSeeder::class ); } }
[ "private", "function", "loadSeedsFrom", "(", ")", "{", "if", "(", "config", "(", "'roles.defaultSeeds.PermissionsTableSeeder'", ")", ")", "{", "$", "this", "->", "app", "[", "'seed.handler'", "]", "->", "register", "(", "DefaultPermissionsTableSeeder", "::", "class", ")", ";", "}", "if", "(", "config", "(", "'roles.defaultSeeds.RolesTableSeeder'", ")", ")", "{", "$", "this", "->", "app", "[", "'seed.handler'", "]", "->", "register", "(", "DefaultRolesTableSeeder", "::", "class", ")", ";", "}", "if", "(", "config", "(", "'roles.defaultSeeds.ConnectRelationshipsSeeder'", ")", ")", "{", "$", "this", "->", "app", "[", "'seed.handler'", "]", "->", "register", "(", "DefaultConnectRelationshipsSeeder", "::", "class", ")", ";", "}", "if", "(", "config", "(", "'roles.defaultSeeds.UsersTableSeeder'", ")", ")", "{", "$", "this", "->", "app", "[", "'seed.handler'", "]", "->", "register", "(", "DefaultUsersTableSeeder", "::", "class", ")", ";", "}", "}" ]
Loads a seeds. @return void
[ "Loads", "a", "seeds", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/RolesServiceProvider.php#L58-L83
train
jeremykenedy/laravel-roles
src/Traits/HasRoleAndPermission.php
HasRoleAndPermission.hasOneRole
public function hasOneRole($role) { foreach ($this->getArrayFrom($role) as $role) { if ($this->checkRole($role)) { return true; } } return false; }
php
public function hasOneRole($role) { foreach ($this->getArrayFrom($role) as $role) { if ($this->checkRole($role)) { return true; } } return false; }
[ "public", "function", "hasOneRole", "(", "$", "role", ")", "{", "foreach", "(", "$", "this", "->", "getArrayFrom", "(", "$", "role", ")", "as", "$", "role", ")", "{", "if", "(", "$", "this", "->", "checkRole", "(", "$", "role", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the user has at least one of the given roles. @param int|string|array $role @return bool
[ "Check", "if", "the", "user", "has", "at", "least", "one", "of", "the", "given", "roles", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/HasRoleAndPermission.php#L78-L87
train
jeremykenedy/laravel-roles
src/Traits/HasRoleAndPermission.php
HasRoleAndPermission.checkRole
public function checkRole($role) { return $this->getRoles()->contains(function ($value) use ($role) { return $role == $value->id || Str::is($role, $value->slug); }); }
php
public function checkRole($role) { return $this->getRoles()->contains(function ($value) use ($role) { return $role == $value->id || Str::is($role, $value->slug); }); }
[ "public", "function", "checkRole", "(", "$", "role", ")", "{", "return", "$", "this", "->", "getRoles", "(", ")", "->", "contains", "(", "function", "(", "$", "value", ")", "use", "(", "$", "role", ")", "{", "return", "$", "role", "==", "$", "value", "->", "id", "||", "Str", "::", "is", "(", "$", "role", ",", "$", "value", "->", "slug", ")", ";", "}", ")", ";", "}" ]
Check if the user has role. @param int|string $role @return bool
[ "Check", "if", "the", "user", "has", "role", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/HasRoleAndPermission.php#L114-L119
train
jeremykenedy/laravel-roles
src/Traits/HasRoleAndPermission.php
HasRoleAndPermission.hasOnePermission
public function hasOnePermission($permission) { foreach ($this->getArrayFrom($permission) as $permission) { if ($this->checkPermission($permission)) { return true; } } return false; }
php
public function hasOnePermission($permission) { foreach ($this->getArrayFrom($permission) as $permission) { if ($this->checkPermission($permission)) { return true; } } return false; }
[ "public", "function", "hasOnePermission", "(", "$", "permission", ")", "{", "foreach", "(", "$", "this", "->", "getArrayFrom", "(", "$", "permission", ")", "as", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "checkPermission", "(", "$", "permission", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the user has at least one of the given permissions. @param int|string|array $permission @return bool
[ "Check", "if", "the", "user", "has", "at", "least", "one", "of", "the", "given", "permissions", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/HasRoleAndPermission.php#L258-L267
train
jeremykenedy/laravel-roles
src/Traits/HasRoleAndPermission.php
HasRoleAndPermission.allowed
public function allowed($providedPermission, Model $entity, $owner = true, $ownerColumn = 'user_id') { if ($this->isPretendEnabled()) { return $this->pretend('allowed'); } if ($owner === true && $entity->{$ownerColumn} == $this->id) { return true; } return $this->isAllowed($providedPermission, $entity); }
php
public function allowed($providedPermission, Model $entity, $owner = true, $ownerColumn = 'user_id') { if ($this->isPretendEnabled()) { return $this->pretend('allowed'); } if ($owner === true && $entity->{$ownerColumn} == $this->id) { return true; } return $this->isAllowed($providedPermission, $entity); }
[ "public", "function", "allowed", "(", "$", "providedPermission", ",", "Model", "$", "entity", ",", "$", "owner", "=", "true", ",", "$", "ownerColumn", "=", "'user_id'", ")", "{", "if", "(", "$", "this", "->", "isPretendEnabled", "(", ")", ")", "{", "return", "$", "this", "->", "pretend", "(", "'allowed'", ")", ";", "}", "if", "(", "$", "owner", "===", "true", "&&", "$", "entity", "->", "{", "$", "ownerColumn", "}", "==", "$", "this", "->", "id", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "isAllowed", "(", "$", "providedPermission", ",", "$", "entity", ")", ";", "}" ]
Check if the user is allowed to manipulate with entity. @param string $providedPermission @param Model $entity @param bool $owner @param string $ownerColumn @return bool
[ "Check", "if", "the", "user", "is", "allowed", "to", "manipulate", "with", "entity", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/HasRoleAndPermission.php#L311-L322
train
jeremykenedy/laravel-roles
src/Traits/HasRoleAndPermission.php
HasRoleAndPermission.isAllowed
protected function isAllowed($providedPermission, Model $entity) { foreach ($this->getPermissions() as $permission) { if ($permission->model != '' && get_class($entity) == $permission->model && ($permission->id == $providedPermission || $permission->slug === $providedPermission) ) { return true; } } return false; }
php
protected function isAllowed($providedPermission, Model $entity) { foreach ($this->getPermissions() as $permission) { if ($permission->model != '' && get_class($entity) == $permission->model && ($permission->id == $providedPermission || $permission->slug === $providedPermission) ) { return true; } } return false; }
[ "protected", "function", "isAllowed", "(", "$", "providedPermission", ",", "Model", "$", "entity", ")", "{", "foreach", "(", "$", "this", "->", "getPermissions", "(", ")", "as", "$", "permission", ")", "{", "if", "(", "$", "permission", "->", "model", "!=", "''", "&&", "get_class", "(", "$", "entity", ")", "==", "$", "permission", "->", "model", "&&", "(", "$", "permission", "->", "id", "==", "$", "providedPermission", "||", "$", "permission", "->", "slug", "===", "$", "providedPermission", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the user is allowed to manipulate with provided entity. @param string $providedPermission @param Model $entity @return bool
[ "Check", "if", "the", "user", "is", "allowed", "to", "manipulate", "with", "provided", "entity", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/HasRoleAndPermission.php#L332-L343
train
jeremykenedy/laravel-roles
src/Traits/RoleHasRelations.php
RoleHasRelations.attachPermission
public function attachPermission($permission) { return (!$this->permissions()->get()->contains($permission)) ? $this->permissions()->attach($permission) : true; }
php
public function attachPermission($permission) { return (!$this->permissions()->get()->contains($permission)) ? $this->permissions()->attach($permission) : true; }
[ "public", "function", "attachPermission", "(", "$", "permission", ")", "{", "return", "(", "!", "$", "this", "->", "permissions", "(", ")", "->", "get", "(", ")", "->", "contains", "(", "$", "permission", ")", ")", "?", "$", "this", "->", "permissions", "(", ")", "->", "attach", "(", "$", "permission", ")", ":", "true", ";", "}" ]
Attach permission to a role. @param int|Permission $permission @return int|bool
[ "Attach", "permission", "to", "a", "role", "." ]
c531167d84f353db77a5709e9d3c106a5e9cf5c3
https://github.com/jeremykenedy/laravel-roles/blob/c531167d84f353db77a5709e9d3c106a5e9cf5c3/src/Traits/RoleHasRelations.php#L37-L40
train
J7mbo/twitter-api-php
TwitterAPIExchange.php
TwitterAPIExchange.buildBaseString
private function buildBaseString($baseURI, $method, $params) { $return = array(); ksort($params); foreach($params as $key => $value) { $return[] = rawurlencode($key) . '=' . rawurlencode($value); } return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $return)); }
php
private function buildBaseString($baseURI, $method, $params) { $return = array(); ksort($params); foreach($params as $key => $value) { $return[] = rawurlencode($key) . '=' . rawurlencode($value); } return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $return)); }
[ "private", "function", "buildBaseString", "(", "$", "baseURI", ",", "$", "method", ",", "$", "params", ")", "{", "$", "return", "=", "array", "(", ")", ";", "ksort", "(", "$", "params", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "return", "[", "]", "=", "rawurlencode", "(", "$", "key", ")", ".", "'='", ".", "rawurlencode", "(", "$", "value", ")", ";", "}", "return", "$", "method", ".", "\"&\"", ".", "rawurlencode", "(", "$", "baseURI", ")", ".", "'&'", ".", "rawurlencode", "(", "implode", "(", "'&'", ",", "$", "return", ")", ")", ";", "}" ]
Private method to generate the base string used by cURL @param string $baseURI @param string $method @param array $params @return string Built base string
[ "Private", "method", "to", "generate", "the", "base", "string", "used", "by", "cURL" ]
f1a84c8c39a854ac7a8bc87e59c997b526c7bbc7
https://github.com/J7mbo/twitter-api-php/blob/f1a84c8c39a854ac7a8bc87e59c997b526c7bbc7/TwitterAPIExchange.php#L338-L349
train
J7mbo/twitter-api-php
TwitterAPIExchange.php
TwitterAPIExchange.request
public function request($url, $method = 'get', $data = null, $curlOptions = array()) { if (strtolower($method) === 'get') { $this->setGetfield($data); } else { $this->setPostfields($data); } return $this->buildOauth($url, $method)->performRequest(true, $curlOptions); }
php
public function request($url, $method = 'get', $data = null, $curlOptions = array()) { if (strtolower($method) === 'get') { $this->setGetfield($data); } else { $this->setPostfields($data); } return $this->buildOauth($url, $method)->performRequest(true, $curlOptions); }
[ "public", "function", "request", "(", "$", "url", ",", "$", "method", "=", "'get'", ",", "$", "data", "=", "null", ",", "$", "curlOptions", "=", "array", "(", ")", ")", "{", "if", "(", "strtolower", "(", "$", "method", ")", "===", "'get'", ")", "{", "$", "this", "->", "setGetfield", "(", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "setPostfields", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "buildOauth", "(", "$", "url", ",", "$", "method", ")", "->", "performRequest", "(", "true", ",", "$", "curlOptions", ")", ";", "}" ]
Helper method to perform our request @param string $url @param string $method @param string $data @param array $curlOptions @throws \Exception @return string The json response from the server
[ "Helper", "method", "to", "perform", "our", "request" ]
f1a84c8c39a854ac7a8bc87e59c997b526c7bbc7
https://github.com/J7mbo/twitter-api-php/blob/f1a84c8c39a854ac7a8bc87e59c997b526c7bbc7/TwitterAPIExchange.php#L387-L399
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/WiFi.php
WiFi.buildWifiString
protected function buildWifiString() { $wifi = $this->prefix; if (isset($this->encryption)) { $wifi .= 'T:'.$this->encryption.$this->separator; } if (isset($this->ssid)) { $wifi .= 'S:'.$this->ssid.$this->separator; } if (isset($this->password)) { $wifi .= 'P:'.$this->password.$this->separator; } if (isset($this->hidden)) { $wifi .= 'H:'.$this->hidden.$this->separator; } return $wifi; }
php
protected function buildWifiString() { $wifi = $this->prefix; if (isset($this->encryption)) { $wifi .= 'T:'.$this->encryption.$this->separator; } if (isset($this->ssid)) { $wifi .= 'S:'.$this->ssid.$this->separator; } if (isset($this->password)) { $wifi .= 'P:'.$this->password.$this->separator; } if (isset($this->hidden)) { $wifi .= 'H:'.$this->hidden.$this->separator; } return $wifi; }
[ "protected", "function", "buildWifiString", "(", ")", "{", "$", "wifi", "=", "$", "this", "->", "prefix", ";", "if", "(", "isset", "(", "$", "this", "->", "encryption", ")", ")", "{", "$", "wifi", ".=", "'T:'", ".", "$", "this", "->", "encryption", ".", "$", "this", "->", "separator", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "ssid", ")", ")", "{", "$", "wifi", ".=", "'S:'", ".", "$", "this", "->", "ssid", ".", "$", "this", "->", "separator", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "password", ")", ")", "{", "$", "wifi", ".=", "'P:'", ".", "$", "this", "->", "password", ".", "$", "this", "->", "separator", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "hidden", ")", ")", "{", "$", "wifi", ".=", "'H:'", ".", "$", "this", "->", "hidden", ".", "$", "this", "->", "separator", ";", "}", "return", "$", "wifi", ";", "}" ]
Builds the WiFi string. @return string
[ "Builds", "the", "WiFi", "string", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/WiFi.php#L74-L92
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/WiFi.php
WiFi.setProperties
protected function setProperties(array $arguments) { $arguments = $arguments[0]; if (isset($arguments['encryption'])) { $this->encryption = $arguments['encryption']; } if (isset($arguments['ssid'])) { $this->ssid = $arguments['ssid']; } if (isset($arguments['password'])) { $this->password = $arguments['password']; } if (isset($arguments['hidden'])) { $this->hidden = $arguments['hidden']; } }
php
protected function setProperties(array $arguments) { $arguments = $arguments[0]; if (isset($arguments['encryption'])) { $this->encryption = $arguments['encryption']; } if (isset($arguments['ssid'])) { $this->ssid = $arguments['ssid']; } if (isset($arguments['password'])) { $this->password = $arguments['password']; } if (isset($arguments['hidden'])) { $this->hidden = $arguments['hidden']; } }
[ "protected", "function", "setProperties", "(", "array", "$", "arguments", ")", "{", "$", "arguments", "=", "$", "arguments", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "arguments", "[", "'encryption'", "]", ")", ")", "{", "$", "this", "->", "encryption", "=", "$", "arguments", "[", "'encryption'", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "'ssid'", "]", ")", ")", "{", "$", "this", "->", "ssid", "=", "$", "arguments", "[", "'ssid'", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "'password'", "]", ")", ")", "{", "$", "this", "->", "password", "=", "$", "arguments", "[", "'password'", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "'hidden'", "]", ")", ")", "{", "$", "this", "->", "hidden", "=", "$", "arguments", "[", "'hidden'", "]", ";", "}", "}" ]
Sets the WiFi properties. @param $arguments
[ "Sets", "the", "WiFi", "properties", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/WiFi.php#L99-L114
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/SMS.php
SMS.setProperties
protected function setProperties(array $arguments) { if (isset($arguments[0])) { $this->phoneNumber = $arguments[0]; } if (isset($arguments[1])) { $this->message = $arguments[1]; } }
php
protected function setProperties(array $arguments) { if (isset($arguments[0])) { $this->phoneNumber = $arguments[0]; } if (isset($arguments[1])) { $this->message = $arguments[1]; } }
[ "protected", "function", "setProperties", "(", "array", "$", "arguments", ")", "{", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", ")", ")", "{", "$", "this", "->", "phoneNumber", "=", "$", "arguments", "[", "0", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "1", "]", ")", ")", "{", "$", "this", "->", "message", "=", "$", "arguments", "[", "1", "]", ";", "}", "}" ]
Sets the phone number and message for a sms message. @param array $arguments
[ "Sets", "the", "phone", "number", "and", "message", "for", "a", "sms", "message", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/SMS.php#L60-L68
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/SMS.php
SMS.buildSMSString
protected function buildSMSString() { $sms = $this->prefix.$this->phoneNumber; if (isset($this->message)) { $sms .= $this->separator.$this->message; } return $sms; }
php
protected function buildSMSString() { $sms = $this->prefix.$this->phoneNumber; if (isset($this->message)) { $sms .= $this->separator.$this->message; } return $sms; }
[ "protected", "function", "buildSMSString", "(", ")", "{", "$", "sms", "=", "$", "this", "->", "prefix", ".", "$", "this", "->", "phoneNumber", ";", "if", "(", "isset", "(", "$", "this", "->", "message", ")", ")", "{", "$", "sms", ".=", "$", "this", "->", "separator", ".", "$", "this", "->", "message", ";", "}", "return", "$", "sms", ";", "}" ]
Builds a SMS string. @return string
[ "Builds", "a", "SMS", "string", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/SMS.php#L75-L84
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php
BTC.setProperties
protected function setProperties(array $arguments) { if (isset($arguments[0])) { $this->address = $arguments[0]; } if (isset($arguments[1])) { $this->amount = $arguments[1]; } if (isset($arguments[2])) { $this->setOptions($arguments[2]); } }
php
protected function setProperties(array $arguments) { if (isset($arguments[0])) { $this->address = $arguments[0]; } if (isset($arguments[1])) { $this->amount = $arguments[1]; } if (isset($arguments[2])) { $this->setOptions($arguments[2]); } }
[ "protected", "function", "setProperties", "(", "array", "$", "arguments", ")", "{", "if", "(", "isset", "(", "$", "arguments", "[", "0", "]", ")", ")", "{", "$", "this", "->", "address", "=", "$", "arguments", "[", "0", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "1", "]", ")", ")", "{", "$", "this", "->", "amount", "=", "$", "arguments", "[", "1", "]", ";", "}", "if", "(", "isset", "(", "$", "arguments", "[", "2", "]", ")", ")", "{", "$", "this", "->", "setOptions", "(", "$", "arguments", "[", "2", "]", ")", ";", "}", "}" ]
Sets the BitCoin arguments. @param array $arguments
[ "Sets", "the", "BitCoin", "arguments", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php#L81-L94
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php
BTC.setOptions
protected function setOptions(array $options) { if (isset($options['label'])) { $this->label = $options['label']; } if (isset($options['message'])) { $this->message = $options['message']; } if (isset($options['returnAddress'])) { $this->returnAddress = $options['returnAddress']; } }
php
protected function setOptions(array $options) { if (isset($options['label'])) { $this->label = $options['label']; } if (isset($options['message'])) { $this->message = $options['message']; } if (isset($options['returnAddress'])) { $this->returnAddress = $options['returnAddress']; } }
[ "protected", "function", "setOptions", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'label'", "]", ")", ")", "{", "$", "this", "->", "label", "=", "$", "options", "[", "'label'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'message'", "]", ")", ")", "{", "$", "this", "->", "message", "=", "$", "options", "[", "'message'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'returnAddress'", "]", ")", ")", "{", "$", "this", "->", "returnAddress", "=", "$", "options", "[", "'returnAddress'", "]", ";", "}", "}" ]
Sets the optional BitCoin options. @param array $options
[ "Sets", "the", "optional", "BitCoin", "options", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php#L101-L114
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php
BTC.buildBitCoinString
protected function buildBitCoinString() { $query = http_build_query([ 'amount' => $this->amount, 'label' => $this->label, '$message' => $this->message, 'r' => $this->returnAddress, ]); $btc = $this->prefix.$this->address.'?'.$query; return $btc; }
php
protected function buildBitCoinString() { $query = http_build_query([ 'amount' => $this->amount, 'label' => $this->label, '$message' => $this->message, 'r' => $this->returnAddress, ]); $btc = $this->prefix.$this->address.'?'.$query; return $btc; }
[ "protected", "function", "buildBitCoinString", "(", ")", "{", "$", "query", "=", "http_build_query", "(", "[", "'amount'", "=>", "$", "this", "->", "amount", ",", "'label'", "=>", "$", "this", "->", "label", ",", "'$message'", "=>", "$", "this", "->", "message", ",", "'r'", "=>", "$", "this", "->", "returnAddress", ",", "]", ")", ";", "$", "btc", "=", "$", "this", "->", "prefix", ".", "$", "this", "->", "address", ".", "'?'", ".", "$", "query", ";", "return", "$", "btc", ";", "}" ]
Builds a BitCoin string. @return string
[ "Builds", "a", "BitCoin", "string", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/DataTypes/BTC.php#L121-L133
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/ImageMerge.php
ImageMerge.merge
public function merge($percentage) { $this->setProperties($percentage); imagecopyresampled( $this->sourceImage->getImageResource(), $this->mergeImage->getImageResource(), $this->centerX, $this->centerY, 0, 0, $this->postMergeImageWidth, $this->postMergeImageHeight, $this->mergeImageWidth, $this->mergeImageHeight ); return $this->createImage(); }
php
public function merge($percentage) { $this->setProperties($percentage); imagecopyresampled( $this->sourceImage->getImageResource(), $this->mergeImage->getImageResource(), $this->centerX, $this->centerY, 0, 0, $this->postMergeImageWidth, $this->postMergeImageHeight, $this->mergeImageWidth, $this->mergeImageHeight ); return $this->createImage(); }
[ "public", "function", "merge", "(", "$", "percentage", ")", "{", "$", "this", "->", "setProperties", "(", "$", "percentage", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "sourceImage", "->", "getImageResource", "(", ")", ",", "$", "this", "->", "mergeImage", "->", "getImageResource", "(", ")", ",", "$", "this", "->", "centerX", ",", "$", "this", "->", "centerY", ",", "0", ",", "0", ",", "$", "this", "->", "postMergeImageWidth", ",", "$", "this", "->", "postMergeImageHeight", ",", "$", "this", "->", "mergeImageWidth", ",", "$", "this", "->", "mergeImageHeight", ")", ";", "return", "$", "this", "->", "createImage", "(", ")", ";", "}" ]
Returns an QrCode that has been merge with another image. This is usually used with logos to imprint a logo into a QrCode. @param $percentage float The percentage of size relative to the entire QR of the merged image @return string
[ "Returns", "an", "QrCode", "that", "has", "been", "merge", "with", "another", "image", ".", "This", "is", "usually", "used", "with", "logos", "to", "imprint", "a", "logo", "into", "a", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/ImageMerge.php#L97-L115
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/ImageMerge.php
ImageMerge.calculateCenter
private function calculateCenter() { $this->centerY = ($this->sourceImageHeight / 2) - ($this->postMergeImageHeight / 2); $this->centerX = ($this->sourceImageWidth / 2) - ($this->postMergeImageHeight / 2); }
php
private function calculateCenter() { $this->centerY = ($this->sourceImageHeight / 2) - ($this->postMergeImageHeight / 2); $this->centerX = ($this->sourceImageWidth / 2) - ($this->postMergeImageHeight / 2); }
[ "private", "function", "calculateCenter", "(", ")", "{", "$", "this", "->", "centerY", "=", "(", "$", "this", "->", "sourceImageHeight", "/", "2", ")", "-", "(", "$", "this", "->", "postMergeImageHeight", "/", "2", ")", ";", "$", "this", "->", "centerX", "=", "(", "$", "this", "->", "sourceImageWidth", "/", "2", ")", "-", "(", "$", "this", "->", "postMergeImageHeight", "/", "2", ")", ";", "}" ]
Calculates the center of the source Image using the Merge image.
[ "Calculates", "the", "center", "of", "the", "source", "Image", "using", "the", "Merge", "image", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/ImageMerge.php#L154-L158
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/ImageMerge.php
ImageMerge.calculateOverlap
private function calculateOverlap($percentage) { $this->postMergeImageHeight = $this->sourceImageHeight * $percentage; $this->postMergeImageWidth = $this->sourceImageWidth * $percentage; }
php
private function calculateOverlap($percentage) { $this->postMergeImageHeight = $this->sourceImageHeight * $percentage; $this->postMergeImageWidth = $this->sourceImageWidth * $percentage; }
[ "private", "function", "calculateOverlap", "(", "$", "percentage", ")", "{", "$", "this", "->", "postMergeImageHeight", "=", "$", "this", "->", "sourceImageHeight", "*", "$", "percentage", ";", "$", "this", "->", "postMergeImageWidth", "=", "$", "this", "->", "sourceImageWidth", "*", "$", "percentage", ";", "}" ]
Calculates the width of the merge image being placed on the source image. @param float $percentage
[ "Calculates", "the", "width", "of", "the", "merge", "image", "being", "placed", "on", "the", "source", "image", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/ImageMerge.php#L165-L169
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.generate
public function generate($text, $filename = null) { $qrCode = $this->writer->writeString($text, $this->encoding, $this->errorCorrection); if ($this->imageMerge !== null) { $merger = new ImageMerge(new Image($qrCode), new Image($this->imageMerge)); $qrCode = $merger->merge($this->imagePercentage); } if ($filename === null) { return $qrCode; } return file_put_contents($filename, $qrCode); }
php
public function generate($text, $filename = null) { $qrCode = $this->writer->writeString($text, $this->encoding, $this->errorCorrection); if ($this->imageMerge !== null) { $merger = new ImageMerge(new Image($qrCode), new Image($this->imageMerge)); $qrCode = $merger->merge($this->imagePercentage); } if ($filename === null) { return $qrCode; } return file_put_contents($filename, $qrCode); }
[ "public", "function", "generate", "(", "$", "text", ",", "$", "filename", "=", "null", ")", "{", "$", "qrCode", "=", "$", "this", "->", "writer", "->", "writeString", "(", "$", "text", ",", "$", "this", "->", "encoding", ",", "$", "this", "->", "errorCorrection", ")", ";", "if", "(", "$", "this", "->", "imageMerge", "!==", "null", ")", "{", "$", "merger", "=", "new", "ImageMerge", "(", "new", "Image", "(", "$", "qrCode", ")", ",", "new", "Image", "(", "$", "this", "->", "imageMerge", ")", ")", ";", "$", "qrCode", "=", "$", "merger", "->", "merge", "(", "$", "this", "->", "imagePercentage", ")", ";", "}", "if", "(", "$", "filename", "===", "null", ")", "{", "return", "$", "qrCode", ";", "}", "return", "file_put_contents", "(", "$", "filename", ",", "$", "qrCode", ")", ";", "}" ]
Generates a QrCode. @param string $text The text to be converted into a QrCode @param null|string $filename The filename and path to save the QrCode file @return string|void Returns a QrCode string depending on the format, or saves to a file.
[ "Generates", "a", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L72-L86
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.merge
public function merge($filepath, $percentage = .2, $absolute = false) { if (function_exists('base_path') && !$absolute) { $filepath = base_path().$filepath; } $this->imageMerge = file_get_contents($filepath); $this->imagePercentage = $percentage; return $this; }
php
public function merge($filepath, $percentage = .2, $absolute = false) { if (function_exists('base_path') && !$absolute) { $filepath = base_path().$filepath; } $this->imageMerge = file_get_contents($filepath); $this->imagePercentage = $percentage; return $this; }
[ "public", "function", "merge", "(", "$", "filepath", ",", "$", "percentage", "=", ".2", ",", "$", "absolute", "=", "false", ")", "{", "if", "(", "function_exists", "(", "'base_path'", ")", "&&", "!", "$", "absolute", ")", "{", "$", "filepath", "=", "base_path", "(", ")", ".", "$", "filepath", ";", "}", "$", "this", "->", "imageMerge", "=", "file_get_contents", "(", "$", "filepath", ")", ";", "$", "this", "->", "imagePercentage", "=", "$", "percentage", ";", "return", "$", "this", ";", "}" ]
Merges an image with the center of the QrCode. @param $filepath string The filepath to an image @param $percentage float The amount that the merged image should be placed over the qrcode. @param $absolute boolean Whether to use an absolute filepath or not. @return $this
[ "Merges", "an", "image", "with", "the", "center", "of", "the", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L97-L107
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.mergeString
public function mergeString($content, $percentage = .2) { $this->imageMerge = $content; $this->imagePercentage = $percentage; return $this; }
php
public function mergeString($content, $percentage = .2) { $this->imageMerge = $content; $this->imagePercentage = $percentage; return $this; }
[ "public", "function", "mergeString", "(", "$", "content", ",", "$", "percentage", "=", ".2", ")", "{", "$", "this", "->", "imageMerge", "=", "$", "content", ";", "$", "this", "->", "imagePercentage", "=", "$", "percentage", ";", "return", "$", "this", ";", "}" ]
Merges an image string with the center of the QrCode, does not check for correct format. @param $content string The string contents of an image. @param $percentage float The amount that the merged image should be placed over the qrcode. @return $this
[ "Merges", "an", "image", "string", "with", "the", "center", "of", "the", "QrCode", "does", "not", "check", "for", "correct", "format", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L117-L123
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.format
public function format($format) { switch ($format) { case 'png': $this->writer->setRenderer(new Png()); break; case 'eps': $this->writer->setRenderer(new Eps()); break; case 'svg': $this->writer->setRenderer(new Svg()); break; default: throw new \InvalidArgumentException('Invalid format provided.'); } return $this; }
php
public function format($format) { switch ($format) { case 'png': $this->writer->setRenderer(new Png()); break; case 'eps': $this->writer->setRenderer(new Eps()); break; case 'svg': $this->writer->setRenderer(new Svg()); break; default: throw new \InvalidArgumentException('Invalid format provided.'); } return $this; }
[ "public", "function", "format", "(", "$", "format", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "'png'", ":", "$", "this", "->", "writer", "->", "setRenderer", "(", "new", "Png", "(", ")", ")", ";", "break", ";", "case", "'eps'", ":", "$", "this", "->", "writer", "->", "setRenderer", "(", "new", "Eps", "(", ")", ")", ";", "break", ";", "case", "'svg'", ":", "$", "this", "->", "writer", "->", "setRenderer", "(", "new", "Svg", "(", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid format provided.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Switches the format of the outputted QrCode or defaults to SVG. @param string $format The desired format. @throws \InvalidArgumentException @return $this
[ "Switches", "the", "format", "of", "the", "outputted", "QrCode", "or", "defaults", "to", "SVG", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L134-L151
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.size
public function size($pixels) { $this->writer->getRenderer()->setHeight($pixels); $this->writer->getRenderer()->setWidth($pixels); return $this; }
php
public function size($pixels) { $this->writer->getRenderer()->setHeight($pixels); $this->writer->getRenderer()->setWidth($pixels); return $this; }
[ "public", "function", "size", "(", "$", "pixels", ")", "{", "$", "this", "->", "writer", "->", "getRenderer", "(", ")", "->", "setHeight", "(", "$", "pixels", ")", ";", "$", "this", "->", "writer", "->", "getRenderer", "(", ")", "->", "setWidth", "(", "$", "pixels", ")", ";", "return", "$", "this", ";", "}" ]
Changes the size of the QrCode. @param int $pixels The size of the QrCode in pixels @return $this
[ "Changes", "the", "size", "of", "the", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L160-L166
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.color
public function color($red, $green, $blue) { $this->writer->getRenderer()->setForegroundColor(new Rgb($red, $green, $blue)); return $this; }
php
public function color($red, $green, $blue) { $this->writer->getRenderer()->setForegroundColor(new Rgb($red, $green, $blue)); return $this; }
[ "public", "function", "color", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "writer", "->", "getRenderer", "(", ")", "->", "setForegroundColor", "(", "new", "Rgb", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", ")", ";", "return", "$", "this", ";", "}" ]
Changes the foreground color of a QrCode. @param int $red @param int $green @param int $blue @return $this
[ "Changes", "the", "foreground", "color", "of", "a", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L177-L182
train
SimpleSoftwareIO/simple-qrcode
src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php
BaconQrCodeGenerator.backgroundColor
public function backgroundColor($red, $green, $blue) { $this->writer->getRenderer()->setBackgroundColor(new Rgb($red, $green, $blue)); return $this; }
php
public function backgroundColor($red, $green, $blue) { $this->writer->getRenderer()->setBackgroundColor(new Rgb($red, $green, $blue)); return $this; }
[ "public", "function", "backgroundColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "writer", "->", "getRenderer", "(", ")", "->", "setBackgroundColor", "(", "new", "Rgb", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", ")", ";", "return", "$", "this", ";", "}" ]
Changes the background color of a QrCode. @param int $red @param int $green @param int $blue @return $this
[ "Changes", "the", "background", "color", "of", "a", "QrCode", "." ]
4968df591efa38f91cbce801a7e63a990e28feea
https://github.com/SimpleSoftwareIO/simple-qrcode/blob/4968df591efa38f91cbce801a7e63a990e28feea/src/SimpleSoftwareIO/QrCode/BaconQrCodeGenerator.php#L193-L198
train
fisharebest/webtrees
app/Auth.php
Auth.login
public static function login(UserInterface $user): void { Session::regenerate(false); Session::put('wt_user', $user->id()); }
php
public static function login(UserInterface $user): void { Session::regenerate(false); Session::put('wt_user', $user->id()); }
[ "public", "static", "function", "login", "(", "UserInterface", "$", "user", ")", ":", "void", "{", "Session", "::", "regenerate", "(", "false", ")", ";", "Session", "::", "put", "(", "'wt_user'", ",", "$", "user", "->", "id", "(", ")", ")", ";", "}" ]
Login directly as an explicit user - for masquerading. @param UserInterface $user @return void
[ "Login", "directly", "as", "an", "explicit", "user", "-", "for", "masquerading", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Auth.php#L184-L188
train
fisharebest/webtrees
app/Report/ReportHtmlLine.php
ReportHtmlLine.render
public function render($renderer) { if ($this->x1 === ReportBaseElement::CURRENT_POSITION) { $this->x1 = $renderer->getX(); } if ($this->y1 === ReportBaseElement::CURRENT_POSITION) { $this->y1 = $renderer->getY(); } if ($this->x2 === ReportBaseElement::CURRENT_POSITION) { $this->x2 = $renderer->getRemainingWidth(); } if ($this->y2 === ReportBaseElement::CURRENT_POSITION) { $this->y2 = $renderer->getY(); } // Vertical line if ($this->x1 == $this->x2) { echo '<div style="position:absolute;overflow:hidden;border-', $renderer->alignRTL, ':solid black 1pt;', $renderer->alignRTL, ':', $this->x1, 'pt;top:', $this->y1 + 1, 'pt;width:1pt;height:', $this->y2 - $this->y1, "pt;\"> </div>\n"; } // Horizontal line if ($this->y1 == $this->y2) { echo '<div style="position:absolute;overflow:hidden;border-top:solid black 1pt;', $renderer->alignRTL, ':', $this->x1, 'pt;top:', $this->y1 + 1, 'pt;width:', $this->x2 - $this->x1, "pt;height:1pt;\"> </div>\n"; } // Keep max Y updated // One or the other will be higher... lasy mans way... $renderer->addMaxY($this->y1); $renderer->addMaxY($this->y2); }
php
public function render($renderer) { if ($this->x1 === ReportBaseElement::CURRENT_POSITION) { $this->x1 = $renderer->getX(); } if ($this->y1 === ReportBaseElement::CURRENT_POSITION) { $this->y1 = $renderer->getY(); } if ($this->x2 === ReportBaseElement::CURRENT_POSITION) { $this->x2 = $renderer->getRemainingWidth(); } if ($this->y2 === ReportBaseElement::CURRENT_POSITION) { $this->y2 = $renderer->getY(); } // Vertical line if ($this->x1 == $this->x2) { echo '<div style="position:absolute;overflow:hidden;border-', $renderer->alignRTL, ':solid black 1pt;', $renderer->alignRTL, ':', $this->x1, 'pt;top:', $this->y1 + 1, 'pt;width:1pt;height:', $this->y2 - $this->y1, "pt;\"> </div>\n"; } // Horizontal line if ($this->y1 == $this->y2) { echo '<div style="position:absolute;overflow:hidden;border-top:solid black 1pt;', $renderer->alignRTL, ':', $this->x1, 'pt;top:', $this->y1 + 1, 'pt;width:', $this->x2 - $this->x1, "pt;height:1pt;\"> </div>\n"; } // Keep max Y updated // One or the other will be higher... lasy mans way... $renderer->addMaxY($this->y1); $renderer->addMaxY($this->y2); }
[ "public", "function", "render", "(", "$", "renderer", ")", "{", "if", "(", "$", "this", "->", "x1", "===", "ReportBaseElement", "::", "CURRENT_POSITION", ")", "{", "$", "this", "->", "x1", "=", "$", "renderer", "->", "getX", "(", ")", ";", "}", "if", "(", "$", "this", "->", "y1", "===", "ReportBaseElement", "::", "CURRENT_POSITION", ")", "{", "$", "this", "->", "y1", "=", "$", "renderer", "->", "getY", "(", ")", ";", "}", "if", "(", "$", "this", "->", "x2", "===", "ReportBaseElement", "::", "CURRENT_POSITION", ")", "{", "$", "this", "->", "x2", "=", "$", "renderer", "->", "getRemainingWidth", "(", ")", ";", "}", "if", "(", "$", "this", "->", "y2", "===", "ReportBaseElement", "::", "CURRENT_POSITION", ")", "{", "$", "this", "->", "y2", "=", "$", "renderer", "->", "getY", "(", ")", ";", "}", "// Vertical line", "if", "(", "$", "this", "->", "x1", "==", "$", "this", "->", "x2", ")", "{", "echo", "'<div style=\"position:absolute;overflow:hidden;border-'", ",", "$", "renderer", "->", "alignRTL", ",", "':solid black 1pt;'", ",", "$", "renderer", "->", "alignRTL", ",", "':'", ",", "$", "this", "->", "x1", ",", "'pt;top:'", ",", "$", "this", "->", "y1", "+", "1", ",", "'pt;width:1pt;height:'", ",", "$", "this", "->", "y2", "-", "$", "this", "->", "y1", ",", "\"pt;\\\"> </div>\\n\"", ";", "}", "// Horizontal line", "if", "(", "$", "this", "->", "y1", "==", "$", "this", "->", "y2", ")", "{", "echo", "'<div style=\"position:absolute;overflow:hidden;border-top:solid black 1pt;'", ",", "$", "renderer", "->", "alignRTL", ",", "':'", ",", "$", "this", "->", "x1", ",", "'pt;top:'", ",", "$", "this", "->", "y1", "+", "1", ",", "'pt;width:'", ",", "$", "this", "->", "x2", "-", "$", "this", "->", "x1", ",", "\"pt;height:1pt;\\\"> </div>\\n\"", ";", "}", "// Keep max Y updated", "// One or the other will be higher... lasy mans way...", "$", "renderer", "->", "addMaxY", "(", "$", "this", "->", "y1", ")", ";", "$", "renderer", "->", "addMaxY", "(", "$", "this", "->", "y2", ")", ";", "}" ]
HTML line renderer @param ReportHtml $renderer @return void
[ "HTML", "line", "renderer" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportHtmlLine.php#L32-L58
train
fisharebest/webtrees
app/GedcomCode/GedcomCodeQuay.php
GedcomCodeQuay.getValues
public static function getValues(): array { $values = []; foreach (self::TYPES as $type) { $values[$type] = self::getValue($type); } return $values; }
php
public static function getValues(): array { $values = []; foreach (self::TYPES as $type) { $values[$type] = self::getValue($type); } return $values; }
[ "public", "static", "function", "getValues", "(", ")", ":", "array", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "self", "::", "TYPES", "as", "$", "type", ")", "{", "$", "values", "[", "$", "type", "]", "=", "self", "::", "getValue", "(", "$", "type", ")", ";", "}", "return", "$", "values", ";", "}" ]
A list of all possible values for QUAY @return string[]
[ "A", "list", "of", "all", "possible", "values", "for", "QUAY" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/GedcomCode/GedcomCodeQuay.php#L67-L75
train
fisharebest/webtrees
app/Module/CustomCssJsModule.php
CustomCssJsModule.getAdminAction
public function getAdminAction(): ResponseInterface { $this->layout = 'layouts/administration'; return $this->viewResponse('modules/custom-css-js/edit', [ 'title' => $this->title(), 'head' => $this->getPreference('head'), 'body' => $this->getPreference('body'), ]); }
php
public function getAdminAction(): ResponseInterface { $this->layout = 'layouts/administration'; return $this->viewResponse('modules/custom-css-js/edit', [ 'title' => $this->title(), 'head' => $this->getPreference('head'), 'body' => $this->getPreference('body'), ]); }
[ "public", "function", "getAdminAction", "(", ")", ":", "ResponseInterface", "{", "$", "this", "->", "layout", "=", "'layouts/administration'", ";", "return", "$", "this", "->", "viewResponse", "(", "'modules/custom-css-js/edit'", ",", "[", "'title'", "=>", "$", "this", "->", "title", "(", ")", ",", "'head'", "=>", "$", "this", "->", "getPreference", "(", "'head'", ")", ",", "'body'", "=>", "$", "this", "->", "getPreference", "(", "'body'", ")", ",", "]", ")", ";", "}" ]
Show a form to edit the user CSS and JS. @return ResponseInterface
[ "Show", "a", "form", "to", "edit", "the", "user", "CSS", "and", "JS", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/CustomCssJsModule.php#L59-L68
train
fisharebest/webtrees
app/Statistics/Repository/EventRepository.php
EventRepository.getCommonFacts
private function getCommonFacts(): array { // The list of facts used to limit the query result return array_merge( Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS ); }
php
private function getCommonFacts(): array { // The list of facts used to limit the query result return array_merge( Gedcom::BIRTH_EVENTS, Gedcom::MARRIAGE_EVENTS, Gedcom::DIVORCE_EVENTS, Gedcom::DEATH_EVENTS ); }
[ "private", "function", "getCommonFacts", "(", ")", ":", "array", "{", "// The list of facts used to limit the query result", "return", "array_merge", "(", "Gedcom", "::", "BIRTH_EVENTS", ",", "Gedcom", "::", "MARRIAGE_EVENTS", ",", "Gedcom", "::", "DIVORCE_EVENTS", ",", "Gedcom", "::", "DEATH_EVENTS", ")", ";", "}" ]
Retursn the list of common facts used query the data. @return array
[ "Retursn", "the", "list", "of", "common", "facts", "used", "query", "the", "data", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Repository/EventRepository.php#L186-L195
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.startElement
protected function startElement($parser, string $name, array $attrs): void { $newattrs = []; foreach ($attrs as $key => $value) { if (preg_match("/^\\$(\w+)$/", $value, $match)) { if (isset($this->vars[$match[1]]['id']) && !isset($this->vars[$match[1]]['gedcom'])) { $value = $this->vars[$match[1]]['id']; } } $newattrs[$key] = $value; } $attrs = $newattrs; if ($this->process_footnote && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag')) { $start_method = $name . 'StartHandler'; $end_method = $name . 'EndHandler'; if (method_exists($this, $start_method)) { $this->$start_method($attrs); } elseif (!method_exists($this, $end_method)) { $this->htmlStartHandler($name, $attrs); } } }
php
protected function startElement($parser, string $name, array $attrs): void { $newattrs = []; foreach ($attrs as $key => $value) { if (preg_match("/^\\$(\w+)$/", $value, $match)) { if (isset($this->vars[$match[1]]['id']) && !isset($this->vars[$match[1]]['gedcom'])) { $value = $this->vars[$match[1]]['id']; } } $newattrs[$key] = $value; } $attrs = $newattrs; if ($this->process_footnote && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag')) { $start_method = $name . 'StartHandler'; $end_method = $name . 'EndHandler'; if (method_exists($this, $start_method)) { $this->$start_method($attrs); } elseif (!method_exists($this, $end_method)) { $this->htmlStartHandler($name, $attrs); } } }
[ "protected", "function", "startElement", "(", "$", "parser", ",", "string", "$", "name", ",", "array", "$", "attrs", ")", ":", "void", "{", "$", "newattrs", "=", "[", "]", ";", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "preg_match", "(", "\"/^\\\\$(\\w+)$/\"", ",", "$", "value", ",", "$", "match", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "vars", "[", "$", "match", "[", "1", "]", "]", "[", "'id'", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "vars", "[", "$", "match", "[", "1", "]", "]", "[", "'gedcom'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "vars", "[", "$", "match", "[", "1", "]", "]", "[", "'id'", "]", ";", "}", "}", "$", "newattrs", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "attrs", "=", "$", "newattrs", ";", "if", "(", "$", "this", "->", "process_footnote", "&&", "(", "$", "this", "->", "process_ifs", "===", "0", "||", "$", "name", "===", "'if'", ")", "&&", "(", "$", "this", "->", "process_gedcoms", "===", "0", "||", "$", "name", "===", "'Gedcom'", ")", "&&", "(", "$", "this", "->", "process_repeats", "===", "0", "||", "$", "name", "===", "'Facts'", "||", "$", "name", "===", "'RepeatTag'", ")", ")", "{", "$", "start_method", "=", "$", "name", ".", "'StartHandler'", ";", "$", "end_method", "=", "$", "name", ".", "'EndHandler'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "start_method", ")", ")", "{", "$", "this", "->", "$", "start_method", "(", "$", "attrs", ")", ";", "}", "elseif", "(", "!", "method_exists", "(", "$", "this", ",", "$", "end_method", ")", ")", "{", "$", "this", "->", "htmlStartHandler", "(", "$", "name", ",", "$", "attrs", ")", ";", "}", "}", "}" ]
XML start element handler This function is called whenever a starting element is reached The element handler will be called if found, otherwise it must be HTML @param resource $parser the resource handler for the XML parser @param string $name the name of the XML element parsed @param string[] $attrs an array of key value pairs for the attributes @return void
[ "XML", "start", "element", "handler", "This", "function", "is", "called", "whenever", "a", "starting", "element", "is", "reached", "The", "element", "handler", "will", "be", "called", "if", "found", "otherwise", "it", "must", "be", "HTML" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L165-L188
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.endElement
protected function endElement($parser, string $name): void { if (($this->process_footnote || $name === 'Footnote') && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag' || $name === 'List' || $name === 'Relatives')) { $start_method = $name . 'StartHandler'; $end_method = $name . 'EndHandler'; if (method_exists($this, $end_method)) { $this->$end_method(); } elseif (!method_exists($this, $start_method)) { $this->htmlEndHandler($name); } } }
php
protected function endElement($parser, string $name): void { if (($this->process_footnote || $name === 'Footnote') && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag' || $name === 'List' || $name === 'Relatives')) { $start_method = $name . 'StartHandler'; $end_method = $name . 'EndHandler'; if (method_exists($this, $end_method)) { $this->$end_method(); } elseif (!method_exists($this, $start_method)) { $this->htmlEndHandler($name); } } }
[ "protected", "function", "endElement", "(", "$", "parser", ",", "string", "$", "name", ")", ":", "void", "{", "if", "(", "(", "$", "this", "->", "process_footnote", "||", "$", "name", "===", "'Footnote'", ")", "&&", "(", "$", "this", "->", "process_ifs", "===", "0", "||", "$", "name", "===", "'if'", ")", "&&", "(", "$", "this", "->", "process_gedcoms", "===", "0", "||", "$", "name", "===", "'Gedcom'", ")", "&&", "(", "$", "this", "->", "process_repeats", "===", "0", "||", "$", "name", "===", "'Facts'", "||", "$", "name", "===", "'RepeatTag'", "||", "$", "name", "===", "'List'", "||", "$", "name", "===", "'Relatives'", ")", ")", "{", "$", "start_method", "=", "$", "name", ".", "'StartHandler'", ";", "$", "end_method", "=", "$", "name", ".", "'EndHandler'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "end_method", ")", ")", "{", "$", "this", "->", "$", "end_method", "(", ")", ";", "}", "elseif", "(", "!", "method_exists", "(", "$", "this", ",", "$", "start_method", ")", ")", "{", "$", "this", "->", "htmlEndHandler", "(", "$", "name", ")", ";", "}", "}", "}" ]
XML end element handler This function is called whenever an ending element is reached The element handler will be called if found, otherwise it must be HTML @param resource $parser the resource handler for the XML parser @param string $name the name of the XML element parsed @return void
[ "XML", "end", "element", "handler", "This", "function", "is", "called", "whenever", "an", "ending", "element", "is", "reached", "The", "element", "handler", "will", "be", "called", "if", "found", "otherwise", "it", "must", "be", "HTML" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L200-L211
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.characterData
protected function characterData($parser, $data): void { if ($this->print_data && $this->process_gedcoms === 0 && $this->process_ifs === 0 && $this->process_repeats === 0) { $this->current_element->addText($data); } }
php
protected function characterData($parser, $data): void { if ($this->print_data && $this->process_gedcoms === 0 && $this->process_ifs === 0 && $this->process_repeats === 0) { $this->current_element->addText($data); } }
[ "protected", "function", "characterData", "(", "$", "parser", ",", "$", "data", ")", ":", "void", "{", "if", "(", "$", "this", "->", "print_data", "&&", "$", "this", "->", "process_gedcoms", "===", "0", "&&", "$", "this", "->", "process_ifs", "===", "0", "&&", "$", "this", "->", "process_repeats", "===", "0", ")", "{", "$", "this", "->", "current_element", "->", "addText", "(", "$", "data", ")", ";", "}", "}" ]
XML character data handler @param resource $parser the resource handler for the XML parser @param string $data the name of the XML element parsed @return void
[ "XML", "character", "data", "handler" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L221-L226
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.gedcomStartHandler
private function gedcomStartHandler(array $attrs): void { if ($this->process_gedcoms > 0) { $this->process_gedcoms++; return; } $tag = $attrs['id']; $tag = str_replace('@fact', $this->fact, $tag); $tags = explode(':', $tag); $newgedrec = ''; if (count($tags) < 2) { $tmp = GedcomRecord::getInstance($attrs['id'], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; } if (empty($newgedrec)) { $tgedrec = $this->gedrec; $newgedrec = ''; foreach ($tags as $tag) { if (preg_match('/\$(.+)/', $tag, $match)) { if (isset($this->vars[$match[1]]['gedcom'])) { $newgedrec = $this->vars[$match[1]]['gedcom']; } else { $tmp = GedcomRecord::getInstance($match[1], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; } } else { if (preg_match('/@(.+)/', $tag, $match)) { $gmatch = []; if (preg_match("/\d $match[1] @([^@]+)@/", $tgedrec, $gmatch)) { $tmp = GedcomRecord::getInstance($gmatch[1], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; $tgedrec = $newgedrec; } else { $newgedrec = ''; break; } } else { $temp = explode(' ', trim($tgedrec)); $level = 1 + (int) $temp[0]; $newgedrec = Functions::getSubRecord($level, "$level $tag", $tgedrec); $tgedrec = $newgedrec; } } } } if (!empty($newgedrec)) { $this->gedrec_stack[] = [$this->gedrec, $this->fact, $this->desc]; $this->gedrec = $newgedrec; if (preg_match("/(\d+) (_?[A-Z0-9]+) (.*)/", $this->gedrec, $match)) { $this->fact = $match[2]; $this->desc = trim($match[3]); } } else { $this->process_gedcoms++; } }
php
private function gedcomStartHandler(array $attrs): void { if ($this->process_gedcoms > 0) { $this->process_gedcoms++; return; } $tag = $attrs['id']; $tag = str_replace('@fact', $this->fact, $tag); $tags = explode(':', $tag); $newgedrec = ''; if (count($tags) < 2) { $tmp = GedcomRecord::getInstance($attrs['id'], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; } if (empty($newgedrec)) { $tgedrec = $this->gedrec; $newgedrec = ''; foreach ($tags as $tag) { if (preg_match('/\$(.+)/', $tag, $match)) { if (isset($this->vars[$match[1]]['gedcom'])) { $newgedrec = $this->vars[$match[1]]['gedcom']; } else { $tmp = GedcomRecord::getInstance($match[1], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; } } else { if (preg_match('/@(.+)/', $tag, $match)) { $gmatch = []; if (preg_match("/\d $match[1] @([^@]+)@/", $tgedrec, $gmatch)) { $tmp = GedcomRecord::getInstance($gmatch[1], $this->tree); $newgedrec = $tmp ? $tmp->privatizeGedcom(Auth::accessLevel($this->tree)) : ''; $tgedrec = $newgedrec; } else { $newgedrec = ''; break; } } else { $temp = explode(' ', trim($tgedrec)); $level = 1 + (int) $temp[0]; $newgedrec = Functions::getSubRecord($level, "$level $tag", $tgedrec); $tgedrec = $newgedrec; } } } } if (!empty($newgedrec)) { $this->gedrec_stack[] = [$this->gedrec, $this->fact, $this->desc]; $this->gedrec = $newgedrec; if (preg_match("/(\d+) (_?[A-Z0-9]+) (.*)/", $this->gedrec, $match)) { $this->fact = $match[2]; $this->desc = trim($match[3]); } } else { $this->process_gedcoms++; } }
[ "private", "function", "gedcomStartHandler", "(", "array", "$", "attrs", ")", ":", "void", "{", "if", "(", "$", "this", "->", "process_gedcoms", ">", "0", ")", "{", "$", "this", "->", "process_gedcoms", "++", ";", "return", ";", "}", "$", "tag", "=", "$", "attrs", "[", "'id'", "]", ";", "$", "tag", "=", "str_replace", "(", "'@fact'", ",", "$", "this", "->", "fact", ",", "$", "tag", ")", ";", "$", "tags", "=", "explode", "(", "':'", ",", "$", "tag", ")", ";", "$", "newgedrec", "=", "''", ";", "if", "(", "count", "(", "$", "tags", ")", "<", "2", ")", "{", "$", "tmp", "=", "GedcomRecord", "::", "getInstance", "(", "$", "attrs", "[", "'id'", "]", ",", "$", "this", "->", "tree", ")", ";", "$", "newgedrec", "=", "$", "tmp", "?", "$", "tmp", "->", "privatizeGedcom", "(", "Auth", "::", "accessLevel", "(", "$", "this", "->", "tree", ")", ")", ":", "''", ";", "}", "if", "(", "empty", "(", "$", "newgedrec", ")", ")", "{", "$", "tgedrec", "=", "$", "this", "->", "gedrec", ";", "$", "newgedrec", "=", "''", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "if", "(", "preg_match", "(", "'/\\$(.+)/'", ",", "$", "tag", ",", "$", "match", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "vars", "[", "$", "match", "[", "1", "]", "]", "[", "'gedcom'", "]", ")", ")", "{", "$", "newgedrec", "=", "$", "this", "->", "vars", "[", "$", "match", "[", "1", "]", "]", "[", "'gedcom'", "]", ";", "}", "else", "{", "$", "tmp", "=", "GedcomRecord", "::", "getInstance", "(", "$", "match", "[", "1", "]", ",", "$", "this", "->", "tree", ")", ";", "$", "newgedrec", "=", "$", "tmp", "?", "$", "tmp", "->", "privatizeGedcom", "(", "Auth", "::", "accessLevel", "(", "$", "this", "->", "tree", ")", ")", ":", "''", ";", "}", "}", "else", "{", "if", "(", "preg_match", "(", "'/@(.+)/'", ",", "$", "tag", ",", "$", "match", ")", ")", "{", "$", "gmatch", "=", "[", "]", ";", "if", "(", "preg_match", "(", "\"/\\d $match[1] @([^@]+)@/\"", ",", "$", "tgedrec", ",", "$", "gmatch", ")", ")", "{", "$", "tmp", "=", "GedcomRecord", "::", "getInstance", "(", "$", "gmatch", "[", "1", "]", ",", "$", "this", "->", "tree", ")", ";", "$", "newgedrec", "=", "$", "tmp", "?", "$", "tmp", "->", "privatizeGedcom", "(", "Auth", "::", "accessLevel", "(", "$", "this", "->", "tree", ")", ")", ":", "''", ";", "$", "tgedrec", "=", "$", "newgedrec", ";", "}", "else", "{", "$", "newgedrec", "=", "''", ";", "break", ";", "}", "}", "else", "{", "$", "temp", "=", "explode", "(", "' '", ",", "trim", "(", "$", "tgedrec", ")", ")", ";", "$", "level", "=", "1", "+", "(", "int", ")", "$", "temp", "[", "0", "]", ";", "$", "newgedrec", "=", "Functions", "::", "getSubRecord", "(", "$", "level", ",", "\"$level $tag\"", ",", "$", "tgedrec", ")", ";", "$", "tgedrec", "=", "$", "newgedrec", ";", "}", "}", "}", "}", "if", "(", "!", "empty", "(", "$", "newgedrec", ")", ")", "{", "$", "this", "->", "gedrec_stack", "[", "]", "=", "[", "$", "this", "->", "gedrec", ",", "$", "this", "->", "fact", ",", "$", "this", "->", "desc", "]", ";", "$", "this", "->", "gedrec", "=", "$", "newgedrec", ";", "if", "(", "preg_match", "(", "\"/(\\d+) (_?[A-Z0-9]+) (.*)/\"", ",", "$", "this", "->", "gedrec", ",", "$", "match", ")", ")", "{", "$", "this", "->", "fact", "=", "$", "match", "[", "2", "]", ";", "$", "this", "->", "desc", "=", "trim", "(", "$", "match", "[", "3", "]", ")", ";", "}", "}", "else", "{", "$", "this", "->", "process_gedcoms", "++", ";", "}", "}" ]
Called at the start of an element. @param string[] $attrs an array of key value pairs for the attributes @return void
[ "Called", "at", "the", "start", "of", "an", "element", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L638-L695
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.gedcomEndHandler
private function gedcomEndHandler(): void { if ($this->process_gedcoms > 0) { $this->process_gedcoms--; } else { [$this->gedrec, $this->fact, $this->desc] = array_pop($this->gedrec_stack); } }
php
private function gedcomEndHandler(): void { if ($this->process_gedcoms > 0) { $this->process_gedcoms--; } else { [$this->gedrec, $this->fact, $this->desc] = array_pop($this->gedrec_stack); } }
[ "private", "function", "gedcomEndHandler", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "process_gedcoms", ">", "0", ")", "{", "$", "this", "->", "process_gedcoms", "--", ";", "}", "else", "{", "[", "$", "this", "->", "gedrec", ",", "$", "this", "->", "fact", ",", "$", "this", "->", "desc", "]", "=", "array_pop", "(", "$", "this", "->", "gedrec_stack", ")", ";", "}", "}" ]
Called at the end of an element. @return void
[ "Called", "at", "the", "end", "of", "an", "element", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L702-L709
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.addDescendancy
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void { $person = Individual::getInstance($pid, $this->tree); if ($person === null) { return; } if (!isset($list[$pid])) { $list[$pid] = $person; } if (!isset($list[$pid]->generation)) { $list[$pid]->generation = 0; } foreach ($person->spouseFamilies() as $family) { if ($parents) { $husband = $family->husband(); $wife = $family->wife(); if ($husband) { $list[$husband->xref()] = $husband; if (isset($list[$pid]->generation)) { $list[$husband->xref()]->generation = $list[$pid]->generation - 1; } else { $list[$husband->xref()]->generation = 1; } } if ($wife) { $list[$wife->xref()] = $wife; if (isset($list[$pid]->generation)) { $list[$wife->xref()]->generation = $list[$pid]->generation - 1; } else { $list[$wife->xref()]->generation = 1; } } } $children = $family->children(); foreach ($children as $child) { if ($child) { $list[$child->xref()] = $child; if (isset($list[$pid]->generation)) { $list[$child->xref()]->generation = $list[$pid]->generation + 1; } else { $list[$child->xref()]->generation = 2; } } } if ($generations == -1 || $list[$pid]->generation + 1 < $generations) { foreach ($children as $child) { $this->addDescendancy($list, $child->xref(), $parents, $generations); // recurse on the childs family } } } }
php
private function addDescendancy(&$list, $pid, $parents = false, $generations = -1): void { $person = Individual::getInstance($pid, $this->tree); if ($person === null) { return; } if (!isset($list[$pid])) { $list[$pid] = $person; } if (!isset($list[$pid]->generation)) { $list[$pid]->generation = 0; } foreach ($person->spouseFamilies() as $family) { if ($parents) { $husband = $family->husband(); $wife = $family->wife(); if ($husband) { $list[$husband->xref()] = $husband; if (isset($list[$pid]->generation)) { $list[$husband->xref()]->generation = $list[$pid]->generation - 1; } else { $list[$husband->xref()]->generation = 1; } } if ($wife) { $list[$wife->xref()] = $wife; if (isset($list[$pid]->generation)) { $list[$wife->xref()]->generation = $list[$pid]->generation - 1; } else { $list[$wife->xref()]->generation = 1; } } } $children = $family->children(); foreach ($children as $child) { if ($child) { $list[$child->xref()] = $child; if (isset($list[$pid]->generation)) { $list[$child->xref()]->generation = $list[$pid]->generation + 1; } else { $list[$child->xref()]->generation = 2; } } } if ($generations == -1 || $list[$pid]->generation + 1 < $generations) { foreach ($children as $child) { $this->addDescendancy($list, $child->xref(), $parents, $generations); // recurse on the childs family } } } }
[ "private", "function", "addDescendancy", "(", "&", "$", "list", ",", "$", "pid", ",", "$", "parents", "=", "false", ",", "$", "generations", "=", "-", "1", ")", ":", "void", "{", "$", "person", "=", "Individual", "::", "getInstance", "(", "$", "pid", ",", "$", "this", "->", "tree", ")", ";", "if", "(", "$", "person", "===", "null", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "pid", "]", ")", ")", "{", "$", "list", "[", "$", "pid", "]", "=", "$", "person", ";", "}", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "pid", "]", "->", "generation", ")", ")", "{", "$", "list", "[", "$", "pid", "]", "->", "generation", "=", "0", ";", "}", "foreach", "(", "$", "person", "->", "spouseFamilies", "(", ")", "as", "$", "family", ")", "{", "if", "(", "$", "parents", ")", "{", "$", "husband", "=", "$", "family", "->", "husband", "(", ")", ";", "$", "wife", "=", "$", "family", "->", "wife", "(", ")", ";", "if", "(", "$", "husband", ")", "{", "$", "list", "[", "$", "husband", "->", "xref", "(", ")", "]", "=", "$", "husband", ";", "if", "(", "isset", "(", "$", "list", "[", "$", "pid", "]", "->", "generation", ")", ")", "{", "$", "list", "[", "$", "husband", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "pid", "]", "->", "generation", "-", "1", ";", "}", "else", "{", "$", "list", "[", "$", "husband", "->", "xref", "(", ")", "]", "->", "generation", "=", "1", ";", "}", "}", "if", "(", "$", "wife", ")", "{", "$", "list", "[", "$", "wife", "->", "xref", "(", ")", "]", "=", "$", "wife", ";", "if", "(", "isset", "(", "$", "list", "[", "$", "pid", "]", "->", "generation", ")", ")", "{", "$", "list", "[", "$", "wife", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "pid", "]", "->", "generation", "-", "1", ";", "}", "else", "{", "$", "list", "[", "$", "wife", "->", "xref", "(", ")", "]", "->", "generation", "=", "1", ";", "}", "}", "}", "$", "children", "=", "$", "family", "->", "children", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", ")", "{", "$", "list", "[", "$", "child", "->", "xref", "(", ")", "]", "=", "$", "child", ";", "if", "(", "isset", "(", "$", "list", "[", "$", "pid", "]", "->", "generation", ")", ")", "{", "$", "list", "[", "$", "child", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "pid", "]", "->", "generation", "+", "1", ";", "}", "else", "{", "$", "list", "[", "$", "child", "->", "xref", "(", ")", "]", "->", "generation", "=", "2", ";", "}", "}", "}", "if", "(", "$", "generations", "==", "-", "1", "||", "$", "list", "[", "$", "pid", "]", "->", "generation", "+", "1", "<", "$", "generations", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "this", "->", "addDescendancy", "(", "$", "list", ",", "$", "child", "->", "xref", "(", ")", ",", "$", "parents", ",", "$", "generations", ")", ";", "// recurse on the childs family", "}", "}", "}", "}" ]
Create a list of all descendants. @param string[] $list @param string $pid @param bool $parents @param int $generations @return void
[ "Create", "a", "list", "of", "all", "descendants", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L2696-L2749
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.addAncestors
private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void { $genlist = [$pid]; $list[$pid]->generation = 1; while (count($genlist) > 0) { $id = array_shift($genlist); if (strpos($id, 'empty') === 0) { continue; // id can be something like “empty7” } $person = Individual::getInstance($id, $this->tree); foreach ($person->childFamilies() as $family) { $husband = $family->husband(); $wife = $family->wife(); if ($husband) { $list[$husband->xref()] = $husband; $list[$husband->xref()]->generation = $list[$id]->generation + 1; } if ($wife) { $list[$wife->xref()] = $wife; $list[$wife->xref()]->generation = $list[$id]->generation + 1; } if ($generations == -1 || $list[$id]->generation + 1 < $generations) { if ($husband) { $genlist[] = $husband->xref(); } if ($wife) { $genlist[] = $wife->xref(); } } if ($children) { foreach ($family->children() as $child) { $list[$child->xref()] = $child; $list[$child->xref()]->generation = $list[$id]->generation ?? 1; } } } } }
php
private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void { $genlist = [$pid]; $list[$pid]->generation = 1; while (count($genlist) > 0) { $id = array_shift($genlist); if (strpos($id, 'empty') === 0) { continue; // id can be something like “empty7” } $person = Individual::getInstance($id, $this->tree); foreach ($person->childFamilies() as $family) { $husband = $family->husband(); $wife = $family->wife(); if ($husband) { $list[$husband->xref()] = $husband; $list[$husband->xref()]->generation = $list[$id]->generation + 1; } if ($wife) { $list[$wife->xref()] = $wife; $list[$wife->xref()]->generation = $list[$id]->generation + 1; } if ($generations == -1 || $list[$id]->generation + 1 < $generations) { if ($husband) { $genlist[] = $husband->xref(); } if ($wife) { $genlist[] = $wife->xref(); } } if ($children) { foreach ($family->children() as $child) { $list[$child->xref()] = $child; $list[$child->xref()]->generation = $list[$id]->generation ?? 1; } } } } }
[ "private", "function", "addAncestors", "(", "array", "&", "$", "list", ",", "string", "$", "pid", ",", "bool", "$", "children", "=", "false", ",", "int", "$", "generations", "=", "-", "1", ")", ":", "void", "{", "$", "genlist", "=", "[", "$", "pid", "]", ";", "$", "list", "[", "$", "pid", "]", "->", "generation", "=", "1", ";", "while", "(", "count", "(", "$", "genlist", ")", ">", "0", ")", "{", "$", "id", "=", "array_shift", "(", "$", "genlist", ")", ";", "if", "(", "strpos", "(", "$", "id", ",", "'empty'", ")", "===", "0", ")", "{", "continue", ";", "// id can be something like “empty7”", "}", "$", "person", "=", "Individual", "::", "getInstance", "(", "$", "id", ",", "$", "this", "->", "tree", ")", ";", "foreach", "(", "$", "person", "->", "childFamilies", "(", ")", "as", "$", "family", ")", "{", "$", "husband", "=", "$", "family", "->", "husband", "(", ")", ";", "$", "wife", "=", "$", "family", "->", "wife", "(", ")", ";", "if", "(", "$", "husband", ")", "{", "$", "list", "[", "$", "husband", "->", "xref", "(", ")", "]", "=", "$", "husband", ";", "$", "list", "[", "$", "husband", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "id", "]", "->", "generation", "+", "1", ";", "}", "if", "(", "$", "wife", ")", "{", "$", "list", "[", "$", "wife", "->", "xref", "(", ")", "]", "=", "$", "wife", ";", "$", "list", "[", "$", "wife", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "id", "]", "->", "generation", "+", "1", ";", "}", "if", "(", "$", "generations", "==", "-", "1", "||", "$", "list", "[", "$", "id", "]", "->", "generation", "+", "1", "<", "$", "generations", ")", "{", "if", "(", "$", "husband", ")", "{", "$", "genlist", "[", "]", "=", "$", "husband", "->", "xref", "(", ")", ";", "}", "if", "(", "$", "wife", ")", "{", "$", "genlist", "[", "]", "=", "$", "wife", "->", "xref", "(", ")", ";", "}", "}", "if", "(", "$", "children", ")", "{", "foreach", "(", "$", "family", "->", "children", "(", ")", "as", "$", "child", ")", "{", "$", "list", "[", "$", "child", "->", "xref", "(", ")", "]", "=", "$", "child", ";", "$", "list", "[", "$", "child", "->", "xref", "(", ")", "]", "->", "generation", "=", "$", "list", "[", "$", "id", "]", "->", "generation", "??", "1", ";", "}", "}", "}", "}", "}" ]
Create a list of all ancestors. @param string[] $list @param string $pid @param bool $children @param int $generations @return void
[ "Create", "a", "list", "of", "all", "ancestors", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L2761-L2798
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.getGedcomValue
private function getGedcomValue($tag, $level, $gedrec): string { if (empty($gedrec)) { return ''; } $tags = explode(':', $tag); $origlevel = $level; if ($level == 0) { $level = $gedrec[0] + 1; } $subrec = $gedrec; foreach ($tags as $t) { $lastsubrec = $subrec; $subrec = Functions::getSubRecord($level, "$level $t", $subrec); if (empty($subrec) && $origlevel == 0) { $level--; $subrec = Functions::getSubRecord($level, "$level $t", $lastsubrec); } if (empty($subrec)) { if ($t === 'TITL') { $subrec = Functions::getSubRecord($level, "$level ABBR", $lastsubrec); if (!empty($subrec)) { $t = 'ABBR'; } } if (empty($subrec)) { if ($level > 0) { $level--; } $subrec = Functions::getSubRecord($level, "@ $t", $gedrec); if (empty($subrec)) { return ''; } } } $level++; } $level--; $ct = preg_match("/$level $t(.*)/", $subrec, $match); if ($ct == 0) { $ct = preg_match("/$level @.+@ (.+)/", $subrec, $match); } if ($ct == 0) { $ct = preg_match("/@ $t (.+)/", $subrec, $match); } if ($ct > 0) { $value = trim($match[1]); if ($t === 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) { $note = Note::getInstance($match[1], $this->tree); if ($note instanceof Note) { $value = $note->getNote(); } else { //-- set the value to the id without the @ $value = $match[1]; } } if ($level != 0 || $t != 'NOTE') { $value .= Functions::getCont($level + 1, $subrec); } return $value; } return ''; }
php
private function getGedcomValue($tag, $level, $gedrec): string { if (empty($gedrec)) { return ''; } $tags = explode(':', $tag); $origlevel = $level; if ($level == 0) { $level = $gedrec[0] + 1; } $subrec = $gedrec; foreach ($tags as $t) { $lastsubrec = $subrec; $subrec = Functions::getSubRecord($level, "$level $t", $subrec); if (empty($subrec) && $origlevel == 0) { $level--; $subrec = Functions::getSubRecord($level, "$level $t", $lastsubrec); } if (empty($subrec)) { if ($t === 'TITL') { $subrec = Functions::getSubRecord($level, "$level ABBR", $lastsubrec); if (!empty($subrec)) { $t = 'ABBR'; } } if (empty($subrec)) { if ($level > 0) { $level--; } $subrec = Functions::getSubRecord($level, "@ $t", $gedrec); if (empty($subrec)) { return ''; } } } $level++; } $level--; $ct = preg_match("/$level $t(.*)/", $subrec, $match); if ($ct == 0) { $ct = preg_match("/$level @.+@ (.+)/", $subrec, $match); } if ($ct == 0) { $ct = preg_match("/@ $t (.+)/", $subrec, $match); } if ($ct > 0) { $value = trim($match[1]); if ($t === 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) { $note = Note::getInstance($match[1], $this->tree); if ($note instanceof Note) { $value = $note->getNote(); } else { //-- set the value to the id without the @ $value = $match[1]; } } if ($level != 0 || $t != 'NOTE') { $value .= Functions::getCont($level + 1, $subrec); } return $value; } return ''; }
[ "private", "function", "getGedcomValue", "(", "$", "tag", ",", "$", "level", ",", "$", "gedrec", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "gedrec", ")", ")", "{", "return", "''", ";", "}", "$", "tags", "=", "explode", "(", "':'", ",", "$", "tag", ")", ";", "$", "origlevel", "=", "$", "level", ";", "if", "(", "$", "level", "==", "0", ")", "{", "$", "level", "=", "$", "gedrec", "[", "0", "]", "+", "1", ";", "}", "$", "subrec", "=", "$", "gedrec", ";", "foreach", "(", "$", "tags", "as", "$", "t", ")", "{", "$", "lastsubrec", "=", "$", "subrec", ";", "$", "subrec", "=", "Functions", "::", "getSubRecord", "(", "$", "level", ",", "\"$level $t\"", ",", "$", "subrec", ")", ";", "if", "(", "empty", "(", "$", "subrec", ")", "&&", "$", "origlevel", "==", "0", ")", "{", "$", "level", "--", ";", "$", "subrec", "=", "Functions", "::", "getSubRecord", "(", "$", "level", ",", "\"$level $t\"", ",", "$", "lastsubrec", ")", ";", "}", "if", "(", "empty", "(", "$", "subrec", ")", ")", "{", "if", "(", "$", "t", "===", "'TITL'", ")", "{", "$", "subrec", "=", "Functions", "::", "getSubRecord", "(", "$", "level", ",", "\"$level ABBR\"", ",", "$", "lastsubrec", ")", ";", "if", "(", "!", "empty", "(", "$", "subrec", ")", ")", "{", "$", "t", "=", "'ABBR'", ";", "}", "}", "if", "(", "empty", "(", "$", "subrec", ")", ")", "{", "if", "(", "$", "level", ">", "0", ")", "{", "$", "level", "--", ";", "}", "$", "subrec", "=", "Functions", "::", "getSubRecord", "(", "$", "level", ",", "\"@ $t\"", ",", "$", "gedrec", ")", ";", "if", "(", "empty", "(", "$", "subrec", ")", ")", "{", "return", "''", ";", "}", "}", "}", "$", "level", "++", ";", "}", "$", "level", "--", ";", "$", "ct", "=", "preg_match", "(", "\"/$level $t(.*)/\"", ",", "$", "subrec", ",", "$", "match", ")", ";", "if", "(", "$", "ct", "==", "0", ")", "{", "$", "ct", "=", "preg_match", "(", "\"/$level @.+@ (.+)/\"", ",", "$", "subrec", ",", "$", "match", ")", ";", "}", "if", "(", "$", "ct", "==", "0", ")", "{", "$", "ct", "=", "preg_match", "(", "\"/@ $t (.+)/\"", ",", "$", "subrec", ",", "$", "match", ")", ";", "}", "if", "(", "$", "ct", ">", "0", ")", "{", "$", "value", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "if", "(", "$", "t", "===", "'NOTE'", "&&", "preg_match", "(", "'/^@(.+)@$/'", ",", "$", "value", ",", "$", "match", ")", ")", "{", "$", "note", "=", "Note", "::", "getInstance", "(", "$", "match", "[", "1", "]", ",", "$", "this", "->", "tree", ")", ";", "if", "(", "$", "note", "instanceof", "Note", ")", "{", "$", "value", "=", "$", "note", "->", "getNote", "(", ")", ";", "}", "else", "{", "//-- set the value to the id without the @", "$", "value", "=", "$", "match", "[", "1", "]", ";", "}", "}", "if", "(", "$", "level", "!=", "0", "||", "$", "t", "!=", "'NOTE'", ")", "{", "$", "value", ".=", "Functions", "::", "getCont", "(", "$", "level", "+", "1", ",", "$", "subrec", ")", ";", "}", "return", "$", "value", ";", "}", "return", "''", ";", "}" ]
get gedcom tag value @param string $tag The tag to find, use : to delineate subtags @param int $level The gedcom line level of the first tag to find, setting level to 0 will cause it to use 1+ the level of the incoming record @param string $gedrec The gedcom record to get the value from @return string the value of a gedcom tag from the given gedcom record
[ "get", "gedcom", "tag", "value" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L2809-L2874
train
fisharebest/webtrees
app/Report/ReportParserGenerate.php
ReportParserGenerate.substituteVars
private function substituteVars($expression, $quote): string { return preg_replace_callback( '/\$(\w+)/', function (array $matches) use ($quote): string { if (isset($this->vars[$matches[1]]['id'])) { if ($quote) { return "'" . addcslashes($this->vars[$matches[1]]['id'], "'") . "'"; } return $this->vars[$matches[1]]['id']; } Log::addErrorLog(sprintf('Undefined variable $%s in report', $matches[1])); return '$' . $matches[1]; }, $expression ); }
php
private function substituteVars($expression, $quote): string { return preg_replace_callback( '/\$(\w+)/', function (array $matches) use ($quote): string { if (isset($this->vars[$matches[1]]['id'])) { if ($quote) { return "'" . addcslashes($this->vars[$matches[1]]['id'], "'") . "'"; } return $this->vars[$matches[1]]['id']; } Log::addErrorLog(sprintf('Undefined variable $%s in report', $matches[1])); return '$' . $matches[1]; }, $expression ); }
[ "private", "function", "substituteVars", "(", "$", "expression", ",", "$", "quote", ")", ":", "string", "{", "return", "preg_replace_callback", "(", "'/\\$(\\w+)/'", ",", "function", "(", "array", "$", "matches", ")", "use", "(", "$", "quote", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "vars", "[", "$", "matches", "[", "1", "]", "]", "[", "'id'", "]", ")", ")", "{", "if", "(", "$", "quote", ")", "{", "return", "\"'\"", ".", "addcslashes", "(", "$", "this", "->", "vars", "[", "$", "matches", "[", "1", "]", "]", "[", "'id'", "]", ",", "\"'\"", ")", ".", "\"'\"", ";", "}", "return", "$", "this", "->", "vars", "[", "$", "matches", "[", "1", "]", "]", "[", "'id'", "]", ";", "}", "Log", "::", "addErrorLog", "(", "sprintf", "(", "'Undefined variable $%s in report'", ",", "$", "matches", "[", "1", "]", ")", ")", ";", "return", "'$'", ".", "$", "matches", "[", "1", "]", ";", "}", ",", "$", "expression", ")", ";", "}" ]
Replace variable identifiers with their values. @param string $expression An expression such as "$foo == 123" @param bool $quote Whether to add quotation marks @return string
[ "Replace", "variable", "identifiers", "with", "their", "values", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportParserGenerate.php#L2884-L2903
train
fisharebest/webtrees
app/File.php
File.mkdir
public static function mkdir($path): bool { if (is_dir($path)) { return true; } if (dirname($path) && !is_dir(dirname($path))) { self::mkdir(dirname($path)); } try { mkdir($path); return true; } catch (Throwable $ex) { return false; } }
php
public static function mkdir($path): bool { if (is_dir($path)) { return true; } if (dirname($path) && !is_dir(dirname($path))) { self::mkdir(dirname($path)); } try { mkdir($path); return true; } catch (Throwable $ex) { return false; } }
[ "public", "static", "function", "mkdir", "(", "$", "path", ")", ":", "bool", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "return", "true", ";", "}", "if", "(", "dirname", "(", "$", "path", ")", "&&", "!", "is_dir", "(", "dirname", "(", "$", "path", ")", ")", ")", "{", "self", "::", "mkdir", "(", "dirname", "(", "$", "path", ")", ")", ";", "}", "try", "{", "mkdir", "(", "$", "path", ")", ";", "return", "true", ";", "}", "catch", "(", "Throwable", "$", "ex", ")", "{", "return", "false", ";", "}", "}" ]
Create a folder, and sub-folders, if it does not already exist @param string $path @return bool Does the folder now exist
[ "Create", "a", "folder", "and", "sub", "-", "folders", "if", "it", "does", "not", "already", "exist" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/File.php#L34-L51
train
fisharebest/webtrees
app/Functions/FunctionsPrintLists.php
FunctionsPrintLists.surnameTagCloud
public static function surnameTagCloud(array $surnames, ?ModuleListInterface $module, bool $totals, Tree $tree): string { $minimum = PHP_INT_MAX; $maximum = 1; foreach ($surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $count) { $maximum = max($maximum, $count); $minimum = min($minimum, $count); } } $html = ''; foreach ($surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $count) { if ($maximum === $minimum) { // All surnames occur the same number of times $size = 150.0; } else { $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); } $tag = ($module instanceof ModuleListInterface) ? 'a' : 'span'; $html .= '<' . $tag . ' style="font-size:' . $size . '%"'; if ($module instanceof ModuleListInterface) { $url = $module->listUrl($tree, ['surname' => $surn]); $html .= ' href="' . e($url) . '"'; } $html .= '>'; if ($totals) { $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $spfxsurn . '</span>', I18N::number($count)); } else { $html .= $spfxsurn; } $html .= '</' . $tag . '> '; } } return '<div class="tag_cloud">' . $html . '</div>'; }
php
public static function surnameTagCloud(array $surnames, ?ModuleListInterface $module, bool $totals, Tree $tree): string { $minimum = PHP_INT_MAX; $maximum = 1; foreach ($surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $count) { $maximum = max($maximum, $count); $minimum = min($minimum, $count); } } $html = ''; foreach ($surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $count) { if ($maximum === $minimum) { // All surnames occur the same number of times $size = 150.0; } else { $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); } $tag = ($module instanceof ModuleListInterface) ? 'a' : 'span'; $html .= '<' . $tag . ' style="font-size:' . $size . '%"'; if ($module instanceof ModuleListInterface) { $url = $module->listUrl($tree, ['surname' => $surn]); $html .= ' href="' . e($url) . '"'; } $html .= '>'; if ($totals) { $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $spfxsurn . '</span>', I18N::number($count)); } else { $html .= $spfxsurn; } $html .= '</' . $tag . '> '; } } return '<div class="tag_cloud">' . $html . '</div>'; }
[ "public", "static", "function", "surnameTagCloud", "(", "array", "$", "surnames", ",", "?", "ModuleListInterface", "$", "module", ",", "bool", "$", "totals", ",", "Tree", "$", "tree", ")", ":", "string", "{", "$", "minimum", "=", "PHP_INT_MAX", ";", "$", "maximum", "=", "1", ";", "foreach", "(", "$", "surnames", "as", "$", "surn", "=>", "$", "surns", ")", "{", "foreach", "(", "$", "surns", "as", "$", "spfxsurn", "=>", "$", "count", ")", "{", "$", "maximum", "=", "max", "(", "$", "maximum", ",", "$", "count", ")", ";", "$", "minimum", "=", "min", "(", "$", "minimum", ",", "$", "count", ")", ";", "}", "}", "$", "html", "=", "''", ";", "foreach", "(", "$", "surnames", "as", "$", "surn", "=>", "$", "surns", ")", "{", "foreach", "(", "$", "surns", "as", "$", "spfxsurn", "=>", "$", "count", ")", "{", "if", "(", "$", "maximum", "===", "$", "minimum", ")", "{", "// All surnames occur the same number of times", "$", "size", "=", "150.0", ";", "}", "else", "{", "$", "size", "=", "75.0", "+", "125.0", "*", "(", "$", "count", "-", "$", "minimum", ")", "/", "(", "$", "maximum", "-", "$", "minimum", ")", ";", "}", "$", "tag", "=", "(", "$", "module", "instanceof", "ModuleListInterface", ")", "?", "'a'", ":", "'span'", ";", "$", "html", ".=", "'<'", ".", "$", "tag", ".", "' style=\"font-size:'", ".", "$", "size", ".", "'%\"'", ";", "if", "(", "$", "module", "instanceof", "ModuleListInterface", ")", "{", "$", "url", "=", "$", "module", "->", "listUrl", "(", "$", "tree", ",", "[", "'surname'", "=>", "$", "surn", "]", ")", ";", "$", "html", ".=", "' href=\"'", ".", "e", "(", "$", "url", ")", ".", "'\"'", ";", "}", "$", "html", ".=", "'>'", ";", "if", "(", "$", "totals", ")", "{", "$", "html", ".=", "I18N", "::", "translate", "(", "'%1$s (%2$s)'", ",", "'<span dir=\"auto\">'", ".", "$", "spfxsurn", ".", "'</span>'", ",", "I18N", "::", "number", "(", "$", "count", ")", ")", ";", "}", "else", "{", "$", "html", ".=", "$", "spfxsurn", ";", "}", "$", "html", ".=", "'</'", ".", "$", "tag", ".", "'> '", ";", "}", "}", "return", "'<div class=\"tag_cloud\">'", ".", "$", "html", ".", "'</div>'", ";", "}" ]
Print a tagcloud of surnames. @param int[][] $surnames array (of SURN, of array of SPFX_SURN, of counts) @param ModuleListInterface|null $module @param bool $totals show totals after each name @param Tree $tree generate links to this tree @return string
[ "Print", "a", "tagcloud", "of", "surnames", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsPrintLists.php#L39-L77
train
fisharebest/webtrees
app/Functions/FunctionsPrintLists.php
FunctionsPrintLists.surnameList
public static function surnameList($surnames, $style, $totals, ?ModuleListInterface $module, Tree $tree): string { $html = []; foreach ($surnames as $surn => $surns) { // Each surname links back to the indilist if ($module instanceof ModuleListInterface) { if ($surn) { $url = $module->listUrl($tree, ['surname' => $surn]); } else { $url = $module->listUrl($tree, ['alpha' => ',']); } } else { $url = null; } // If all the surnames are just case variants, then merge them into one // Comment out this block if you want SMITH listed separately from Smith $tag = ($module instanceof ModuleListInterface) ? 'a' : 'span'; $subhtml = '<' . $tag; if ($url !== null) { $subhtml .= ' href="' . e($url) . '"'; } $subhtml .= ' dir="auto">' . e(implode(I18N::$list_separator, array_keys($surns))) . '</' . $tag . '>'; if ($totals) { $subtotal = 0; foreach ($surns as $count) { $subtotal += $count; } $subhtml .= '&nbsp;(' . I18N::number($subtotal) . ')'; } $html[] = $subhtml; } switch ($style) { default: case 1: return '<ul><li>' . implode('</li><li>', $html) . '</li></ul>'; case 2: return implode(I18N::$list_separator, $html); case 3: $i = 0; $count = count($html); if ($count > 36) { $col = 4; } elseif ($count > 18) { $col = 3; } elseif ($count > 6) { $col = 2; } else { $col = 1; } $newcol = (int) ceil($count / $col); $html2 = '<table class="list_table"><tr>'; $html2 .= '<td class="list_value" style="padding: 14px;">'; foreach ($html as $surns) { $html2 .= $surns . '<br>'; $i++; if ($i === $newcol && $i < $count) { $html2 .= '</td><td class="list_value" style="padding: 14px;">'; $newcol = $i + ceil($count / $col); } } $html2 .= '</td></tr></table>'; return $html2; } }
php
public static function surnameList($surnames, $style, $totals, ?ModuleListInterface $module, Tree $tree): string { $html = []; foreach ($surnames as $surn => $surns) { // Each surname links back to the indilist if ($module instanceof ModuleListInterface) { if ($surn) { $url = $module->listUrl($tree, ['surname' => $surn]); } else { $url = $module->listUrl($tree, ['alpha' => ',']); } } else { $url = null; } // If all the surnames are just case variants, then merge them into one // Comment out this block if you want SMITH listed separately from Smith $tag = ($module instanceof ModuleListInterface) ? 'a' : 'span'; $subhtml = '<' . $tag; if ($url !== null) { $subhtml .= ' href="' . e($url) . '"'; } $subhtml .= ' dir="auto">' . e(implode(I18N::$list_separator, array_keys($surns))) . '</' . $tag . '>'; if ($totals) { $subtotal = 0; foreach ($surns as $count) { $subtotal += $count; } $subhtml .= '&nbsp;(' . I18N::number($subtotal) . ')'; } $html[] = $subhtml; } switch ($style) { default: case 1: return '<ul><li>' . implode('</li><li>', $html) . '</li></ul>'; case 2: return implode(I18N::$list_separator, $html); case 3: $i = 0; $count = count($html); if ($count > 36) { $col = 4; } elseif ($count > 18) { $col = 3; } elseif ($count > 6) { $col = 2; } else { $col = 1; } $newcol = (int) ceil($count / $col); $html2 = '<table class="list_table"><tr>'; $html2 .= '<td class="list_value" style="padding: 14px;">'; foreach ($html as $surns) { $html2 .= $surns . '<br>'; $i++; if ($i === $newcol && $i < $count) { $html2 .= '</td><td class="list_value" style="padding: 14px;">'; $newcol = $i + ceil($count / $col); } } $html2 .= '</td></tr></table>'; return $html2; } }
[ "public", "static", "function", "surnameList", "(", "$", "surnames", ",", "$", "style", ",", "$", "totals", ",", "?", "ModuleListInterface", "$", "module", ",", "Tree", "$", "tree", ")", ":", "string", "{", "$", "html", "=", "[", "]", ";", "foreach", "(", "$", "surnames", "as", "$", "surn", "=>", "$", "surns", ")", "{", "// Each surname links back to the indilist", "if", "(", "$", "module", "instanceof", "ModuleListInterface", ")", "{", "if", "(", "$", "surn", ")", "{", "$", "url", "=", "$", "module", "->", "listUrl", "(", "$", "tree", ",", "[", "'surname'", "=>", "$", "surn", "]", ")", ";", "}", "else", "{", "$", "url", "=", "$", "module", "->", "listUrl", "(", "$", "tree", ",", "[", "'alpha'", "=>", "','", "]", ")", ";", "}", "}", "else", "{", "$", "url", "=", "null", ";", "}", "// If all the surnames are just case variants, then merge them into one", "// Comment out this block if you want SMITH listed separately from Smith", "$", "tag", "=", "(", "$", "module", "instanceof", "ModuleListInterface", ")", "?", "'a'", ":", "'span'", ";", "$", "subhtml", "=", "'<'", ".", "$", "tag", ";", "if", "(", "$", "url", "!==", "null", ")", "{", "$", "subhtml", ".=", "' href=\"'", ".", "e", "(", "$", "url", ")", ".", "'\"'", ";", "}", "$", "subhtml", ".=", "' dir=\"auto\">'", ".", "e", "(", "implode", "(", "I18N", "::", "$", "list_separator", ",", "array_keys", "(", "$", "surns", ")", ")", ")", ".", "'</'", ".", "$", "tag", ".", "'>'", ";", "if", "(", "$", "totals", ")", "{", "$", "subtotal", "=", "0", ";", "foreach", "(", "$", "surns", "as", "$", "count", ")", "{", "$", "subtotal", "+=", "$", "count", ";", "}", "$", "subhtml", ".=", "'&nbsp;('", ".", "I18N", "::", "number", "(", "$", "subtotal", ")", ".", "')'", ";", "}", "$", "html", "[", "]", "=", "$", "subhtml", ";", "}", "switch", "(", "$", "style", ")", "{", "default", ":", "case", "1", ":", "return", "'<ul><li>'", ".", "implode", "(", "'</li><li>'", ",", "$", "html", ")", ".", "'</li></ul>'", ";", "case", "2", ":", "return", "implode", "(", "I18N", "::", "$", "list_separator", ",", "$", "html", ")", ";", "case", "3", ":", "$", "i", "=", "0", ";", "$", "count", "=", "count", "(", "$", "html", ")", ";", "if", "(", "$", "count", ">", "36", ")", "{", "$", "col", "=", "4", ";", "}", "elseif", "(", "$", "count", ">", "18", ")", "{", "$", "col", "=", "3", ";", "}", "elseif", "(", "$", "count", ">", "6", ")", "{", "$", "col", "=", "2", ";", "}", "else", "{", "$", "col", "=", "1", ";", "}", "$", "newcol", "=", "(", "int", ")", "ceil", "(", "$", "count", "/", "$", "col", ")", ";", "$", "html2", "=", "'<table class=\"list_table\"><tr>'", ";", "$", "html2", ".=", "'<td class=\"list_value\" style=\"padding: 14px;\">'", ";", "foreach", "(", "$", "html", "as", "$", "surns", ")", "{", "$", "html2", ".=", "$", "surns", ".", "'<br>'", ";", "$", "i", "++", ";", "if", "(", "$", "i", "===", "$", "newcol", "&&", "$", "i", "<", "$", "count", ")", "{", "$", "html2", ".=", "'</td><td class=\"list_value\" style=\"padding: 14px;\">'", ";", "$", "newcol", "=", "$", "i", "+", "ceil", "(", "$", "count", "/", "$", "col", ")", ";", "}", "}", "$", "html2", ".=", "'</td></tr></table>'", ";", "return", "$", "html2", ";", "}", "}" ]
Print a list of surnames. @param int[][] $surnames counts of surname by variant @param int $style 1=bullet list, 2=semicolon-separated list, 3=tabulated list with up to 4 columns @param bool $totals show totals after each name @param ModuleListInterface|null $module @param Tree $tree Link back to the individual list in this tree @return string
[ "Print", "a", "list", "of", "surnames", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsPrintLists.php#L90-L157
train
fisharebest/webtrees
app/Http/Controllers/Admin/ModuleController.php
ModuleController.list
public function list(): ResponseInterface { return $this->viewResponse('admin/modules', [ 'title' => I18N::translate('All modules'), 'modules' => $this->module_service->all(true), 'deleted_modules' => $this->module_service->deletedModules(), ]); }
php
public function list(): ResponseInterface { return $this->viewResponse('admin/modules', [ 'title' => I18N::translate('All modules'), 'modules' => $this->module_service->all(true), 'deleted_modules' => $this->module_service->deletedModules(), ]); }
[ "public", "function", "list", "(", ")", ":", "ResponseInterface", "{", "return", "$", "this", "->", "viewResponse", "(", "'admin/modules'", ",", "[", "'title'", "=>", "I18N", "::", "translate", "(", "'All modules'", ")", ",", "'modules'", "=>", "$", "this", "->", "module_service", "->", "all", "(", "true", ")", ",", "'deleted_modules'", "=>", "$", "this", "->", "module_service", "->", "deletedModules", "(", ")", ",", "]", ")", ";", "}" ]
Show the administrator a list of modules. @return ResponseInterface
[ "Show", "the", "administrator", "a", "list", "of", "modules", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/ModuleController.php#L83-L90
train
fisharebest/webtrees
app/Module/ColorsTheme.php
ColorsTheme.menuPalette
public function menuPalette(): Menu { $request = app(ServerRequestInterface::class); /* I18N: A colour scheme */ $menu = new Menu(I18N::translate('Palette'), '#', 'menu-color'); foreach ($this->palettes() as $palette_id => $palette_name) { $url = (string) $request->getUri(); $url = preg_replace('/&themecolor=[a-z]+/', '', $url); $url .= '&themecolor=' . $palette_id; $menu->addSubmenu(new Menu( $palette_name, '#', 'menu-color-' . $palette_id . ($this->palette() === $palette_id ? ' active' : ''), [ 'onclick' => 'document.location=\'' . $url . '\'', ] )); } return $menu; }
php
public function menuPalette(): Menu { $request = app(ServerRequestInterface::class); /* I18N: A colour scheme */ $menu = new Menu(I18N::translate('Palette'), '#', 'menu-color'); foreach ($this->palettes() as $palette_id => $palette_name) { $url = (string) $request->getUri(); $url = preg_replace('/&themecolor=[a-z]+/', '', $url); $url .= '&themecolor=' . $palette_id; $menu->addSubmenu(new Menu( $palette_name, '#', 'menu-color-' . $palette_id . ($this->palette() === $palette_id ? ' active' : ''), [ 'onclick' => 'document.location=\'' . $url . '\'', ] )); } return $menu; }
[ "public", "function", "menuPalette", "(", ")", ":", "Menu", "{", "$", "request", "=", "app", "(", "ServerRequestInterface", "::", "class", ")", ";", "/* I18N: A colour scheme */", "$", "menu", "=", "new", "Menu", "(", "I18N", "::", "translate", "(", "'Palette'", ")", ",", "'#'", ",", "'menu-color'", ")", ";", "foreach", "(", "$", "this", "->", "palettes", "(", ")", "as", "$", "palette_id", "=>", "$", "palette_name", ")", "{", "$", "url", "=", "(", "string", ")", "$", "request", "->", "getUri", "(", ")", ";", "$", "url", "=", "preg_replace", "(", "'/&themecolor=[a-z]+/'", ",", "''", ",", "$", "url", ")", ";", "$", "url", ".=", "'&themecolor='", ".", "$", "palette_id", ";", "$", "menu", "->", "addSubmenu", "(", "new", "Menu", "(", "$", "palette_name", ",", "'#'", ",", "'menu-color-'", ".", "$", "palette_id", ".", "(", "$", "this", "->", "palette", "(", ")", "===", "$", "palette_id", "?", "' active'", ":", "''", ")", ",", "[", "'onclick'", "=>", "'document.location=\\''", ".", "$", "url", ".", "'\\''", ",", "]", ")", ")", ";", "}", "return", "$", "menu", ";", "}" ]
Create a menu of palette options @return Menu
[ "Create", "a", "menu", "of", "palette", "options" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ColorsTheme.php#L71-L94
train
fisharebest/webtrees
app/Carbon.php
Carbon.local
public function local(): Carbon { $locale = app(LocaleInterface::class)->code(); $timezone = Auth::user()->getPreference('TIMEZONE', Site::getPreference('TIMEZONE', 'UTC')); return $this->locale($locale)->setTimezone($timezone); }
php
public function local(): Carbon { $locale = app(LocaleInterface::class)->code(); $timezone = Auth::user()->getPreference('TIMEZONE', Site::getPreference('TIMEZONE', 'UTC')); return $this->locale($locale)->setTimezone($timezone); }
[ "public", "function", "local", "(", ")", ":", "Carbon", "{", "$", "locale", "=", "app", "(", "LocaleInterface", "::", "class", ")", "->", "code", "(", ")", ";", "$", "timezone", "=", "Auth", "::", "user", "(", ")", "->", "getPreference", "(", "'TIMEZONE'", ",", "Site", "::", "getPreference", "(", "'TIMEZONE'", ",", "'UTC'", ")", ")", ";", "return", "$", "this", "->", "locale", "(", "$", "locale", ")", "->", "setTimezone", "(", "$", "timezone", ")", ";", "}" ]
Create a local timestamp for the current user. @return Carbon
[ "Create", "a", "local", "timestamp", "for", "the", "current", "user", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Carbon.php#L46-L52
train
fisharebest/webtrees
app/Module/IndividualFactsTabModule.php
IndividualFactsTabModule.historicalFacts
private function historicalFacts(Individual $individual): array { return $this->module_service->findByInterface(ModuleHistoricEventsInterface::class) ->map(static function (ModuleHistoricEventsInterface $module) use ($individual): Collection { return $module->historicEventsForIndividual($individual); }) ->flatten() ->all(); }
php
private function historicalFacts(Individual $individual): array { return $this->module_service->findByInterface(ModuleHistoricEventsInterface::class) ->map(static function (ModuleHistoricEventsInterface $module) use ($individual): Collection { return $module->historicEventsForIndividual($individual); }) ->flatten() ->all(); }
[ "private", "function", "historicalFacts", "(", "Individual", "$", "individual", ")", ":", "array", "{", "return", "$", "this", "->", "module_service", "->", "findByInterface", "(", "ModuleHistoricEventsInterface", "::", "class", ")", "->", "map", "(", "static", "function", "(", "ModuleHistoricEventsInterface", "$", "module", ")", "use", "(", "$", "individual", ")", ":", "Collection", "{", "return", "$", "module", "->", "historicEventsForIndividual", "(", "$", "individual", ")", ";", "}", ")", "->", "flatten", "(", ")", "->", "all", "(", ")", ";", "}" ]
Get any historical events. @param Individual $individual @return Fact[]
[ "Get", "any", "historical", "events", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/IndividualFactsTabModule.php#L453-L461
train
fisharebest/webtrees
app/Module/IndividualFactsTabModule.php
IndividualFactsTabModule.associateFacts
private function associateFacts(Individual $person): array { $facts = []; /** @var Individual[] $associates */ $associates = array_merge( $person->linkedIndividuals('ASSO'), $person->linkedIndividuals('_ASSO'), $person->linkedFamilies('ASSO'), $person->linkedFamilies('_ASSO') ); foreach ($associates as $associate) { foreach ($associate->facts() as $fact) { $arec = $fact->attribute('_ASSO'); if (!$arec) { $arec = $fact->attribute('ASSO'); } if ($arec && trim($arec, '@') === $person->xref()) { // Extract the important details from the fact $factrec = '1 ' . $fact->getTag(); if (preg_match('/\n2 DATE .*/', $fact->gedcom(), $match)) { $factrec .= $match[0]; } if (preg_match('/\n2 PLAC .*/', $fact->gedcom(), $match)) { $factrec .= $match[0]; } if ($associate instanceof Family) { foreach ($associate->spouses() as $spouse) { $factrec .= "\n2 _ASSO @" . $spouse->xref() . '@'; } } else { $factrec .= "\n2 _ASSO @" . $associate->xref() . '@'; } $facts[] = new Fact($factrec, $associate, 'asso'); } } } return $facts; }
php
private function associateFacts(Individual $person): array { $facts = []; /** @var Individual[] $associates */ $associates = array_merge( $person->linkedIndividuals('ASSO'), $person->linkedIndividuals('_ASSO'), $person->linkedFamilies('ASSO'), $person->linkedFamilies('_ASSO') ); foreach ($associates as $associate) { foreach ($associate->facts() as $fact) { $arec = $fact->attribute('_ASSO'); if (!$arec) { $arec = $fact->attribute('ASSO'); } if ($arec && trim($arec, '@') === $person->xref()) { // Extract the important details from the fact $factrec = '1 ' . $fact->getTag(); if (preg_match('/\n2 DATE .*/', $fact->gedcom(), $match)) { $factrec .= $match[0]; } if (preg_match('/\n2 PLAC .*/', $fact->gedcom(), $match)) { $factrec .= $match[0]; } if ($associate instanceof Family) { foreach ($associate->spouses() as $spouse) { $factrec .= "\n2 _ASSO @" . $spouse->xref() . '@'; } } else { $factrec .= "\n2 _ASSO @" . $associate->xref() . '@'; } $facts[] = new Fact($factrec, $associate, 'asso'); } } } return $facts; }
[ "private", "function", "associateFacts", "(", "Individual", "$", "person", ")", ":", "array", "{", "$", "facts", "=", "[", "]", ";", "/** @var Individual[] $associates */", "$", "associates", "=", "array_merge", "(", "$", "person", "->", "linkedIndividuals", "(", "'ASSO'", ")", ",", "$", "person", "->", "linkedIndividuals", "(", "'_ASSO'", ")", ",", "$", "person", "->", "linkedFamilies", "(", "'ASSO'", ")", ",", "$", "person", "->", "linkedFamilies", "(", "'_ASSO'", ")", ")", ";", "foreach", "(", "$", "associates", "as", "$", "associate", ")", "{", "foreach", "(", "$", "associate", "->", "facts", "(", ")", "as", "$", "fact", ")", "{", "$", "arec", "=", "$", "fact", "->", "attribute", "(", "'_ASSO'", ")", ";", "if", "(", "!", "$", "arec", ")", "{", "$", "arec", "=", "$", "fact", "->", "attribute", "(", "'ASSO'", ")", ";", "}", "if", "(", "$", "arec", "&&", "trim", "(", "$", "arec", ",", "'@'", ")", "===", "$", "person", "->", "xref", "(", ")", ")", "{", "// Extract the important details from the fact", "$", "factrec", "=", "'1 '", ".", "$", "fact", "->", "getTag", "(", ")", ";", "if", "(", "preg_match", "(", "'/\\n2 DATE .*/'", ",", "$", "fact", "->", "gedcom", "(", ")", ",", "$", "match", ")", ")", "{", "$", "factrec", ".=", "$", "match", "[", "0", "]", ";", "}", "if", "(", "preg_match", "(", "'/\\n2 PLAC .*/'", ",", "$", "fact", "->", "gedcom", "(", ")", ",", "$", "match", ")", ")", "{", "$", "factrec", ".=", "$", "match", "[", "0", "]", ";", "}", "if", "(", "$", "associate", "instanceof", "Family", ")", "{", "foreach", "(", "$", "associate", "->", "spouses", "(", ")", "as", "$", "spouse", ")", "{", "$", "factrec", ".=", "\"\\n2 _ASSO @\"", ".", "$", "spouse", "->", "xref", "(", ")", ".", "'@'", ";", "}", "}", "else", "{", "$", "factrec", ".=", "\"\\n2 _ASSO @\"", ".", "$", "associate", "->", "xref", "(", ")", ".", "'@'", ";", "}", "$", "facts", "[", "]", "=", "new", "Fact", "(", "$", "factrec", ",", "$", "associate", ",", "'asso'", ")", ";", "}", "}", "}", "return", "$", "facts", ";", "}" ]
Get the events of associates. @param Individual $person @return Fact[]
[ "Get", "the", "events", "of", "associates", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/IndividualFactsTabModule.php#L470-L509
train
fisharebest/webtrees
app/Http/Controllers/SearchController.php
SearchController.quick
public function quick(ServerRequestInterface $request, Tree $tree): ResponseInterface { $query = $request->get('query', ''); // Was the search query an XREF in the current tree? // If so, go straight to it. $record = GedcomRecord::getInstance($query, $tree); if ($record !== null && $record->canShow()) { return redirect($record->url()); } return $this->general($request, $tree); }
php
public function quick(ServerRequestInterface $request, Tree $tree): ResponseInterface { $query = $request->get('query', ''); // Was the search query an XREF in the current tree? // If so, go straight to it. $record = GedcomRecord::getInstance($query, $tree); if ($record !== null && $record->canShow()) { return redirect($record->url()); } return $this->general($request, $tree); }
[ "public", "function", "quick", "(", "ServerRequestInterface", "$", "request", ",", "Tree", "$", "tree", ")", ":", "ResponseInterface", "{", "$", "query", "=", "$", "request", "->", "get", "(", "'query'", ",", "''", ")", ";", "// Was the search query an XREF in the current tree?", "// If so, go straight to it.", "$", "record", "=", "GedcomRecord", "::", "getInstance", "(", "$", "query", ",", "$", "tree", ")", ";", "if", "(", "$", "record", "!==", "null", "&&", "$", "record", "->", "canShow", "(", ")", ")", "{", "return", "redirect", "(", "$", "record", "->", "url", "(", ")", ")", ";", "}", "return", "$", "this", "->", "general", "(", "$", "request", ",", "$", "tree", ")", ";", "}" ]
The "omni-search" box in the header. @param ServerRequestInterface $request @param Tree $tree @return ResponseInterface
[ "The", "omni", "-", "search", "box", "in", "the", "header", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/SearchController.php#L144-L157
train
fisharebest/webtrees
app/Http/Controllers/SearchController.php
SearchController.extractSearchTerms
private function extractSearchTerms(string $query): array { $search_terms = []; // Words in double quotes stay together while (preg_match('/"([^"]+)"/', $query, $match)) { $search_terms[] = trim($match[1]); $query = str_replace($match[0], '', $query); } // Other words get treated separately while (preg_match('/[\S]+/', $query, $match)) { $search_terms[] = trim($match[0]); $query = str_replace($match[0], '', $query); } return $search_terms; }
php
private function extractSearchTerms(string $query): array { $search_terms = []; // Words in double quotes stay together while (preg_match('/"([^"]+)"/', $query, $match)) { $search_terms[] = trim($match[1]); $query = str_replace($match[0], '', $query); } // Other words get treated separately while (preg_match('/[\S]+/', $query, $match)) { $search_terms[] = trim($match[0]); $query = str_replace($match[0], '', $query); } return $search_terms; }
[ "private", "function", "extractSearchTerms", "(", "string", "$", "query", ")", ":", "array", "{", "$", "search_terms", "=", "[", "]", ";", "// Words in double quotes stay together", "while", "(", "preg_match", "(", "'/\"([^\"]+)\"/'", ",", "$", "query", ",", "$", "match", ")", ")", "{", "$", "search_terms", "[", "]", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "$", "query", "=", "str_replace", "(", "$", "match", "[", "0", "]", ",", "''", ",", "$", "query", ")", ";", "}", "// Other words get treated separately", "while", "(", "preg_match", "(", "'/[\\S]+/'", ",", "$", "query", ",", "$", "match", ")", ")", "{", "$", "search_terms", "[", "]", "=", "trim", "(", "$", "match", "[", "0", "]", ")", ";", "$", "query", "=", "str_replace", "(", "$", "match", "[", "0", "]", ",", "''", ",", "$", "query", ")", ";", "}", "return", "$", "search_terms", ";", "}" ]
Convert the query into an array of search terms @param string $query @return string[]
[ "Convert", "the", "query", "into", "an", "array", "of", "search", "terms" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/SearchController.php#L281-L298
train
fisharebest/webtrees
app/Http/Controllers/SearchController.php
SearchController.phonetic
public function phonetic(ServerRequestInterface $request, Tree $tree): ResponseInterface { $firstname = $request->get('firstname', ''); $lastname = $request->get('lastname', ''); $place = $request->get('place', ''); $soundex = $request->get('soundex', 'Russell'); // What trees to seach? if (Site::getPreference('ALLOW_CHANGE_GEDCOM') === '1') { $all_trees = Tree::getAll(); } else { $all_trees = [$tree]; } $search_tree_names = (array) $request->get('search_trees', []); $search_trees = array_filter($all_trees, static function (Tree $tree) use ($search_tree_names): bool { return in_array($tree->name(), $search_tree_names, true); }); if (empty($search_trees)) { $search_trees = [$tree]; } $individuals = $this->search_service->searchIndividualsPhonetic($soundex, $lastname, $firstname, $place, $search_trees); $title = I18N::translate('Phonetic search'); return $this->viewResponse('search-phonetic-page', [ 'all_trees' => $all_trees, 'firstname' => $firstname, 'individuals' => $individuals, 'lastname' => $lastname, 'place' => $place, 'search_trees' => $search_trees, 'soundex' => $soundex, 'title' => $title, ]); }
php
public function phonetic(ServerRequestInterface $request, Tree $tree): ResponseInterface { $firstname = $request->get('firstname', ''); $lastname = $request->get('lastname', ''); $place = $request->get('place', ''); $soundex = $request->get('soundex', 'Russell'); // What trees to seach? if (Site::getPreference('ALLOW_CHANGE_GEDCOM') === '1') { $all_trees = Tree::getAll(); } else { $all_trees = [$tree]; } $search_tree_names = (array) $request->get('search_trees', []); $search_trees = array_filter($all_trees, static function (Tree $tree) use ($search_tree_names): bool { return in_array($tree->name(), $search_tree_names, true); }); if (empty($search_trees)) { $search_trees = [$tree]; } $individuals = $this->search_service->searchIndividualsPhonetic($soundex, $lastname, $firstname, $place, $search_trees); $title = I18N::translate('Phonetic search'); return $this->viewResponse('search-phonetic-page', [ 'all_trees' => $all_trees, 'firstname' => $firstname, 'individuals' => $individuals, 'lastname' => $lastname, 'place' => $place, 'search_trees' => $search_trees, 'soundex' => $soundex, 'title' => $title, ]); }
[ "public", "function", "phonetic", "(", "ServerRequestInterface", "$", "request", ",", "Tree", "$", "tree", ")", ":", "ResponseInterface", "{", "$", "firstname", "=", "$", "request", "->", "get", "(", "'firstname'", ",", "''", ")", ";", "$", "lastname", "=", "$", "request", "->", "get", "(", "'lastname'", ",", "''", ")", ";", "$", "place", "=", "$", "request", "->", "get", "(", "'place'", ",", "''", ")", ";", "$", "soundex", "=", "$", "request", "->", "get", "(", "'soundex'", ",", "'Russell'", ")", ";", "// What trees to seach?", "if", "(", "Site", "::", "getPreference", "(", "'ALLOW_CHANGE_GEDCOM'", ")", "===", "'1'", ")", "{", "$", "all_trees", "=", "Tree", "::", "getAll", "(", ")", ";", "}", "else", "{", "$", "all_trees", "=", "[", "$", "tree", "]", ";", "}", "$", "search_tree_names", "=", "(", "array", ")", "$", "request", "->", "get", "(", "'search_trees'", ",", "[", "]", ")", ";", "$", "search_trees", "=", "array_filter", "(", "$", "all_trees", ",", "static", "function", "(", "Tree", "$", "tree", ")", "use", "(", "$", "search_tree_names", ")", ":", "bool", "{", "return", "in_array", "(", "$", "tree", "->", "name", "(", ")", ",", "$", "search_tree_names", ",", "true", ")", ";", "}", ")", ";", "if", "(", "empty", "(", "$", "search_trees", ")", ")", "{", "$", "search_trees", "=", "[", "$", "tree", "]", ";", "}", "$", "individuals", "=", "$", "this", "->", "search_service", "->", "searchIndividualsPhonetic", "(", "$", "soundex", ",", "$", "lastname", ",", "$", "firstname", ",", "$", "place", ",", "$", "search_trees", ")", ";", "$", "title", "=", "I18N", "::", "translate", "(", "'Phonetic search'", ")", ";", "return", "$", "this", "->", "viewResponse", "(", "'search-phonetic-page'", ",", "[", "'all_trees'", "=>", "$", "all_trees", ",", "'firstname'", "=>", "$", "firstname", ",", "'individuals'", "=>", "$", "individuals", ",", "'lastname'", "=>", "$", "lastname", ",", "'place'", "=>", "$", "place", ",", "'search_trees'", "=>", "$", "search_trees", ",", "'soundex'", "=>", "$", "soundex", ",", "'title'", "=>", "$", "title", ",", "]", ")", ";", "}" ]
The phonetic search. @param ServerRequestInterface $request @param Tree $tree @return ResponseInterface
[ "The", "phonetic", "search", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/SearchController.php#L308-L346
train
fisharebest/webtrees
app/Http/Controllers/SearchController.php
SearchController.advanced
public function advanced(ServerRequestInterface $request, Tree $tree): ResponseInterface { $default_fields = array_fill_keys(self::DEFAULT_ADVANCED_FIELDS, ''); $fields = $request->get('fields', $default_fields); $modifiers = $request->get('modifiers', []); $other_field = $request->get('other_field', ''); $other_value = $request->get('other_value', ''); if ($other_field !== '' && $other_value !== '') { $fields[$other_field] = $other_value; } $other_fields = $this->otherFields($fields); $date_options = $this->dateOptions(); $name_options = $this->nameOptions(); if (!empty(array_filter($fields))) { $individuals = $this->search_service->searchIndividualsAdvanced([$tree], $fields, $modifiers); } else { $individuals = []; } $title = I18N::translate('Advanced search'); return $this->viewResponse('search-advanced-page', [ 'date_options' => $date_options, 'fields' => $fields, 'individuals' => $individuals, 'modifiers' => $modifiers, 'name_options' => $name_options, 'other_fields' => $other_fields, 'title' => $title, ]); }
php
public function advanced(ServerRequestInterface $request, Tree $tree): ResponseInterface { $default_fields = array_fill_keys(self::DEFAULT_ADVANCED_FIELDS, ''); $fields = $request->get('fields', $default_fields); $modifiers = $request->get('modifiers', []); $other_field = $request->get('other_field', ''); $other_value = $request->get('other_value', ''); if ($other_field !== '' && $other_value !== '') { $fields[$other_field] = $other_value; } $other_fields = $this->otherFields($fields); $date_options = $this->dateOptions(); $name_options = $this->nameOptions(); if (!empty(array_filter($fields))) { $individuals = $this->search_service->searchIndividualsAdvanced([$tree], $fields, $modifiers); } else { $individuals = []; } $title = I18N::translate('Advanced search'); return $this->viewResponse('search-advanced-page', [ 'date_options' => $date_options, 'fields' => $fields, 'individuals' => $individuals, 'modifiers' => $modifiers, 'name_options' => $name_options, 'other_fields' => $other_fields, 'title' => $title, ]); }
[ "public", "function", "advanced", "(", "ServerRequestInterface", "$", "request", ",", "Tree", "$", "tree", ")", ":", "ResponseInterface", "{", "$", "default_fields", "=", "array_fill_keys", "(", "self", "::", "DEFAULT_ADVANCED_FIELDS", ",", "''", ")", ";", "$", "fields", "=", "$", "request", "->", "get", "(", "'fields'", ",", "$", "default_fields", ")", ";", "$", "modifiers", "=", "$", "request", "->", "get", "(", "'modifiers'", ",", "[", "]", ")", ";", "$", "other_field", "=", "$", "request", "->", "get", "(", "'other_field'", ",", "''", ")", ";", "$", "other_value", "=", "$", "request", "->", "get", "(", "'other_value'", ",", "''", ")", ";", "if", "(", "$", "other_field", "!==", "''", "&&", "$", "other_value", "!==", "''", ")", "{", "$", "fields", "[", "$", "other_field", "]", "=", "$", "other_value", ";", "}", "$", "other_fields", "=", "$", "this", "->", "otherFields", "(", "$", "fields", ")", ";", "$", "date_options", "=", "$", "this", "->", "dateOptions", "(", ")", ";", "$", "name_options", "=", "$", "this", "->", "nameOptions", "(", ")", ";", "if", "(", "!", "empty", "(", "array_filter", "(", "$", "fields", ")", ")", ")", "{", "$", "individuals", "=", "$", "this", "->", "search_service", "->", "searchIndividualsAdvanced", "(", "[", "$", "tree", "]", ",", "$", "fields", ",", "$", "modifiers", ")", ";", "}", "else", "{", "$", "individuals", "=", "[", "]", ";", "}", "$", "title", "=", "I18N", "::", "translate", "(", "'Advanced search'", ")", ";", "return", "$", "this", "->", "viewResponse", "(", "'search-advanced-page'", ",", "[", "'date_options'", "=>", "$", "date_options", ",", "'fields'", "=>", "$", "fields", ",", "'individuals'", "=>", "$", "individuals", ",", "'modifiers'", "=>", "$", "modifiers", ",", "'name_options'", "=>", "$", "name_options", ",", "'other_fields'", "=>", "$", "other_fields", ",", "'title'", "=>", "$", "title", ",", "]", ")", ";", "}" ]
A structured search. @param ServerRequestInterface $request @param Tree $tree @return ResponseInterface
[ "A", "structured", "search", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/SearchController.php#L537-L571
train
fisharebest/webtrees
app/Http/Controllers/SearchController.php
SearchController.otherFields
private function otherFields(array $fields): array { $unused = array_diff(self::OTHER_ADVANCED_FIELDS, array_keys($fields)); $other_fileds = []; foreach ($unused as $tag) { $other_fileds[$tag] = GedcomTag::getLabel($tag); } return $other_fileds; }
php
private function otherFields(array $fields): array { $unused = array_diff(self::OTHER_ADVANCED_FIELDS, array_keys($fields)); $other_fileds = []; foreach ($unused as $tag) { $other_fileds[$tag] = GedcomTag::getLabel($tag); } return $other_fileds; }
[ "private", "function", "otherFields", "(", "array", "$", "fields", ")", ":", "array", "{", "$", "unused", "=", "array_diff", "(", "self", "::", "OTHER_ADVANCED_FIELDS", ",", "array_keys", "(", "$", "fields", ")", ")", ";", "$", "other_fileds", "=", "[", "]", ";", "foreach", "(", "$", "unused", "as", "$", "tag", ")", "{", "$", "other_fileds", "[", "$", "tag", "]", "=", "GedcomTag", "::", "getLabel", "(", "$", "tag", ")", ";", "}", "return", "$", "other_fileds", ";", "}" ]
Extra search fields to add to the advanced search @param string[] $fields @return string[]
[ "Extra", "search", "fields", "to", "add", "to", "the", "advanced", "search" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/SearchController.php#L580-L591
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getIso3166Countries
private function getIso3166Countries(): array { $countries = $this->country_service->getAllCountries(); // Get the country names for each language $country_to_iso3166 = []; foreach (I18N::activeLocales() as $locale) { I18N::init($locale->languageTag()); foreach ($this->country_service->iso3166() as $three => $two) { $country_to_iso3166[$three] = $two; $country_to_iso3166[$countries[$three]] = $two; } } return $country_to_iso3166; }
php
private function getIso3166Countries(): array { $countries = $this->country_service->getAllCountries(); // Get the country names for each language $country_to_iso3166 = []; foreach (I18N::activeLocales() as $locale) { I18N::init($locale->languageTag()); foreach ($this->country_service->iso3166() as $three => $two) { $country_to_iso3166[$three] = $two; $country_to_iso3166[$countries[$three]] = $two; } } return $country_to_iso3166; }
[ "private", "function", "getIso3166Countries", "(", ")", ":", "array", "{", "$", "countries", "=", "$", "this", "->", "country_service", "->", "getAllCountries", "(", ")", ";", "// Get the country names for each language", "$", "country_to_iso3166", "=", "[", "]", ";", "foreach", "(", "I18N", "::", "activeLocales", "(", ")", "as", "$", "locale", ")", "{", "I18N", "::", "init", "(", "$", "locale", "->", "languageTag", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "country_service", "->", "iso3166", "(", ")", "as", "$", "three", "=>", "$", "two", ")", "{", "$", "country_to_iso3166", "[", "$", "three", "]", "=", "$", "two", ";", "$", "country_to_iso3166", "[", "$", "countries", "[", "$", "three", "]", "]", "=", "$", "two", ";", "}", "}", "return", "$", "country_to_iso3166", ";", "}" ]
Returns the country names for each language. @return string[]
[ "Returns", "the", "country", "names", "for", "each", "language", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L88-L105
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.createChartData
private function createChartData(array $places): array { $data = [ [ I18N::translate('Country'), I18N::translate('Total'), ], ]; // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($places as $country => $count) { $data[] = [ [ 'v' => $country, 'f' => $this->country_service->mapTwoLetterToName($country), ], $count ]; } return $data; }
php
private function createChartData(array $places): array { $data = [ [ I18N::translate('Country'), I18N::translate('Total'), ], ]; // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($places as $country => $count) { $data[] = [ [ 'v' => $country, 'f' => $this->country_service->mapTwoLetterToName($country), ], $count ]; } return $data; }
[ "private", "function", "createChartData", "(", "array", "$", "places", ")", ":", "array", "{", "$", "data", "=", "[", "[", "I18N", "::", "translate", "(", "'Country'", ")", ",", "I18N", "::", "translate", "(", "'Total'", ")", ",", "]", ",", "]", ";", "// webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes.", "foreach", "(", "$", "places", "as", "$", "country", "=>", "$", "count", ")", "{", "$", "data", "[", "]", "=", "[", "[", "'v'", "=>", "$", "country", ",", "'f'", "=>", "$", "this", "->", "country_service", "->", "mapTwoLetterToName", "(", "$", "country", ")", ",", "]", ",", "$", "count", "]", ";", "}", "return", "$", "data", ";", "}" ]
Returns the data structure required by google geochart. @param array $places @return array
[ "Returns", "the", "data", "structure", "required", "by", "google", "geochart", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L114-L135
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getBirthChartData
private function getBirthChartData(): array { // Count how many people were born in each country $surn_countries = []; $b_countries = $this->placeRepository->statsPlaces('INDI', 'BIRT', 0, true); foreach ($b_countries as $country => $count) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $count; } else { $surn_countries[$country_code] = $count; } } } return $this->createChartData($surn_countries); }
php
private function getBirthChartData(): array { // Count how many people were born in each country $surn_countries = []; $b_countries = $this->placeRepository->statsPlaces('INDI', 'BIRT', 0, true); foreach ($b_countries as $country => $count) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $count; } else { $surn_countries[$country_code] = $count; } } } return $this->createChartData($surn_countries); }
[ "private", "function", "getBirthChartData", "(", ")", ":", "array", "{", "// Count how many people were born in each country", "$", "surn_countries", "=", "[", "]", ";", "$", "b_countries", "=", "$", "this", "->", "placeRepository", "->", "statsPlaces", "(", "'INDI'", ",", "'BIRT'", ",", "0", ",", "true", ")", ";", "foreach", "(", "$", "b_countries", "as", "$", "country", "=>", "$", "count", ")", "{", "// Consolidate places (Germany, DEU => DE)", "if", "(", "array_key_exists", "(", "$", "country", ",", "$", "this", "->", "country_to_iso3166", ")", ")", "{", "$", "country_code", "=", "$", "this", "->", "country_to_iso3166", "[", "$", "country", "]", ";", "if", "(", "array_key_exists", "(", "$", "country_code", ",", "$", "surn_countries", ")", ")", "{", "$", "surn_countries", "[", "$", "country_code", "]", "+=", "$", "count", ";", "}", "else", "{", "$", "surn_countries", "[", "$", "country_code", "]", "=", "$", "count", ";", "}", "}", "}", "return", "$", "this", "->", "createChartData", "(", "$", "surn_countries", ")", ";", "}" ]
Returns the google geochart data for birth fact. @return array
[ "Returns", "the", "google", "geochart", "data", "for", "birth", "fact", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L142-L162
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getDeathChartData
private function getDeathChartData(): array { // Count how many people were death in each country $surn_countries = []; $d_countries = $this->placeRepository->statsPlaces('INDI', 'DEAT', 0, true); foreach ($d_countries as $country => $count) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $count; } else { $surn_countries[$country_code] = $count; } } } return $this->createChartData($surn_countries); }
php
private function getDeathChartData(): array { // Count how many people were death in each country $surn_countries = []; $d_countries = $this->placeRepository->statsPlaces('INDI', 'DEAT', 0, true); foreach ($d_countries as $country => $count) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $count; } else { $surn_countries[$country_code] = $count; } } } return $this->createChartData($surn_countries); }
[ "private", "function", "getDeathChartData", "(", ")", ":", "array", "{", "// Count how many people were death in each country", "$", "surn_countries", "=", "[", "]", ";", "$", "d_countries", "=", "$", "this", "->", "placeRepository", "->", "statsPlaces", "(", "'INDI'", ",", "'DEAT'", ",", "0", ",", "true", ")", ";", "foreach", "(", "$", "d_countries", "as", "$", "country", "=>", "$", "count", ")", "{", "// Consolidate places (Germany, DEU => DE)", "if", "(", "array_key_exists", "(", "$", "country", ",", "$", "this", "->", "country_to_iso3166", ")", ")", "{", "$", "country_code", "=", "$", "this", "->", "country_to_iso3166", "[", "$", "country", "]", ";", "if", "(", "array_key_exists", "(", "$", "country_code", ",", "$", "surn_countries", ")", ")", "{", "$", "surn_countries", "[", "$", "country_code", "]", "+=", "$", "count", ";", "}", "else", "{", "$", "surn_countries", "[", "$", "country_code", "]", "=", "$", "count", ";", "}", "}", "}", "return", "$", "this", "->", "createChartData", "(", "$", "surn_countries", ")", ";", "}" ]
Returns the google geochart data for death fact. @return array
[ "Returns", "the", "google", "geochart", "data", "for", "death", "fact", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L169-L189
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getMarriageChartData
private function getMarriageChartData(): array { // Count how many families got marriage in each country $surn_countries = []; $m_countries = $this->placeRepository->statsPlaces('FAM'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($m_countries as $place) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($place->country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$place->country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $place->tot; } else { $surn_countries[$country_code] = $place->tot; } } } return $this->createChartData($surn_countries); }
php
private function getMarriageChartData(): array { // Count how many families got marriage in each country $surn_countries = []; $m_countries = $this->placeRepository->statsPlaces('FAM'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($m_countries as $place) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($place->country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$place->country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $place->tot; } else { $surn_countries[$country_code] = $place->tot; } } } return $this->createChartData($surn_countries); }
[ "private", "function", "getMarriageChartData", "(", ")", ":", "array", "{", "// Count how many families got marriage in each country", "$", "surn_countries", "=", "[", "]", ";", "$", "m_countries", "=", "$", "this", "->", "placeRepository", "->", "statsPlaces", "(", "'FAM'", ")", ";", "// webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes.", "foreach", "(", "$", "m_countries", "as", "$", "place", ")", "{", "// Consolidate places (Germany, DEU => DE)", "if", "(", "array_key_exists", "(", "$", "place", "->", "country", ",", "$", "this", "->", "country_to_iso3166", ")", ")", "{", "$", "country_code", "=", "$", "this", "->", "country_to_iso3166", "[", "$", "place", "->", "country", "]", ";", "if", "(", "array_key_exists", "(", "$", "country_code", ",", "$", "surn_countries", ")", ")", "{", "$", "surn_countries", "[", "$", "country_code", "]", "+=", "$", "place", "->", "tot", ";", "}", "else", "{", "$", "surn_countries", "[", "$", "country_code", "]", "=", "$", "place", "->", "tot", ";", "}", "}", "}", "return", "$", "this", "->", "createChartData", "(", "$", "surn_countries", ")", ";", "}" ]
Returns the google geochart data for marriages. @return array
[ "Returns", "the", "google", "geochart", "data", "for", "marriages", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L196-L217
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getSurnameChartData
private function getSurnameChartData(string $surname): array { if ($surname === '') { $surname = $this->individualRepository->getCommonSurname(); } // Count how many people are events in each country $surn_countries = []; $records = $this->queryRecords($surname); foreach ($records as $row) { /** @var string[][] $matches */ if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $row->i_gedcom, $matches)) { // webtrees uses 3 letter country codes and localised country names, // but google uses 2 letter codes. foreach ($matches[1] as $country) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code]++; } else { $surn_countries[$country_code] = 1; } } } } } return $this->createChartData($surn_countries); }
php
private function getSurnameChartData(string $surname): array { if ($surname === '') { $surname = $this->individualRepository->getCommonSurname(); } // Count how many people are events in each country $surn_countries = []; $records = $this->queryRecords($surname); foreach ($records as $row) { /** @var string[][] $matches */ if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $row->i_gedcom, $matches)) { // webtrees uses 3 letter country codes and localised country names, // but google uses 2 letter codes. foreach ($matches[1] as $country) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code]++; } else { $surn_countries[$country_code] = 1; } } } } } return $this->createChartData($surn_countries); }
[ "private", "function", "getSurnameChartData", "(", "string", "$", "surname", ")", ":", "array", "{", "if", "(", "$", "surname", "===", "''", ")", "{", "$", "surname", "=", "$", "this", "->", "individualRepository", "->", "getCommonSurname", "(", ")", ";", "}", "// Count how many people are events in each country", "$", "surn_countries", "=", "[", "]", ";", "$", "records", "=", "$", "this", "->", "queryRecords", "(", "$", "surname", ")", ";", "foreach", "(", "$", "records", "as", "$", "row", ")", "{", "/** @var string[][] $matches */", "if", "(", "preg_match_all", "(", "'/^2 PLAC (?:.*, *)*(.*)/m'", ",", "$", "row", "->", "i_gedcom", ",", "$", "matches", ")", ")", "{", "// webtrees uses 3 letter country codes and localised country names,", "// but google uses 2 letter codes.", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "country", ")", "{", "// Consolidate places (Germany, DEU => DE)", "if", "(", "array_key_exists", "(", "$", "country", ",", "$", "this", "->", "country_to_iso3166", ")", ")", "{", "$", "country_code", "=", "$", "this", "->", "country_to_iso3166", "[", "$", "country", "]", ";", "if", "(", "array_key_exists", "(", "$", "country_code", ",", "$", "surn_countries", ")", ")", "{", "$", "surn_countries", "[", "$", "country_code", "]", "++", ";", "}", "else", "{", "$", "surn_countries", "[", "$", "country_code", "]", "=", "1", ";", "}", "}", "}", "}", "}", "return", "$", "this", "->", "createChartData", "(", "$", "surn_countries", ")", ";", "}" ]
Returns the google geochart data for surnames. @param string $surname The surname used to create the chart @return array
[ "Returns", "the", "google", "geochart", "data", "for", "surnames", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L247-L278
train
fisharebest/webtrees
app/Statistics/Google/ChartDistribution.php
ChartDistribution.getIndivdualChartData
private function getIndivdualChartData(): array { // Count how many people have events in each country $surn_countries = []; $a_countries = $this->placeRepository->statsPlaces('INDI'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($a_countries as $place) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($place->country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$place->country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $place->tot; } else { $surn_countries[$country_code] = $place->tot; } } } return $this->createChartData($surn_countries); }
php
private function getIndivdualChartData(): array { // Count how many people have events in each country $surn_countries = []; $a_countries = $this->placeRepository->statsPlaces('INDI'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($a_countries as $place) { // Consolidate places (Germany, DEU => DE) if (array_key_exists($place->country, $this->country_to_iso3166)) { $country_code = $this->country_to_iso3166[$place->country]; if (array_key_exists($country_code, $surn_countries)) { $surn_countries[$country_code] += $place->tot; } else { $surn_countries[$country_code] = $place->tot; } } } return $this->createChartData($surn_countries); }
[ "private", "function", "getIndivdualChartData", "(", ")", ":", "array", "{", "// Count how many people have events in each country", "$", "surn_countries", "=", "[", "]", ";", "$", "a_countries", "=", "$", "this", "->", "placeRepository", "->", "statsPlaces", "(", "'INDI'", ")", ";", "// webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes.", "foreach", "(", "$", "a_countries", "as", "$", "place", ")", "{", "// Consolidate places (Germany, DEU => DE)", "if", "(", "array_key_exists", "(", "$", "place", "->", "country", ",", "$", "this", "->", "country_to_iso3166", ")", ")", "{", "$", "country_code", "=", "$", "this", "->", "country_to_iso3166", "[", "$", "place", "->", "country", "]", ";", "if", "(", "array_key_exists", "(", "$", "country_code", ",", "$", "surn_countries", ")", ")", "{", "$", "surn_countries", "[", "$", "country_code", "]", "+=", "$", "place", "->", "tot", ";", "}", "else", "{", "$", "surn_countries", "[", "$", "country_code", "]", "=", "$", "place", "->", "tot", ";", "}", "}", "}", "return", "$", "this", "->", "createChartData", "(", "$", "surn_countries", ")", ";", "}" ]
Returns the google geochart data for individuals. @return array
[ "Returns", "the", "google", "geochart", "data", "for", "individuals", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartDistribution.php#L285-L306
train
fisharebest/webtrees
app/Module/DescendancyModule.php
DescendancyModule.getPersonLi
public function getPersonLi(Individual $person, $generations = 0): string { $icon = $generations > 0 ? 'icon-minus' : 'icon-plus'; $lifespan = $person->canShow() ? '(' . $person->getLifeSpan() . ')' : ''; $spouses = $generations > 0 ? $this->loadSpouses($person, 0) : ''; return '<li class="sb_desc_indi_li">' . '<a class="sb_desc_indi" href="' . e(route('module', [ 'module' => $this->name(), 'action' => 'Descendants', 'ged' => $person->tree()->name(), 'xref' => $person->xref(), ])) . '">' . '<i class="plusminus ' . $icon . '"></i>' . $person->getSexImage() . $person->fullName() . $lifespan . '</a>' . '<a href="' . e($person->url()) . '" title="' . strip_tags($person->fullName()) . '">' . view('icons/individual') . '</a>' . '<div>' . $spouses . '</div>' . '</li>'; }
php
public function getPersonLi(Individual $person, $generations = 0): string { $icon = $generations > 0 ? 'icon-minus' : 'icon-plus'; $lifespan = $person->canShow() ? '(' . $person->getLifeSpan() . ')' : ''; $spouses = $generations > 0 ? $this->loadSpouses($person, 0) : ''; return '<li class="sb_desc_indi_li">' . '<a class="sb_desc_indi" href="' . e(route('module', [ 'module' => $this->name(), 'action' => 'Descendants', 'ged' => $person->tree()->name(), 'xref' => $person->xref(), ])) . '">' . '<i class="plusminus ' . $icon . '"></i>' . $person->getSexImage() . $person->fullName() . $lifespan . '</a>' . '<a href="' . e($person->url()) . '" title="' . strip_tags($person->fullName()) . '">' . view('icons/individual') . '</a>' . '<div>' . $spouses . '</div>' . '</li>'; }
[ "public", "function", "getPersonLi", "(", "Individual", "$", "person", ",", "$", "generations", "=", "0", ")", ":", "string", "{", "$", "icon", "=", "$", "generations", ">", "0", "?", "'icon-minus'", ":", "'icon-plus'", ";", "$", "lifespan", "=", "$", "person", "->", "canShow", "(", ")", "?", "'('", ".", "$", "person", "->", "getLifeSpan", "(", ")", ".", "')'", ":", "''", ";", "$", "spouses", "=", "$", "generations", ">", "0", "?", "$", "this", "->", "loadSpouses", "(", "$", "person", ",", "0", ")", ":", "''", ";", "return", "'<li class=\"sb_desc_indi_li\">'", ".", "'<a class=\"sb_desc_indi\" href=\"'", ".", "e", "(", "route", "(", "'module'", ",", "[", "'module'", "=>", "$", "this", "->", "name", "(", ")", ",", "'action'", "=>", "'Descendants'", ",", "'ged'", "=>", "$", "person", "->", "tree", "(", ")", "->", "name", "(", ")", ",", "'xref'", "=>", "$", "person", "->", "xref", "(", ")", ",", "]", ")", ")", ".", "'\">'", ".", "'<i class=\"plusminus '", ".", "$", "icon", ".", "'\"></i>'", ".", "$", "person", "->", "getSexImage", "(", ")", ".", "$", "person", "->", "fullName", "(", ")", ".", "$", "lifespan", ".", "'</a>'", ".", "'<a href=\"'", ".", "e", "(", "$", "person", "->", "url", "(", ")", ")", ".", "'\" title=\"'", ".", "strip_tags", "(", "$", "person", "->", "fullName", "(", ")", ")", ".", "'\">'", ".", "view", "(", "'icons/individual'", ")", ".", "'</a>'", ".", "'<div>'", ".", "$", "spouses", ".", "'</div>'", ".", "'</li>'", ";", "}" ]
Format an individual in a list. @param Individual $person @param int $generations @return string
[ "Format", "an", "individual", "in", "a", "list", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/DescendancyModule.php#L145-L165
train
fisharebest/webtrees
app/Module/DescendancyModule.php
DescendancyModule.getFamilyLi
public function getFamilyLi(Family $family, Individual $person, $generations = 0): string { $spouse = $family->spouse($person); if ($spouse) { $spouse_name = $spouse->getSexImage() . $spouse->fullName(); $spouse_link = '<a href="' . e($person->url()) . '" title="' . strip_tags($person->fullName()) . '">' . view('icons/individual') . '</a>'; } else { $spouse_name = ''; $spouse_link = ''; } $family_link = '<a href="' . e($family->url()) . '" title="' . strip_tags($family->fullName()) . '">' . view('icons/family') . '</a>'; $marryear = $family->getMarriageYear(); $marr = $marryear ? '<i class="icon-rings"></i>' . $marryear : ''; return '<li class="sb_desc_indi_li">' . '<a class="sb_desc_indi" href="#"><i class="plusminus icon-minus"></i>' . $spouse_name . $marr . '</a>' . $spouse_link . $family_link . '<div>' . $this->loadChildren($family, $generations) . '</div>' . '</li>'; }
php
public function getFamilyLi(Family $family, Individual $person, $generations = 0): string { $spouse = $family->spouse($person); if ($spouse) { $spouse_name = $spouse->getSexImage() . $spouse->fullName(); $spouse_link = '<a href="' . e($person->url()) . '" title="' . strip_tags($person->fullName()) . '">' . view('icons/individual') . '</a>'; } else { $spouse_name = ''; $spouse_link = ''; } $family_link = '<a href="' . e($family->url()) . '" title="' . strip_tags($family->fullName()) . '">' . view('icons/family') . '</a>'; $marryear = $family->getMarriageYear(); $marr = $marryear ? '<i class="icon-rings"></i>' . $marryear : ''; return '<li class="sb_desc_indi_li">' . '<a class="sb_desc_indi" href="#"><i class="plusminus icon-minus"></i>' . $spouse_name . $marr . '</a>' . $spouse_link . $family_link . '<div>' . $this->loadChildren($family, $generations) . '</div>' . '</li>'; }
[ "public", "function", "getFamilyLi", "(", "Family", "$", "family", ",", "Individual", "$", "person", ",", "$", "generations", "=", "0", ")", ":", "string", "{", "$", "spouse", "=", "$", "family", "->", "spouse", "(", "$", "person", ")", ";", "if", "(", "$", "spouse", ")", "{", "$", "spouse_name", "=", "$", "spouse", "->", "getSexImage", "(", ")", ".", "$", "spouse", "->", "fullName", "(", ")", ";", "$", "spouse_link", "=", "'<a href=\"'", ".", "e", "(", "$", "person", "->", "url", "(", ")", ")", ".", "'\" title=\"'", ".", "strip_tags", "(", "$", "person", "->", "fullName", "(", ")", ")", ".", "'\">'", ".", "view", "(", "'icons/individual'", ")", ".", "'</a>'", ";", "}", "else", "{", "$", "spouse_name", "=", "''", ";", "$", "spouse_link", "=", "''", ";", "}", "$", "family_link", "=", "'<a href=\"'", ".", "e", "(", "$", "family", "->", "url", "(", ")", ")", ".", "'\" title=\"'", ".", "strip_tags", "(", "$", "family", "->", "fullName", "(", ")", ")", ".", "'\">'", ".", "view", "(", "'icons/family'", ")", ".", "'</a>'", ";", "$", "marryear", "=", "$", "family", "->", "getMarriageYear", "(", ")", ";", "$", "marr", "=", "$", "marryear", "?", "'<i class=\"icon-rings\"></i>'", ".", "$", "marryear", ":", "''", ";", "return", "'<li class=\"sb_desc_indi_li\">'", ".", "'<a class=\"sb_desc_indi\" href=\"#\"><i class=\"plusminus icon-minus\"></i>'", ".", "$", "spouse_name", ".", "$", "marr", ".", "'</a>'", ".", "$", "spouse_link", ".", "$", "family_link", ".", "'<div>'", ".", "$", "this", "->", "loadChildren", "(", "$", "family", ",", "$", "generations", ")", ".", "'</div>'", ".", "'</li>'", ";", "}" ]
Format a family in a list. @param Family $family @param Individual $person @param int $generations @return string
[ "Format", "a", "family", "in", "a", "list", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/DescendancyModule.php#L176-L202
train
fisharebest/webtrees
app/Module/DescendancyModule.php
DescendancyModule.loadSpouses
public function loadSpouses(Individual $individual, $generations): string { $out = ''; if ($individual->canShow()) { foreach ($individual->spouseFamilies() as $family) { $out .= $this->getFamilyLi($family, $individual, $generations - 1); } } if ($out) { return '<ul>' . $out . '</ul>'; } return ''; }
php
public function loadSpouses(Individual $individual, $generations): string { $out = ''; if ($individual->canShow()) { foreach ($individual->spouseFamilies() as $family) { $out .= $this->getFamilyLi($family, $individual, $generations - 1); } } if ($out) { return '<ul>' . $out . '</ul>'; } return ''; }
[ "public", "function", "loadSpouses", "(", "Individual", "$", "individual", ",", "$", "generations", ")", ":", "string", "{", "$", "out", "=", "''", ";", "if", "(", "$", "individual", "->", "canShow", "(", ")", ")", "{", "foreach", "(", "$", "individual", "->", "spouseFamilies", "(", ")", "as", "$", "family", ")", "{", "$", "out", ".=", "$", "this", "->", "getFamilyLi", "(", "$", "family", ",", "$", "individual", ",", "$", "generations", "-", "1", ")", ";", "}", "}", "if", "(", "$", "out", ")", "{", "return", "'<ul>'", ".", "$", "out", ".", "'</ul>'", ";", "}", "return", "''", ";", "}" ]
Display spouses. @param Individual $individual @param int $generations @return string
[ "Display", "spouses", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/DescendancyModule.php#L212-L225
train
fisharebest/webtrees
app/Module/DescendancyModule.php
DescendancyModule.loadChildren
public function loadChildren(Family $family, $generations): string { $out = ''; if ($family->canShow()) { $children = $family->children(); if ($children->isNotEmpty()) { foreach ($children as $child) { $out .= $this->getPersonLi($child, $generations - 1); } } else { $out .= '<li class="sb_desc_none">' . I18N::translate('No children') . '</li>'; } } if ($out) { return '<ul>' . $out . '</ul>'; } return ''; }
php
public function loadChildren(Family $family, $generations): string { $out = ''; if ($family->canShow()) { $children = $family->children(); if ($children->isNotEmpty()) { foreach ($children as $child) { $out .= $this->getPersonLi($child, $generations - 1); } } else { $out .= '<li class="sb_desc_none">' . I18N::translate('No children') . '</li>'; } } if ($out) { return '<ul>' . $out . '</ul>'; } return ''; }
[ "public", "function", "loadChildren", "(", "Family", "$", "family", ",", "$", "generations", ")", ":", "string", "{", "$", "out", "=", "''", ";", "if", "(", "$", "family", "->", "canShow", "(", ")", ")", "{", "$", "children", "=", "$", "family", "->", "children", "(", ")", ";", "if", "(", "$", "children", "->", "isNotEmpty", "(", ")", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "out", ".=", "$", "this", "->", "getPersonLi", "(", "$", "child", ",", "$", "generations", "-", "1", ")", ";", "}", "}", "else", "{", "$", "out", ".=", "'<li class=\"sb_desc_none\">'", ".", "I18N", "::", "translate", "(", "'No children'", ")", ".", "'</li>'", ";", "}", "}", "if", "(", "$", "out", ")", "{", "return", "'<ul>'", ".", "$", "out", ".", "'</ul>'", ";", "}", "return", "''", ";", "}" ]
Display descendants. @param Family $family @param int $generations @return string
[ "Display", "descendants", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/DescendancyModule.php#L235-L254
train
fisharebest/webtrees
app/Http/Controllers/PendingChangesController.php
PendingChangesController.acceptAllChanges
public function acceptAllChanges(ServerRequestInterface $request, Tree $tree): ResponseInterface { $url = $request->get('url', ''); $changes = DB::table('change') ->where('gedcom_id', '=', $tree->id()) ->where('status', '=', 'pending') ->orderBy('change_id') ->get(); foreach ($changes as $change) { if (empty($change->new_gedcom)) { // delete FunctionsImport::updateRecord($change->old_gedcom, $tree, true); } else { // add/update FunctionsImport::updateRecord($change->new_gedcom, $tree, false); } DB::table('change') ->where('change_id', '=', $change->change_id) ->update(['status' => 'accepted']); Log::addEditLog('Accepted change ' . $change->change_id . ' for ' . $change->xref . ' / ' . $tree->name(), $tree); } return redirect(route('show-pending', [ 'ged' => $tree->name(), 'url' => $url, ])); }
php
public function acceptAllChanges(ServerRequestInterface $request, Tree $tree): ResponseInterface { $url = $request->get('url', ''); $changes = DB::table('change') ->where('gedcom_id', '=', $tree->id()) ->where('status', '=', 'pending') ->orderBy('change_id') ->get(); foreach ($changes as $change) { if (empty($change->new_gedcom)) { // delete FunctionsImport::updateRecord($change->old_gedcom, $tree, true); } else { // add/update FunctionsImport::updateRecord($change->new_gedcom, $tree, false); } DB::table('change') ->where('change_id', '=', $change->change_id) ->update(['status' => 'accepted']); Log::addEditLog('Accepted change ' . $change->change_id . ' for ' . $change->xref . ' / ' . $tree->name(), $tree); } return redirect(route('show-pending', [ 'ged' => $tree->name(), 'url' => $url, ])); }
[ "public", "function", "acceptAllChanges", "(", "ServerRequestInterface", "$", "request", ",", "Tree", "$", "tree", ")", ":", "ResponseInterface", "{", "$", "url", "=", "$", "request", "->", "get", "(", "'url'", ",", "''", ")", ";", "$", "changes", "=", "DB", "::", "table", "(", "'change'", ")", "->", "where", "(", "'gedcom_id'", ",", "'='", ",", "$", "tree", "->", "id", "(", ")", ")", "->", "where", "(", "'status'", ",", "'='", ",", "'pending'", ")", "->", "orderBy", "(", "'change_id'", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "changes", "as", "$", "change", ")", "{", "if", "(", "empty", "(", "$", "change", "->", "new_gedcom", ")", ")", "{", "// delete", "FunctionsImport", "::", "updateRecord", "(", "$", "change", "->", "old_gedcom", ",", "$", "tree", ",", "true", ")", ";", "}", "else", "{", "// add/update", "FunctionsImport", "::", "updateRecord", "(", "$", "change", "->", "new_gedcom", ",", "$", "tree", ",", "false", ")", ";", "}", "DB", "::", "table", "(", "'change'", ")", "->", "where", "(", "'change_id'", ",", "'='", ",", "$", "change", "->", "change_id", ")", "->", "update", "(", "[", "'status'", "=>", "'accepted'", "]", ")", ";", "Log", "::", "addEditLog", "(", "'Accepted change '", ".", "$", "change", "->", "change_id", ".", "' for '", ".", "$", "change", "->", "xref", ".", "' / '", ".", "$", "tree", "->", "name", "(", ")", ",", "$", "tree", ")", ";", "}", "return", "redirect", "(", "route", "(", "'show-pending'", ",", "[", "'ged'", "=>", "$", "tree", "->", "name", "(", ")", ",", "'url'", "=>", "$", "url", ",", "]", ")", ")", ";", "}" ]
Accept all changes to a tree. @param ServerRequestInterface $request @param Tree $tree @return ResponseInterface
[ "Accept", "all", "changes", "to", "a", "tree", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/PendingChangesController.php#L52-L82
train
fisharebest/webtrees
app/Http/Controllers/PendingChangesController.php
PendingChangesController.rejectAllChanges
public function rejectAllChanges(ServerRequestInterface $request, Tree $tree): ResponseInterface { $url = $request->get('url', ''); DB::table('change') ->where('gedcom_id', '=', $tree->id()) ->where('status', '=', 'pending') ->update(['status' => 'rejected']); return redirect(route('show-pending', [ 'ged' => $tree->name(), 'url' => $url, ])); }
php
public function rejectAllChanges(ServerRequestInterface $request, Tree $tree): ResponseInterface { $url = $request->get('url', ''); DB::table('change') ->where('gedcom_id', '=', $tree->id()) ->where('status', '=', 'pending') ->update(['status' => 'rejected']); return redirect(route('show-pending', [ 'ged' => $tree->name(), 'url' => $url, ])); }
[ "public", "function", "rejectAllChanges", "(", "ServerRequestInterface", "$", "request", ",", "Tree", "$", "tree", ")", ":", "ResponseInterface", "{", "$", "url", "=", "$", "request", "->", "get", "(", "'url'", ",", "''", ")", ";", "DB", "::", "table", "(", "'change'", ")", "->", "where", "(", "'gedcom_id'", ",", "'='", ",", "$", "tree", "->", "id", "(", ")", ")", "->", "where", "(", "'status'", ",", "'='", ",", "'pending'", ")", "->", "update", "(", "[", "'status'", "=>", "'rejected'", "]", ")", ";", "return", "redirect", "(", "route", "(", "'show-pending'", ",", "[", "'ged'", "=>", "$", "tree", "->", "name", "(", ")", ",", "'url'", "=>", "$", "url", ",", "]", ")", ")", ";", "}" ]
Reject all changes to a tree. @param ServerRequestInterface $request @param Tree $tree @return ResponseInterface
[ "Reject", "all", "changes", "to", "a", "tree", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/PendingChangesController.php#L166-L179
train
fisharebest/webtrees
app/Functions/FunctionsDate.php
FunctionsDate.getAgeAtEvent
public static function getAgeAtEvent(string $age_string): string { switch (strtoupper($age_string)) { case 'CHILD': return I18N::translate('Child'); case 'INFANT': return I18N::translate('Infant'); case 'STILLBORN': return I18N::translate('Stillborn'); default: return preg_replace_callback( [ '/(\d+)([ymwd])/', ], static function (array $match): string { $num = (int) $match[1]; switch ($match[2]) { case 'y': return I18N::plural('%s year', '%s years', $num, I18N::number($num)); case 'm': return I18N::plural('%s month', '%s months', $num, I18N::number($num)); case 'w': return I18N::plural('%s week', '%s weeks', $num, I18N::number($num)); case 'd': return I18N::plural('%s day', '%s days', $num, I18N::number($num)); default: throw new LogicException('Should never get here'); } }, $age_string ); } }
php
public static function getAgeAtEvent(string $age_string): string { switch (strtoupper($age_string)) { case 'CHILD': return I18N::translate('Child'); case 'INFANT': return I18N::translate('Infant'); case 'STILLBORN': return I18N::translate('Stillborn'); default: return preg_replace_callback( [ '/(\d+)([ymwd])/', ], static function (array $match): string { $num = (int) $match[1]; switch ($match[2]) { case 'y': return I18N::plural('%s year', '%s years', $num, I18N::number($num)); case 'm': return I18N::plural('%s month', '%s months', $num, I18N::number($num)); case 'w': return I18N::plural('%s week', '%s weeks', $num, I18N::number($num)); case 'd': return I18N::plural('%s day', '%s days', $num, I18N::number($num)); default: throw new LogicException('Should never get here'); } }, $age_string ); } }
[ "public", "static", "function", "getAgeAtEvent", "(", "string", "$", "age_string", ")", ":", "string", "{", "switch", "(", "strtoupper", "(", "$", "age_string", ")", ")", "{", "case", "'CHILD'", ":", "return", "I18N", "::", "translate", "(", "'Child'", ")", ";", "case", "'INFANT'", ":", "return", "I18N", "::", "translate", "(", "'Infant'", ")", ";", "case", "'STILLBORN'", ":", "return", "I18N", "::", "translate", "(", "'Stillborn'", ")", ";", "default", ":", "return", "preg_replace_callback", "(", "[", "'/(\\d+)([ymwd])/'", ",", "]", ",", "static", "function", "(", "array", "$", "match", ")", ":", "string", "{", "$", "num", "=", "(", "int", ")", "$", "match", "[", "1", "]", ";", "switch", "(", "$", "match", "[", "2", "]", ")", "{", "case", "'y'", ":", "return", "I18N", "::", "plural", "(", "'%s year'", ",", "'%s years'", ",", "$", "num", ",", "I18N", "::", "number", "(", "$", "num", ")", ")", ";", "case", "'m'", ":", "return", "I18N", "::", "plural", "(", "'%s month'", ",", "'%s months'", ",", "$", "num", ",", "I18N", "::", "number", "(", "$", "num", ")", ")", ";", "case", "'w'", ":", "return", "I18N", "::", "plural", "(", "'%s week'", ",", "'%s weeks'", ",", "$", "num", ",", "I18N", "::", "number", "(", "$", "num", ")", ")", ";", "case", "'d'", ":", "return", "I18N", "::", "plural", "(", "'%s day'", ",", "'%s days'", ",", "$", "num", ",", "I18N", "::", "number", "(", "$", "num", ")", ")", ";", "default", ":", "throw", "new", "LogicException", "(", "'Should never get here'", ")", ";", "}", "}", ",", "$", "age_string", ")", ";", "}", "}" ]
Convert a GEDCOM age string to localized text. @param string $age_string @return string
[ "Convert", "a", "GEDCOM", "age", "string", "to", "localized", "text", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsDate.php#L35-L68
train
fisharebest/webtrees
app/Module/BatchUpdate/BatchUpdateBasePlugin.php
BatchUpdateBasePlugin.getActionPreview
public function getActionPreview(GedcomRecord $record): string { $old_lines = explode("\n", $record->gedcom()); $new_lines = explode("\n", $this->updateRecord($record)); $algorithm = new MyersDiff(); $differences = $algorithm->calculate($old_lines, $new_lines); $diff_lines = []; foreach ($differences as $difference) { switch ($difference[1]) { case MyersDiff::DELETE: $diff_lines[] = self::decorateDeletedText($difference[0]); break; case MyersDiff::INSERT: $diff_lines[] = self::decorateInsertedText($difference[0]); break; default: $diff_lines[] = $difference[0]; } } return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines), $record) . '</pre>'; }
php
public function getActionPreview(GedcomRecord $record): string { $old_lines = explode("\n", $record->gedcom()); $new_lines = explode("\n", $this->updateRecord($record)); $algorithm = new MyersDiff(); $differences = $algorithm->calculate($old_lines, $new_lines); $diff_lines = []; foreach ($differences as $difference) { switch ($difference[1]) { case MyersDiff::DELETE: $diff_lines[] = self::decorateDeletedText($difference[0]); break; case MyersDiff::INSERT: $diff_lines[] = self::decorateInsertedText($difference[0]); break; default: $diff_lines[] = $difference[0]; } } return '<pre class="gedcom-data">' . self::createEditLinks(implode("\n", $diff_lines), $record) . '</pre>'; }
[ "public", "function", "getActionPreview", "(", "GedcomRecord", "$", "record", ")", ":", "string", "{", "$", "old_lines", "=", "explode", "(", "\"\\n\"", ",", "$", "record", "->", "gedcom", "(", ")", ")", ";", "$", "new_lines", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "updateRecord", "(", "$", "record", ")", ")", ";", "$", "algorithm", "=", "new", "MyersDiff", "(", ")", ";", "$", "differences", "=", "$", "algorithm", "->", "calculate", "(", "$", "old_lines", ",", "$", "new_lines", ")", ";", "$", "diff_lines", "=", "[", "]", ";", "foreach", "(", "$", "differences", "as", "$", "difference", ")", "{", "switch", "(", "$", "difference", "[", "1", "]", ")", "{", "case", "MyersDiff", "::", "DELETE", ":", "$", "diff_lines", "[", "]", "=", "self", "::", "decorateDeletedText", "(", "$", "difference", "[", "0", "]", ")", ";", "break", ";", "case", "MyersDiff", "::", "INSERT", ":", "$", "diff_lines", "[", "]", "=", "self", "::", "decorateInsertedText", "(", "$", "difference", "[", "0", "]", ")", ";", "break", ";", "default", ":", "$", "diff_lines", "[", "]", "=", "$", "difference", "[", "0", "]", ";", "}", "}", "return", "'<pre class=\"gedcom-data\">'", ".", "self", "::", "createEditLinks", "(", "implode", "(", "\"\\n\"", ",", "$", "diff_lines", ")", ",", "$", "record", ")", ".", "'</pre>'", ";", "}" ]
Default previewer for plugins with no custom preview. @param GedcomRecord $record @return string
[ "Default", "previewer", "for", "plugins", "with", "no", "custom", "preview", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdate/BatchUpdateBasePlugin.php#L81-L103
train
fisharebest/webtrees
app/Module/BatchUpdate/BatchUpdateBasePlugin.php
BatchUpdateBasePlugin.createEditLinks
public static function createEditLinks($gedrec, GedcomRecord $record): string { return preg_replace( "/@([^#@\n]+)@/m", '<a href="' . e(route('edit-raw-record', [ 'ged' => $record->tree()->name(), 'xref' => $record->xref(), ])) . '">@\\1@</a>', $gedrec ); }
php
public static function createEditLinks($gedrec, GedcomRecord $record): string { return preg_replace( "/@([^#@\n]+)@/m", '<a href="' . e(route('edit-raw-record', [ 'ged' => $record->tree()->name(), 'xref' => $record->xref(), ])) . '">@\\1@</a>', $gedrec ); }
[ "public", "static", "function", "createEditLinks", "(", "$", "gedrec", ",", "GedcomRecord", "$", "record", ")", ":", "string", "{", "return", "preg_replace", "(", "\"/@([^#@\\n]+)@/m\"", ",", "'<a href=\"'", ".", "e", "(", "route", "(", "'edit-raw-record'", ",", "[", "'ged'", "=>", "$", "record", "->", "tree", "(", ")", "->", "name", "(", ")", ",", "'xref'", "=>", "$", "record", "->", "xref", "(", ")", ",", "]", ")", ")", ".", "'\">@\\\\1@</a>'", ",", "$", "gedrec", ")", ";", "}" ]
Converted gedcom links into editable links @param string $gedrec @param GedcomRecord $record @return string
[ "Converted", "gedcom", "links", "into", "editable", "links" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/BatchUpdate/BatchUpdateBasePlugin.php#L137-L147
train
fisharebest/webtrees
app/Report/ReportPdfFootnote.php
ReportPdfFootnote.render
public function render($renderer) { $renderer->setCurrentStyle('footnotenum'); $renderer->Write($renderer->getCurrentStyleHeight(), $this->numText, $this->addlink); //source link numbers after name }
php
public function render($renderer) { $renderer->setCurrentStyle('footnotenum'); $renderer->Write($renderer->getCurrentStyleHeight(), $this->numText, $this->addlink); //source link numbers after name }
[ "public", "function", "render", "(", "$", "renderer", ")", "{", "$", "renderer", "->", "setCurrentStyle", "(", "'footnotenum'", ")", ";", "$", "renderer", "->", "Write", "(", "$", "renderer", "->", "getCurrentStyleHeight", "(", ")", ",", "$", "this", "->", "numText", ",", "$", "this", "->", "addlink", ")", ";", "//source link numbers after name", "}" ]
PDF Footnotes number renderer @param ReportTcpdf $renderer @return void
[ "PDF", "Footnotes", "number", "renderer" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportPdfFootnote.php#L32-L36
train
fisharebest/webtrees
app/Report/ReportPdfFootnote.php
ReportPdfFootnote.getWidth
public function getWidth($renderer) { // Setup the style name, a font must be selected to calculate the width $renderer->setCurrentStyle('footnotenum'); // Check for the largest font size in the box $fsize = $renderer->getCurrentStyleHeight(); if ($fsize > $renderer->largestFontHeight) { $renderer->largestFontHeight = $fsize; } // Returns the Object if already numbered else false if (empty($this->num)) { $renderer->checkFootnote($this); } // Get the line width $lw = ceil($renderer->GetStringWidth($this->numText)); // Line Feed counter - Number of lines in the text $lfct = substr_count($this->numText, "\n") + 1; // If there is still remaining wrap width... if ($this->wrapWidthRemaining > 0) { // Check with line counter too! $wrapWidthRemaining = $this->wrapWidthRemaining; if ($lw >= $wrapWidthRemaining || $lfct > 1) { $newtext = ''; $lines = explode("\n", $this->numText); // Go throught the text line by line foreach ($lines as $line) { // Line width in points $lw = ceil($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 += ceil($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 feed 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->numText = $newtext; $lfct = substr_count($this->numText, "\n"); return [ $lw, 1, $lfct, ]; } } $l = 0; $lfct = substr_count($this->numText, "\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 $renderer->setCurrentStyle('footnotenum'); // Check for the largest font size in the box $fsize = $renderer->getCurrentStyleHeight(); if ($fsize > $renderer->largestFontHeight) { $renderer->largestFontHeight = $fsize; } // Returns the Object if already numbered else false if (empty($this->num)) { $renderer->checkFootnote($this); } // Get the line width $lw = ceil($renderer->GetStringWidth($this->numText)); // Line Feed counter - Number of lines in the text $lfct = substr_count($this->numText, "\n") + 1; // If there is still remaining wrap width... if ($this->wrapWidthRemaining > 0) { // Check with line counter too! $wrapWidthRemaining = $this->wrapWidthRemaining; if ($lw >= $wrapWidthRemaining || $lfct > 1) { $newtext = ''; $lines = explode("\n", $this->numText); // Go throught the text line by line foreach ($lines as $line) { // Line width in points $lw = ceil($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 += ceil($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 feed 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->numText = $newtext; $lfct = substr_count($this->numText, "\n"); return [ $lw, 1, $lfct, ]; } } $l = 0; $lfct = substr_count($this->numText, "\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", "$", "renderer", "->", "setCurrentStyle", "(", "'footnotenum'", ")", ";", "// Check for the largest font size in the box", "$", "fsize", "=", "$", "renderer", "->", "getCurrentStyleHeight", "(", ")", ";", "if", "(", "$", "fsize", ">", "$", "renderer", "->", "largestFontHeight", ")", "{", "$", "renderer", "->", "largestFontHeight", "=", "$", "fsize", ";", "}", "// Returns the Object if already numbered else false", "if", "(", "empty", "(", "$", "this", "->", "num", ")", ")", "{", "$", "renderer", "->", "checkFootnote", "(", "$", "this", ")", ";", "}", "// Get the line width", "$", "lw", "=", "ceil", "(", "$", "renderer", "->", "GetStringWidth", "(", "$", "this", "->", "numText", ")", ")", ";", "// Line Feed counter - Number of lines in the text", "$", "lfct", "=", "substr_count", "(", "$", "this", "->", "numText", ",", "\"\\n\"", ")", "+", "1", ";", "// If there is still remaining wrap width...", "if", "(", "$", "this", "->", "wrapWidthRemaining", ">", "0", ")", "{", "// Check with line counter too!", "$", "wrapWidthRemaining", "=", "$", "this", "->", "wrapWidthRemaining", ";", "if", "(", "$", "lw", ">=", "$", "wrapWidthRemaining", "||", "$", "lfct", ">", "1", ")", "{", "$", "newtext", "=", "''", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "numText", ")", ";", "// Go throught the text line by line", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "// Line width in points", "$", "lw", "=", "ceil", "(", "$", "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", "+=", "ceil", "(", "$", "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 feed 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", "->", "numText", "=", "$", "newtext", ";", "$", "lfct", "=", "substr_count", "(", "$", "this", "->", "numText", ",", "\"\\n\"", ")", ";", "return", "[", "$", "lw", ",", "1", ",", "$", "lfct", ",", "]", ";", "}", "}", "$", "l", "=", "0", ";", "$", "lfct", "=", "substr_count", "(", "$", "this", "->", "numText", ",", "\"\\n\"", ")", ";", "if", "(", "$", "lfct", ">", "0", ")", "{", "$", "l", "=", "2", ";", "}", "return", "[", "$", "lw", ",", "$", "l", ",", "$", "lfct", ",", "]", ";", "}" ]
Splits the text into lines to fit into a giving cell and returns the last lines width @param ReportTcpdf $renderer @return float|array
[ "Splits", "the", "text", "into", "lines", "to", "fit", "into", "a", "giving", "cell", "and", "returns", "the", "last", "lines", "width" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Report/ReportPdfFootnote.php#L92-L181
train
fisharebest/webtrees
app/Media.php
Media.mediaFiles
public function mediaFiles(): Collection { return $this->facts(['FILE']) ->map(function (Fact $fact): MediaFile { return new MediaFile($fact->gedcom(), $this); }); }
php
public function mediaFiles(): Collection { return $this->facts(['FILE']) ->map(function (Fact $fact): MediaFile { return new MediaFile($fact->gedcom(), $this); }); }
[ "public", "function", "mediaFiles", "(", ")", ":", "Collection", "{", "return", "$", "this", "->", "facts", "(", "[", "'FILE'", "]", ")", "->", "map", "(", "function", "(", "Fact", "$", "fact", ")", ":", "MediaFile", "{", "return", "new", "MediaFile", "(", "$", "fact", "->", "gedcom", "(", ")", ",", "$", "this", ")", ";", "}", ")", ";", "}" ]
Get the media files for this media object @return Collection @return MediaFile[]
[ "Get", "the", "media", "files", "for", "this", "media", "object" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Media.php#L120-L126
train
fisharebest/webtrees
app/Media.php
Media.firstImageFile
public function firstImageFile(): ?MediaFile { foreach ($this->mediaFiles() as $media_file) { if ($media_file->isImage()) { return $media_file; } } return null; }
php
public function firstImageFile(): ?MediaFile { foreach ($this->mediaFiles() as $media_file) { if ($media_file->isImage()) { return $media_file; } } return null; }
[ "public", "function", "firstImageFile", "(", ")", ":", "?", "MediaFile", "{", "foreach", "(", "$", "this", "->", "mediaFiles", "(", ")", "as", "$", "media_file", ")", "{", "if", "(", "$", "media_file", "->", "isImage", "(", ")", ")", "{", "return", "$", "media_file", ";", "}", "}", "return", "null", ";", "}" ]
Get the first media file that contains an image. @return MediaFile|null
[ "Get", "the", "first", "media", "file", "that", "contains", "an", "image", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Media.php#L133-L142
train
fisharebest/webtrees
app/Media.php
Media.getNote
public function getNote(): string { $fact = $this->facts(['NOTE'])->first(); if ($fact instanceof Fact) { // Link to note object $note = $fact->target(); if ($note instanceof Note) { return $note->getNote(); } // Inline note return $fact->value(); } return ''; }
php
public function getNote(): string { $fact = $this->facts(['NOTE'])->first(); if ($fact instanceof Fact) { // Link to note object $note = $fact->target(); if ($note instanceof Note) { return $note->getNote(); } // Inline note return $fact->value(); } return ''; }
[ "public", "function", "getNote", "(", ")", ":", "string", "{", "$", "fact", "=", "$", "this", "->", "facts", "(", "[", "'NOTE'", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "fact", "instanceof", "Fact", ")", "{", "// Link to note object", "$", "note", "=", "$", "fact", "->", "target", "(", ")", ";", "if", "(", "$", "note", "instanceof", "Note", ")", "{", "return", "$", "note", "->", "getNote", "(", ")", ";", "}", "// Inline note", "return", "$", "fact", "->", "value", "(", ")", ";", "}", "return", "''", ";", "}" ]
Get the first note attached to this media object @return string
[ "Get", "the", "first", "note", "attached", "to", "this", "media", "object" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Media.php#L149-L165
train
fisharebest/webtrees
app/Module/HitCountFooterModule.php
HitCountFooterModule.countHit
protected function countHit(Tree $tree, string $page, string $parameter): int { // Don't increment the counter while we stay on the same page. if ( Session::get('last_gedcom_id') === $tree->id() && Session::get('last_page_name') === $page && Session::get('last_page_parameter') === $parameter ) { return (int) Session::get('last_count'); } $count = (int) DB::table('hit_counter') ->where('gedcom_id', '=', $tree->id()) ->where('page_name', '=', $page) ->where('page_parameter', '=', $parameter) ->value('page_count'); $count++; DB::table('hit_counter')->updateOrInsert([ 'gedcom_id' => $tree->id(), 'page_name' => $page, 'page_parameter' => $parameter, ], [ 'page_count' => $count, ]); Session::put('last_gedcom_id', $tree->id()); Session::put('last_page_name', $page); Session::put('last_page_parameter', $parameter); Session::put('last_count', $count); return $count; }
php
protected function countHit(Tree $tree, string $page, string $parameter): int { // Don't increment the counter while we stay on the same page. if ( Session::get('last_gedcom_id') === $tree->id() && Session::get('last_page_name') === $page && Session::get('last_page_parameter') === $parameter ) { return (int) Session::get('last_count'); } $count = (int) DB::table('hit_counter') ->where('gedcom_id', '=', $tree->id()) ->where('page_name', '=', $page) ->where('page_parameter', '=', $parameter) ->value('page_count'); $count++; DB::table('hit_counter')->updateOrInsert([ 'gedcom_id' => $tree->id(), 'page_name' => $page, 'page_parameter' => $parameter, ], [ 'page_count' => $count, ]); Session::put('last_gedcom_id', $tree->id()); Session::put('last_page_name', $page); Session::put('last_page_parameter', $parameter); Session::put('last_count', $count); return $count; }
[ "protected", "function", "countHit", "(", "Tree", "$", "tree", ",", "string", "$", "page", ",", "string", "$", "parameter", ")", ":", "int", "{", "// Don't increment the counter while we stay on the same page.", "if", "(", "Session", "::", "get", "(", "'last_gedcom_id'", ")", "===", "$", "tree", "->", "id", "(", ")", "&&", "Session", "::", "get", "(", "'last_page_name'", ")", "===", "$", "page", "&&", "Session", "::", "get", "(", "'last_page_parameter'", ")", "===", "$", "parameter", ")", "{", "return", "(", "int", ")", "Session", "::", "get", "(", "'last_count'", ")", ";", "}", "$", "count", "=", "(", "int", ")", "DB", "::", "table", "(", "'hit_counter'", ")", "->", "where", "(", "'gedcom_id'", ",", "'='", ",", "$", "tree", "->", "id", "(", ")", ")", "->", "where", "(", "'page_name'", ",", "'='", ",", "$", "page", ")", "->", "where", "(", "'page_parameter'", ",", "'='", ",", "$", "parameter", ")", "->", "value", "(", "'page_count'", ")", ";", "$", "count", "++", ";", "DB", "::", "table", "(", "'hit_counter'", ")", "->", "updateOrInsert", "(", "[", "'gedcom_id'", "=>", "$", "tree", "->", "id", "(", ")", ",", "'page_name'", "=>", "$", "page", ",", "'page_parameter'", "=>", "$", "parameter", ",", "]", ",", "[", "'page_count'", "=>", "$", "count", ",", "]", ")", ";", "Session", "::", "put", "(", "'last_gedcom_id'", ",", "$", "tree", "->", "id", "(", ")", ")", ";", "Session", "::", "put", "(", "'last_page_name'", ",", "$", "page", ")", ";", "Session", "::", "put", "(", "'last_page_parameter'", ",", "$", "parameter", ")", ";", "Session", "::", "put", "(", "'last_count'", ",", "$", "count", ")", ";", "return", "$", "count", ";", "}" ]
Increment the page count. @param Tree $tree @param string $page @param string $parameter @return int
[ "Increment", "the", "page", "count", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/HitCountFooterModule.php#L153-L186
train
fisharebest/webtrees
app/Http/Controllers/ReportEngineController.php
ReportEngineController.reportList
public function reportList(Tree $tree, UserInterface $user): ResponseInterface { $title = I18N::translate('Choose a report to run'); return $this->viewResponse('report-select-page', [ 'reports' => $this->module_service->findByComponent(ModuleReportInterface::class, $tree, $user), 'title' => $title, ]); }
php
public function reportList(Tree $tree, UserInterface $user): ResponseInterface { $title = I18N::translate('Choose a report to run'); return $this->viewResponse('report-select-page', [ 'reports' => $this->module_service->findByComponent(ModuleReportInterface::class, $tree, $user), 'title' => $title, ]); }
[ "public", "function", "reportList", "(", "Tree", "$", "tree", ",", "UserInterface", "$", "user", ")", ":", "ResponseInterface", "{", "$", "title", "=", "I18N", "::", "translate", "(", "'Choose a report to run'", ")", ";", "return", "$", "this", "->", "viewResponse", "(", "'report-select-page'", ",", "[", "'reports'", "=>", "$", "this", "->", "module_service", "->", "findByComponent", "(", "ModuleReportInterface", "::", "class", ",", "$", "tree", ",", "$", "user", ")", ",", "'title'", "=>", "$", "title", ",", "]", ")", ";", "}" ]
A list of available reports. @param Tree $tree @param UserInterface $user @return ResponseInterface
[ "A", "list", "of", "available", "reports", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/ReportEngineController.php#L69-L77
train
fisharebest/webtrees
app/Http/Middleware/DoHousekeeping.php
DoHousekeeping.runHousekeeping
private function runHousekeeping(): void { $data_filesystem = app(FilesystemInterface::class); $root_filesystem = new Filesystem(new Local(Webtrees::ROOT_DIR)); // Clear files in the (user-specified) data folder - which might not be local files $this->housekeeping_service->deleteOldFiles($data_filesystem, 'cache', self::MAX_CACHE_AGE); $this->housekeeping_service->deleteOldFiles($data_filesystem, 'thumbnail-cache', self::MAX_THUMBNAIL_AGE); // Clear files in /data - which need to be local files $this->housekeeping_service->deleteOldFiles($root_filesystem, self::TMP_DIR, self::MAX_TMP_FILE_AGE); // Clear entries in database tables $this->housekeeping_service->deleteOldLogs(self::MAX_LOG_AGE); $this->housekeeping_service->deleteOldSessions(self::MAX_SESSION_AGE); }
php
private function runHousekeeping(): void { $data_filesystem = app(FilesystemInterface::class); $root_filesystem = new Filesystem(new Local(Webtrees::ROOT_DIR)); // Clear files in the (user-specified) data folder - which might not be local files $this->housekeeping_service->deleteOldFiles($data_filesystem, 'cache', self::MAX_CACHE_AGE); $this->housekeeping_service->deleteOldFiles($data_filesystem, 'thumbnail-cache', self::MAX_THUMBNAIL_AGE); // Clear files in /data - which need to be local files $this->housekeeping_service->deleteOldFiles($root_filesystem, self::TMP_DIR, self::MAX_TMP_FILE_AGE); // Clear entries in database tables $this->housekeeping_service->deleteOldLogs(self::MAX_LOG_AGE); $this->housekeeping_service->deleteOldSessions(self::MAX_SESSION_AGE); }
[ "private", "function", "runHousekeeping", "(", ")", ":", "void", "{", "$", "data_filesystem", "=", "app", "(", "FilesystemInterface", "::", "class", ")", ";", "$", "root_filesystem", "=", "new", "Filesystem", "(", "new", "Local", "(", "Webtrees", "::", "ROOT_DIR", ")", ")", ";", "// Clear files in the (user-specified) data folder - which might not be local files", "$", "this", "->", "housekeeping_service", "->", "deleteOldFiles", "(", "$", "data_filesystem", ",", "'cache'", ",", "self", "::", "MAX_CACHE_AGE", ")", ";", "$", "this", "->", "housekeeping_service", "->", "deleteOldFiles", "(", "$", "data_filesystem", ",", "'thumbnail-cache'", ",", "self", "::", "MAX_THUMBNAIL_AGE", ")", ";", "// Clear files in /data - which need to be local files", "$", "this", "->", "housekeeping_service", "->", "deleteOldFiles", "(", "$", "root_filesystem", ",", "self", "::", "TMP_DIR", ",", "self", "::", "MAX_TMP_FILE_AGE", ")", ";", "// Clear entries in database tables", "$", "this", "->", "housekeeping_service", "->", "deleteOldLogs", "(", "self", "::", "MAX_LOG_AGE", ")", ";", "$", "this", "->", "housekeeping_service", "->", "deleteOldSessions", "(", "self", "::", "MAX_SESSION_AGE", ")", ";", "}" ]
Run the various housekeeping services. @return void
[ "Run", "the", "various", "housekeeping", "services", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Middleware/DoHousekeeping.php#L91-L108
train
fisharebest/webtrees
app/Functions/FunctionsExport.php
FunctionsExport.convertMediaPath
private static function convertMediaPath($rec, $path): string { if ($path && preg_match('/\n1 FILE (.+)/', $rec, $match)) { $old_file_name = $match[1]; // Don’t modify external links if (strpos($old_file_name, '://') === false) { // Adding a windows path? Convert the slashes. if (strpos($path, '\\') !== false) { $new_file_name = preg_replace('~/+~', '\\', $old_file_name); } else { $new_file_name = $old_file_name; } // Path not present - add it. if (strpos($new_file_name, $path) === false) { $new_file_name = $path . $new_file_name; } $rec = str_replace("\n1 FILE " . $old_file_name, "\n1 FILE " . $new_file_name, $rec); } } return $rec; }
php
private static function convertMediaPath($rec, $path): string { if ($path && preg_match('/\n1 FILE (.+)/', $rec, $match)) { $old_file_name = $match[1]; // Don’t modify external links if (strpos($old_file_name, '://') === false) { // Adding a windows path? Convert the slashes. if (strpos($path, '\\') !== false) { $new_file_name = preg_replace('~/+~', '\\', $old_file_name); } else { $new_file_name = $old_file_name; } // Path not present - add it. if (strpos($new_file_name, $path) === false) { $new_file_name = $path . $new_file_name; } $rec = str_replace("\n1 FILE " . $old_file_name, "\n1 FILE " . $new_file_name, $rec); } } return $rec; }
[ "private", "static", "function", "convertMediaPath", "(", "$", "rec", ",", "$", "path", ")", ":", "string", "{", "if", "(", "$", "path", "&&", "preg_match", "(", "'/\\n1 FILE (.+)/'", ",", "$", "rec", ",", "$", "match", ")", ")", "{", "$", "old_file_name", "=", "$", "match", "[", "1", "]", ";", "// Don’t modify external links", "if", "(", "strpos", "(", "$", "old_file_name", ",", "'://'", ")", "===", "false", ")", "{", "// Adding a windows path? Convert the slashes.", "if", "(", "strpos", "(", "$", "path", ",", "'\\\\'", ")", "!==", "false", ")", "{", "$", "new_file_name", "=", "preg_replace", "(", "'~/+~'", ",", "'\\\\'", ",", "$", "old_file_name", ")", ";", "}", "else", "{", "$", "new_file_name", "=", "$", "old_file_name", ";", "}", "// Path not present - add it.", "if", "(", "strpos", "(", "$", "new_file_name", ",", "$", "path", ")", "===", "false", ")", "{", "$", "new_file_name", "=", "$", "path", ".", "$", "new_file_name", ";", "}", "$", "rec", "=", "str_replace", "(", "\"\\n1 FILE \"", ".", "$", "old_file_name", ",", "\"\\n1 FILE \"", ".", "$", "new_file_name", ",", "$", "rec", ")", ";", "}", "}", "return", "$", "rec", ";", "}" ]
Prepend the GEDCOM_MEDIA_PATH to media filenames. @param string $rec @param string $path @return string
[ "Prepend", "the", "GEDCOM_MEDIA_PATH", "to", "media", "filenames", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Functions/FunctionsExport.php#L138-L159
train
fisharebest/webtrees
app/Services/CalendarService.php
CalendarService.calendarMonthsInYear
public function calendarMonthsInYear(string $calendar, int $year): array { $date = new Date($calendar . ' ' . $year); $calendar_date = $date->minimumDate(); $month_numbers = range(1, $calendar_date->monthsInYear()); $month_names = []; foreach ($month_numbers as $month_number) { $calendar_date->day = 1; $calendar_date->month = $month_number; $calendar_date->setJdFromYmd(); if ($month_number === 6 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) { // No month 6 in Jewish non-leap years. continue; } if ($month_number === 7 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) { // Month 7 is ADR in Jewish non-leap years (and ADS in others). $mon = 'ADR'; } else { $mon = $calendar_date->format('%O'); } $month_names[$mon] = $calendar_date->format('%F'); } return $month_names; }
php
public function calendarMonthsInYear(string $calendar, int $year): array { $date = new Date($calendar . ' ' . $year); $calendar_date = $date->minimumDate(); $month_numbers = range(1, $calendar_date->monthsInYear()); $month_names = []; foreach ($month_numbers as $month_number) { $calendar_date->day = 1; $calendar_date->month = $month_number; $calendar_date->setJdFromYmd(); if ($month_number === 6 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) { // No month 6 in Jewish non-leap years. continue; } if ($month_number === 7 && $calendar_date instanceof JewishDate && !$calendar_date->isLeapYear()) { // Month 7 is ADR in Jewish non-leap years (and ADS in others). $mon = 'ADR'; } else { $mon = $calendar_date->format('%O'); } $month_names[$mon] = $calendar_date->format('%F'); } return $month_names; }
[ "public", "function", "calendarMonthsInYear", "(", "string", "$", "calendar", ",", "int", "$", "year", ")", ":", "array", "{", "$", "date", "=", "new", "Date", "(", "$", "calendar", ".", "' '", ".", "$", "year", ")", ";", "$", "calendar_date", "=", "$", "date", "->", "minimumDate", "(", ")", ";", "$", "month_numbers", "=", "range", "(", "1", ",", "$", "calendar_date", "->", "monthsInYear", "(", ")", ")", ";", "$", "month_names", "=", "[", "]", ";", "foreach", "(", "$", "month_numbers", "as", "$", "month_number", ")", "{", "$", "calendar_date", "->", "day", "=", "1", ";", "$", "calendar_date", "->", "month", "=", "$", "month_number", ";", "$", "calendar_date", "->", "setJdFromYmd", "(", ")", ";", "if", "(", "$", "month_number", "===", "6", "&&", "$", "calendar_date", "instanceof", "JewishDate", "&&", "!", "$", "calendar_date", "->", "isLeapYear", "(", ")", ")", "{", "// No month 6 in Jewish non-leap years.", "continue", ";", "}", "if", "(", "$", "month_number", "===", "7", "&&", "$", "calendar_date", "instanceof", "JewishDate", "&&", "!", "$", "calendar_date", "->", "isLeapYear", "(", ")", ")", "{", "// Month 7 is ADR in Jewish non-leap years (and ADS in others).", "$", "mon", "=", "'ADR'", ";", "}", "else", "{", "$", "mon", "=", "$", "calendar_date", "->", "format", "(", "'%O'", ")", ";", "}", "$", "month_names", "[", "$", "mon", "]", "=", "$", "calendar_date", "->", "format", "(", "'%F'", ")", ";", "}", "return", "$", "month_names", ";", "}" ]
List all the months in a given year. @param string $calendar @param int $year @return string[]
[ "List", "all", "the", "months", "in", "a", "given", "year", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/CalendarService.php#L51-L79
train
fisharebest/webtrees
app/Services/CalendarService.php
CalendarService.getEventsList
public function getEventsList(int $jd1, int $jd2, string $events, bool $only_living, string $sort_by, Tree $tree): array { $found_facts = []; $facts = []; foreach (range($jd1, $jd2) as $jd) { $found_facts = array_merge($found_facts, $this->getAnniversaryEvents($jd, $events, $tree)); } foreach ($found_facts as $fact) { $record = $fact->record(); // only living people ? if ($only_living) { if ($record instanceof Individual && $record->isDead()) { continue; } if ($record instanceof Family) { $husb = $record->husband(); if ($husb === null || $husb->isDead()) { continue; } $wife = $record->wife(); if ($wife === null || $wife->isDead()) { continue; } } } $facts[] = $fact; } switch ($sort_by) { case 'anniv': $facts = Fact::sortFacts(Collection::make($facts))->all(); break; case 'alpha': uasort($facts, static function (Fact $x, Fact $y): int { return GedcomRecord::nameComparator()($x->record(), $y->record()); }); break; } return $facts; }
php
public function getEventsList(int $jd1, int $jd2, string $events, bool $only_living, string $sort_by, Tree $tree): array { $found_facts = []; $facts = []; foreach (range($jd1, $jd2) as $jd) { $found_facts = array_merge($found_facts, $this->getAnniversaryEvents($jd, $events, $tree)); } foreach ($found_facts as $fact) { $record = $fact->record(); // only living people ? if ($only_living) { if ($record instanceof Individual && $record->isDead()) { continue; } if ($record instanceof Family) { $husb = $record->husband(); if ($husb === null || $husb->isDead()) { continue; } $wife = $record->wife(); if ($wife === null || $wife->isDead()) { continue; } } } $facts[] = $fact; } switch ($sort_by) { case 'anniv': $facts = Fact::sortFacts(Collection::make($facts))->all(); break; case 'alpha': uasort($facts, static function (Fact $x, Fact $y): int { return GedcomRecord::nameComparator()($x->record(), $y->record()); }); break; } return $facts; }
[ "public", "function", "getEventsList", "(", "int", "$", "jd1", ",", "int", "$", "jd2", ",", "string", "$", "events", ",", "bool", "$", "only_living", ",", "string", "$", "sort_by", ",", "Tree", "$", "tree", ")", ":", "array", "{", "$", "found_facts", "=", "[", "]", ";", "$", "facts", "=", "[", "]", ";", "foreach", "(", "range", "(", "$", "jd1", ",", "$", "jd2", ")", "as", "$", "jd", ")", "{", "$", "found_facts", "=", "array_merge", "(", "$", "found_facts", ",", "$", "this", "->", "getAnniversaryEvents", "(", "$", "jd", ",", "$", "events", ",", "$", "tree", ")", ")", ";", "}", "foreach", "(", "$", "found_facts", "as", "$", "fact", ")", "{", "$", "record", "=", "$", "fact", "->", "record", "(", ")", ";", "// only living people ?", "if", "(", "$", "only_living", ")", "{", "if", "(", "$", "record", "instanceof", "Individual", "&&", "$", "record", "->", "isDead", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "record", "instanceof", "Family", ")", "{", "$", "husb", "=", "$", "record", "->", "husband", "(", ")", ";", "if", "(", "$", "husb", "===", "null", "||", "$", "husb", "->", "isDead", "(", ")", ")", "{", "continue", ";", "}", "$", "wife", "=", "$", "record", "->", "wife", "(", ")", ";", "if", "(", "$", "wife", "===", "null", "||", "$", "wife", "->", "isDead", "(", ")", ")", "{", "continue", ";", "}", "}", "}", "$", "facts", "[", "]", "=", "$", "fact", ";", "}", "switch", "(", "$", "sort_by", ")", "{", "case", "'anniv'", ":", "$", "facts", "=", "Fact", "::", "sortFacts", "(", "Collection", "::", "make", "(", "$", "facts", ")", ")", "->", "all", "(", ")", ";", "break", ";", "case", "'alpha'", ":", "uasort", "(", "$", "facts", ",", "static", "function", "(", "Fact", "$", "x", ",", "Fact", "$", "y", ")", ":", "int", "{", "return", "GedcomRecord", "::", "nameComparator", "(", ")", "(", "$", "x", "->", "record", "(", ")", ",", "$", "y", "->", "record", "(", ")", ")", ";", "}", ")", ";", "break", ";", "}", "return", "$", "facts", ";", "}" ]
Get the list of current and upcoming events, sorted by anniversary date @param int $jd1 @param int $jd2 @param string $events @param bool $only_living @param string $sort_by @param Tree $tree @return Fact[]
[ "Get", "the", "list", "of", "current", "and", "upcoming", "events", "sorted", "by", "anniversary", "date" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/CalendarService.php#L168-L211
train
fisharebest/webtrees
app/Services/CalendarService.php
CalendarService.defaultAnniversaries
private function defaultAnniversaries(Builder $query, AbstractCalendarDate $anniv): void { if ($anniv->day() === 1) { $query->where('d_day', '<=', 1); } elseif ($anniv->day() === $anniv->daysInMonth()) { $query->where('d_day', '>=', $anniv->daysInMonth()); } else { $query->where('d_day', '=', $anniv->day()); } $query->where('d_mon', '=', $anniv->month()); }
php
private function defaultAnniversaries(Builder $query, AbstractCalendarDate $anniv): void { if ($anniv->day() === 1) { $query->where('d_day', '<=', 1); } elseif ($anniv->day() === $anniv->daysInMonth()) { $query->where('d_day', '>=', $anniv->daysInMonth()); } else { $query->where('d_day', '=', $anniv->day()); } $query->where('d_mon', '=', $anniv->month()); }
[ "private", "function", "defaultAnniversaries", "(", "Builder", "$", "query", ",", "AbstractCalendarDate", "$", "anniv", ")", ":", "void", "{", "if", "(", "$", "anniv", "->", "day", "(", ")", "===", "1", ")", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'<='", ",", "1", ")", ";", "}", "elseif", "(", "$", "anniv", "->", "day", "(", ")", "===", "$", "anniv", "->", "daysInMonth", "(", ")", ")", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'>='", ",", "$", "anniv", "->", "daysInMonth", "(", ")", ")", ";", "}", "else", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'='", ",", "$", "anniv", "->", "day", "(", ")", ")", ";", "}", "$", "query", "->", "where", "(", "'d_mon'", ",", "'='", ",", "$", "anniv", "->", "month", "(", ")", ")", ";", "}" ]
By default, missing days have anniversaries on the first of the month, and invalid days have anniversaries on the last day of the month. @param Builder $query @param AbstractCalendarDate $anniv
[ "By", "default", "missing", "days", "have", "anniversaries", "on", "the", "first", "of", "the", "month", "and", "invalid", "days", "have", "anniversaries", "on", "the", "last", "day", "of", "the", "month", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/CalendarService.php#L329-L340
train
fisharebest/webtrees
app/Services/CalendarService.php
CalendarService.adarIIAnniversaries
private function adarIIAnniversaries(Builder $query, JewishDate $anniv): void { if ($anniv->day() === 1) { $query->where('d_day', '<=', 1); } elseif ($anniv->day() === $anniv->daysInMonth()) { $query->where('d_day', '>=', $anniv->daysInMonth()); } else { $query->where('d_day', '<=', 1); } $query->where(static function (Builder $query): void { $query ->where('d_mon', '=', 7) ->orWhere(static function (Builder $query): void { $query ->where('d_mon', '=', 6) ->where(DB::raw('(7 * d_year + 1 % 19)'), '>=', 7); }); }); }
php
private function adarIIAnniversaries(Builder $query, JewishDate $anniv): void { if ($anniv->day() === 1) { $query->where('d_day', '<=', 1); } elseif ($anniv->day() === $anniv->daysInMonth()) { $query->where('d_day', '>=', $anniv->daysInMonth()); } else { $query->where('d_day', '<=', 1); } $query->where(static function (Builder $query): void { $query ->where('d_mon', '=', 7) ->orWhere(static function (Builder $query): void { $query ->where('d_mon', '=', 6) ->where(DB::raw('(7 * d_year + 1 % 19)'), '>=', 7); }); }); }
[ "private", "function", "adarIIAnniversaries", "(", "Builder", "$", "query", ",", "JewishDate", "$", "anniv", ")", ":", "void", "{", "if", "(", "$", "anniv", "->", "day", "(", ")", "===", "1", ")", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'<='", ",", "1", ")", ";", "}", "elseif", "(", "$", "anniv", "->", "day", "(", ")", "===", "$", "anniv", "->", "daysInMonth", "(", ")", ")", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'>='", ",", "$", "anniv", "->", "daysInMonth", "(", ")", ")", ";", "}", "else", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'<='", ",", "1", ")", ";", "}", "$", "query", "->", "where", "(", "static", "function", "(", "Builder", "$", "query", ")", ":", "void", "{", "$", "query", "->", "where", "(", "'d_mon'", ",", "'='", ",", "7", ")", "->", "orWhere", "(", "static", "function", "(", "Builder", "$", "query", ")", ":", "void", "{", "$", "query", "->", "where", "(", "'d_mon'", ",", "'='", ",", "6", ")", "->", "where", "(", "DB", "::", "raw", "(", "'(7 * d_year + 1 % 19)'", ")", ",", "'>='", ",", "7", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
ADS includes non-leap ADR. @param Builder $query @param JewishDate $anniv
[ "ADS", "includes", "non", "-", "leap", "ADR", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/CalendarService.php#L418-L437
train
fisharebest/webtrees
app/Services/CalendarService.php
CalendarService.nisanAnniversaries
private function nisanAnniversaries(Builder $query, JewishDate $anniv): void { if ($anniv->day === 1 && !$anniv->isLeapYear()) { $query->where(static function (Builder $query): void { $query->where(static function (Builder $query): void { $query->where('d_day', '<=', 1)->where('d_mon', '=', 8); })->orWhere(static function (Builder $query): void { $query->where('d_day', '=', 30)->where('d_mon', '=', 6); }); }); } else { $this->defaultAnniversaries($query, $anniv); } }
php
private function nisanAnniversaries(Builder $query, JewishDate $anniv): void { if ($anniv->day === 1 && !$anniv->isLeapYear()) { $query->where(static function (Builder $query): void { $query->where(static function (Builder $query): void { $query->where('d_day', '<=', 1)->where('d_mon', '=', 8); })->orWhere(static function (Builder $query): void { $query->where('d_day', '=', 30)->where('d_mon', '=', 6); }); }); } else { $this->defaultAnniversaries($query, $anniv); } }
[ "private", "function", "nisanAnniversaries", "(", "Builder", "$", "query", ",", "JewishDate", "$", "anniv", ")", ":", "void", "{", "if", "(", "$", "anniv", "->", "day", "===", "1", "&&", "!", "$", "anniv", "->", "isLeapYear", "(", ")", ")", "{", "$", "query", "->", "where", "(", "static", "function", "(", "Builder", "$", "query", ")", ":", "void", "{", "$", "query", "->", "where", "(", "static", "function", "(", "Builder", "$", "query", ")", ":", "void", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'<='", ",", "1", ")", "->", "where", "(", "'d_mon'", ",", "'='", ",", "8", ")", ";", "}", ")", "->", "orWhere", "(", "static", "function", "(", "Builder", "$", "query", ")", ":", "void", "{", "$", "query", "->", "where", "(", "'d_day'", ",", "'='", ",", "30", ")", "->", "where", "(", "'d_mon'", ",", "'='", ",", "6", ")", ";", "}", ")", ";", "}", ")", ";", "}", "else", "{", "$", "this", "->", "defaultAnniversaries", "(", "$", "query", ",", "$", "anniv", ")", ";", "}", "}" ]
1 NSN includes 30 ADR, if this year is non-leap. @param Builder $query @param JewishDate $anniv
[ "1", "NSN", "includes", "30", "ADR", "if", "this", "year", "is", "non", "-", "leap", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Services/CalendarService.php#L445-L458
train
fisharebest/webtrees
app/Statistics/Google/ChartChildren.php
ChartChildren.chartChildren
public function chartChildren(): string { $data = [ [ I18N::translate('Century'), I18N::translate('Average number') ] ]; foreach ($this->queryRecords() as $record) { $data[] = [ $this->century_service->centuryName((int) $record->century), (float) $record->num ]; } $chart_title = I18N::translate('Average number of children per family'); $chart_options = [ 'title' => $chart_title, 'subtitle' => '', 'legend' => [ 'position' => 'none', ], 'vAxis' => [ 'title' => I18N::translate('Number of children'), ], 'hAxis' => [ 'title' => I18N::translate('Century'), ], 'colors' => [ '#84beff' ], ]; return view( 'statistics/other/charts/column', [ 'data' => $data, 'chart_options' => $chart_options, 'chart_title' => $chart_title, ] ); }
php
public function chartChildren(): string { $data = [ [ I18N::translate('Century'), I18N::translate('Average number') ] ]; foreach ($this->queryRecords() as $record) { $data[] = [ $this->century_service->centuryName((int) $record->century), (float) $record->num ]; } $chart_title = I18N::translate('Average number of children per family'); $chart_options = [ 'title' => $chart_title, 'subtitle' => '', 'legend' => [ 'position' => 'none', ], 'vAxis' => [ 'title' => I18N::translate('Number of children'), ], 'hAxis' => [ 'title' => I18N::translate('Century'), ], 'colors' => [ '#84beff' ], ]; return view( 'statistics/other/charts/column', [ 'data' => $data, 'chart_options' => $chart_options, 'chart_title' => $chart_title, ] ); }
[ "public", "function", "chartChildren", "(", ")", ":", "string", "{", "$", "data", "=", "[", "[", "I18N", "::", "translate", "(", "'Century'", ")", ",", "I18N", "::", "translate", "(", "'Average number'", ")", "]", "]", ";", "foreach", "(", "$", "this", "->", "queryRecords", "(", ")", "as", "$", "record", ")", "{", "$", "data", "[", "]", "=", "[", "$", "this", "->", "century_service", "->", "centuryName", "(", "(", "int", ")", "$", "record", "->", "century", ")", ",", "(", "float", ")", "$", "record", "->", "num", "]", ";", "}", "$", "chart_title", "=", "I18N", "::", "translate", "(", "'Average number of children per family'", ")", ";", "$", "chart_options", "=", "[", "'title'", "=>", "$", "chart_title", ",", "'subtitle'", "=>", "''", ",", "'legend'", "=>", "[", "'position'", "=>", "'none'", ",", "]", ",", "'vAxis'", "=>", "[", "'title'", "=>", "I18N", "::", "translate", "(", "'Number of children'", ")", ",", "]", ",", "'hAxis'", "=>", "[", "'title'", "=>", "I18N", "::", "translate", "(", "'Century'", ")", ",", "]", ",", "'colors'", "=>", "[", "'#84beff'", "]", ",", "]", ";", "return", "view", "(", "'statistics/other/charts/column'", ",", "[", "'data'", "=>", "$", "data", ",", "'chart_options'", "=>", "$", "chart_options", ",", "'chart_title'", "=>", "$", "chart_title", ",", "]", ")", ";", "}" ]
Creates a children per family chart. @return string
[ "Creates", "a", "children", "per", "family", "chart", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Statistics/Google/ChartChildren.php#L82-L124
train
fisharebest/webtrees
app/Census/AbstractCensusColumnCondition.php
AbstractCensusColumnCondition.isChild
private function isChild(Individual $individual): bool { $age = Date::getAgeYears($individual->getEstimatedBirthDate(), $this->date()); return $age < $this->age_adult; }
php
private function isChild(Individual $individual): bool { $age = Date::getAgeYears($individual->getEstimatedBirthDate(), $this->date()); return $age < $this->age_adult; }
[ "private", "function", "isChild", "(", "Individual", "$", "individual", ")", ":", "bool", "{", "$", "age", "=", "Date", "::", "getAgeYears", "(", "$", "individual", "->", "getEstimatedBirthDate", "(", ")", ",", "$", "this", "->", "date", "(", ")", ")", ";", "return", "$", "age", "<", "$", "this", "->", "age_adult", ";", "}" ]
Is the individual a child. @param Individual $individual @return bool
[ "Is", "the", "individual", "a", "child", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Census/AbstractCensusColumnCondition.php#L101-L106
train
fisharebest/webtrees
app/Census/AbstractCensusColumnCondition.php
AbstractCensusColumnCondition.isDead
private function isDead(Individual $individual): bool { return $individual->getDeathDate()->isOK() && Date::compare($individual->getDeathDate(), $this->date()) < 0; }
php
private function isDead(Individual $individual): bool { return $individual->getDeathDate()->isOK() && Date::compare($individual->getDeathDate(), $this->date()) < 0; }
[ "private", "function", "isDead", "(", "Individual", "$", "individual", ")", ":", "bool", "{", "return", "$", "individual", "->", "getDeathDate", "(", ")", "->", "isOK", "(", ")", "&&", "Date", "::", "compare", "(", "$", "individual", "->", "getDeathDate", "(", ")", ",", "$", "this", "->", "date", "(", ")", ")", "<", "0", ";", "}" ]
Is the individual dead. @param Individual $individual @return bool
[ "Is", "the", "individual", "dead", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Census/AbstractCensusColumnCondition.php#L163-L166
train
fisharebest/webtrees
app/Date.php
Date.calendarNames
public static function calendarNames(): array { return [ /* I18N: The gregorian calendar */ 'gregorian' => I18N::translate('Gregorian'), /* I18N: The julian calendar */ 'julian' => I18N::translate('Julian'), /* I18N: The French calendar */ 'french' => I18N::translate('French'), /* I18N: The Hebrew/Jewish calendar */ 'jewish' => I18N::translate('Jewish'), /* I18N: The Arabic/Hijri calendar */ 'hijri' => I18N::translate('Hijri'), /* I18N: The Persian/Jalali calendar */ 'jalali' => I18N::translate('Jalali'), ]; }
php
public static function calendarNames(): array { return [ /* I18N: The gregorian calendar */ 'gregorian' => I18N::translate('Gregorian'), /* I18N: The julian calendar */ 'julian' => I18N::translate('Julian'), /* I18N: The French calendar */ 'french' => I18N::translate('French'), /* I18N: The Hebrew/Jewish calendar */ 'jewish' => I18N::translate('Jewish'), /* I18N: The Arabic/Hijri calendar */ 'hijri' => I18N::translate('Hijri'), /* I18N: The Persian/Jalali calendar */ 'jalali' => I18N::translate('Jalali'), ]; }
[ "public", "static", "function", "calendarNames", "(", ")", ":", "array", "{", "return", "[", "/* I18N: The gregorian calendar */", "'gregorian'", "=>", "I18N", "::", "translate", "(", "'Gregorian'", ")", ",", "/* I18N: The julian calendar */", "'julian'", "=>", "I18N", "::", "translate", "(", "'Julian'", ")", ",", "/* I18N: The French calendar */", "'french'", "=>", "I18N", "::", "translate", "(", "'French'", ")", ",", "/* I18N: The Hebrew/Jewish calendar */", "'jewish'", "=>", "I18N", "::", "translate", "(", "'Jewish'", ")", ",", "/* I18N: The Arabic/Hijri calendar */", "'hijri'", "=>", "I18N", "::", "translate", "(", "'Hijri'", ")", ",", "/* I18N: The Persian/Jalali calendar */", "'jalali'", "=>", "I18N", "::", "translate", "(", "'Jalali'", ")", ",", "]", ";", "}" ]
A list of supported calendars and their names. @return string[]
[ "A", "list", "of", "supported", "calendars", "and", "their", "names", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date.php#L221-L237
train
fisharebest/webtrees
app/Date.php
Date.addYears
public function addYears(int $years, string $qualifier = ''): Date { $tmp = clone $this; $tmp->date1->year += $years; $tmp->date1->month = 0; $tmp->date1->day = 0; $tmp->date1->setJdFromYmd(); $tmp->qual1 = $qualifier; $tmp->qual2 = ''; $tmp->date2 = null; return $tmp; }
php
public function addYears(int $years, string $qualifier = ''): Date { $tmp = clone $this; $tmp->date1->year += $years; $tmp->date1->month = 0; $tmp->date1->day = 0; $tmp->date1->setJdFromYmd(); $tmp->qual1 = $qualifier; $tmp->qual2 = ''; $tmp->date2 = null; return $tmp; }
[ "public", "function", "addYears", "(", "int", "$", "years", ",", "string", "$", "qualifier", "=", "''", ")", ":", "Date", "{", "$", "tmp", "=", "clone", "$", "this", ";", "$", "tmp", "->", "date1", "->", "year", "+=", "$", "years", ";", "$", "tmp", "->", "date1", "->", "month", "=", "0", ";", "$", "tmp", "->", "date1", "->", "day", "=", "0", ";", "$", "tmp", "->", "date1", "->", "setJdFromYmd", "(", ")", ";", "$", "tmp", "->", "qual1", "=", "$", "qualifier", ";", "$", "tmp", "->", "qual2", "=", "''", ";", "$", "tmp", "->", "date2", "=", "null", ";", "return", "$", "tmp", ";", "}" ]
Offset this date by N years, and round to the whole year. This is typically used to create an estimated death date, which is before a certain number of years after the birth date. @param int $years a number of years, positive or negative @param string $qualifier typically “BEF” or “AFT” @return Date
[ "Offset", "this", "date", "by", "N", "years", "and", "round", "to", "the", "whole", "year", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date.php#L451-L463
train
fisharebest/webtrees
app/Date.php
Date.getAge
public static function getAge(Date $d1, Date $d2 = null): string { if ($d2 instanceof self) { if ($d2->maximumJulianDay() >= $d1->minimumJulianDay() && $d2->minimumJulianDay() <= $d1->maximumJulianDay()) { // Overlapping dates $jd = $d1->minimumJulianDay(); } else { // Non-overlapping dates $jd = $d2->minimumJulianDay(); } } else { // If second date not specified, use today’s date $jd = Carbon::now()->julianDay(); } // Just years, in local digits, with warning for negative/ if ($jd && $d1->minimumJulianDay()) { if ($d1->minimumJulianDay() > $jd) { return view('icons/warning'); } $years = $d1->minimumDate()->getAge($jd); return I18N::number($years); } return ''; }
php
public static function getAge(Date $d1, Date $d2 = null): string { if ($d2 instanceof self) { if ($d2->maximumJulianDay() >= $d1->minimumJulianDay() && $d2->minimumJulianDay() <= $d1->maximumJulianDay()) { // Overlapping dates $jd = $d1->minimumJulianDay(); } else { // Non-overlapping dates $jd = $d2->minimumJulianDay(); } } else { // If second date not specified, use today’s date $jd = Carbon::now()->julianDay(); } // Just years, in local digits, with warning for negative/ if ($jd && $d1->minimumJulianDay()) { if ($d1->minimumJulianDay() > $jd) { return view('icons/warning'); } $years = $d1->minimumDate()->getAge($jd); return I18N::number($years); } return ''; }
[ "public", "static", "function", "getAge", "(", "Date", "$", "d1", ",", "Date", "$", "d2", "=", "null", ")", ":", "string", "{", "if", "(", "$", "d2", "instanceof", "self", ")", "{", "if", "(", "$", "d2", "->", "maximumJulianDay", "(", ")", ">=", "$", "d1", "->", "minimumJulianDay", "(", ")", "&&", "$", "d2", "->", "minimumJulianDay", "(", ")", "<=", "$", "d1", "->", "maximumJulianDay", "(", ")", ")", "{", "// Overlapping dates", "$", "jd", "=", "$", "d1", "->", "minimumJulianDay", "(", ")", ";", "}", "else", "{", "// Non-overlapping dates", "$", "jd", "=", "$", "d2", "->", "minimumJulianDay", "(", ")", ";", "}", "}", "else", "{", "// If second date not specified, use today’s date", "$", "jd", "=", "Carbon", "::", "now", "(", ")", "->", "julianDay", "(", ")", ";", "}", "// Just years, in local digits, with warning for negative/", "if", "(", "$", "jd", "&&", "$", "d1", "->", "minimumJulianDay", "(", ")", ")", "{", "if", "(", "$", "d1", "->", "minimumJulianDay", "(", ")", ">", "$", "jd", ")", "{", "return", "view", "(", "'icons/warning'", ")", ";", "}", "$", "years", "=", "$", "d1", "->", "minimumDate", "(", ")", "->", "getAge", "(", "$", "jd", ")", ";", "return", "I18N", "::", "number", "(", "$", "years", ")", ";", "}", "return", "''", ";", "}" ]
Calculate the the age of a person, on a date. @param Date $d1 @param Date|null $d2 @return string
[ "Calculate", "the", "the", "age", "of", "a", "person", "on", "a", "date", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date.php#L524-L551
train
fisharebest/webtrees
app/Date.php
Date.compare
public static function compare(Date $a, Date $b): int { // Get min/max JD for each date. switch ($a->qual1) { case 'BEF': $amin = $a->minimumJulianDay() - 1; $amax = $amin; break; case 'AFT': $amax = $a->maximumJulianDay() + 1; $amin = $amax; break; default: $amin = $a->minimumJulianDay(); $amax = $a->maximumJulianDay(); break; } switch ($b->qual1) { case 'BEF': $bmin = $b->minimumJulianDay() - 1; $bmax = $bmin; break; case 'AFT': $bmax = $b->maximumJulianDay() + 1; $bmin = $bmax; break; default: $bmin = $b->minimumJulianDay(); $bmax = $b->maximumJulianDay(); break; } if ($amax < $bmin) { return -1; } if ($amin > $bmax && $bmax > 0) { return 1; } if ($amin < $bmin && $amax <= $bmax) { return -1; } if ($amin > $bmin && $amax >= $bmax && $bmax > 0) { return 1; } return 0; }
php
public static function compare(Date $a, Date $b): int { // Get min/max JD for each date. switch ($a->qual1) { case 'BEF': $amin = $a->minimumJulianDay() - 1; $amax = $amin; break; case 'AFT': $amax = $a->maximumJulianDay() + 1; $amin = $amax; break; default: $amin = $a->minimumJulianDay(); $amax = $a->maximumJulianDay(); break; } switch ($b->qual1) { case 'BEF': $bmin = $b->minimumJulianDay() - 1; $bmax = $bmin; break; case 'AFT': $bmax = $b->maximumJulianDay() + 1; $bmin = $bmax; break; default: $bmin = $b->minimumJulianDay(); $bmax = $b->maximumJulianDay(); break; } if ($amax < $bmin) { return -1; } if ($amin > $bmax && $bmax > 0) { return 1; } if ($amin < $bmin && $amax <= $bmax) { return -1; } if ($amin > $bmin && $amax >= $bmax && $bmax > 0) { return 1; } return 0; }
[ "public", "static", "function", "compare", "(", "Date", "$", "a", ",", "Date", "$", "b", ")", ":", "int", "{", "// Get min/max JD for each date.", "switch", "(", "$", "a", "->", "qual1", ")", "{", "case", "'BEF'", ":", "$", "amin", "=", "$", "a", "->", "minimumJulianDay", "(", ")", "-", "1", ";", "$", "amax", "=", "$", "amin", ";", "break", ";", "case", "'AFT'", ":", "$", "amax", "=", "$", "a", "->", "maximumJulianDay", "(", ")", "+", "1", ";", "$", "amin", "=", "$", "amax", ";", "break", ";", "default", ":", "$", "amin", "=", "$", "a", "->", "minimumJulianDay", "(", ")", ";", "$", "amax", "=", "$", "a", "->", "maximumJulianDay", "(", ")", ";", "break", ";", "}", "switch", "(", "$", "b", "->", "qual1", ")", "{", "case", "'BEF'", ":", "$", "bmin", "=", "$", "b", "->", "minimumJulianDay", "(", ")", "-", "1", ";", "$", "bmax", "=", "$", "bmin", ";", "break", ";", "case", "'AFT'", ":", "$", "bmax", "=", "$", "b", "->", "maximumJulianDay", "(", ")", "+", "1", ";", "$", "bmin", "=", "$", "bmax", ";", "break", ";", "default", ":", "$", "bmin", "=", "$", "b", "->", "minimumJulianDay", "(", ")", ";", "$", "bmax", "=", "$", "b", "->", "maximumJulianDay", "(", ")", ";", "break", ";", "}", "if", "(", "$", "amax", "<", "$", "bmin", ")", "{", "return", "-", "1", ";", "}", "if", "(", "$", "amin", ">", "$", "bmax", "&&", "$", "bmax", ">", "0", ")", "{", "return", "1", ";", "}", "if", "(", "$", "amin", "<", "$", "bmin", "&&", "$", "amax", "<=", "$", "bmax", ")", "{", "return", "-", "1", ";", "}", "if", "(", "$", "amin", ">", "$", "bmin", "&&", "$", "amax", ">=", "$", "bmax", "&&", "$", "bmax", ">", "0", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}" ]
Compare two dates, so they can be sorted. return <0 if $a<$b return >0 if $b>$a return 0 if dates same/overlap BEF/AFT sort as the day before/after @param Date $a @param Date $b @return int
[ "Compare", "two", "dates", "so", "they", "can", "be", "sorted", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Date.php#L592-L640
train
fisharebest/webtrees
app/Http/Controllers/Admin/UsersController.php
UsersController.monthOptions
private function monthOptions(): array { return [ 3 => I18N::number(3), 6 => I18N::number(6), 9 => I18N::number(9), 12 => I18N::number(12), 18 => I18N::number(18), 24 => I18N::number(24), ]; }
php
private function monthOptions(): array { return [ 3 => I18N::number(3), 6 => I18N::number(6), 9 => I18N::number(9), 12 => I18N::number(12), 18 => I18N::number(18), 24 => I18N::number(24), ]; }
[ "private", "function", "monthOptions", "(", ")", ":", "array", "{", "return", "[", "3", "=>", "I18N", "::", "number", "(", "3", ")", ",", "6", "=>", "I18N", "::", "number", "(", "6", ")", ",", "9", "=>", "I18N", "::", "number", "(", "9", ")", ",", "12", "=>", "I18N", "::", "number", "(", "12", ")", ",", "18", "=>", "I18N", "::", "number", "(", "18", ")", ",", "24", "=>", "I18N", "::", "number", "(", "24", ")", ",", "]", ";", "}" ]
Delete users older than this. @return string[]
[ "Delete", "users", "older", "than", "this", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Http/Controllers/Admin/UsersController.php#L484-L494
train
fisharebest/webtrees
app/Module/ModuleListTrait.php
ModuleListTrait.listMenu
public function listMenu(Tree $tree): ?Menu { if ($this->listIsEmpty($tree)) { return null; } return new Menu( $this->listTitle(), $this->listUrl($tree), $this->listMenuClass(), $this->listUrlAttributes() ); }
php
public function listMenu(Tree $tree): ?Menu { if ($this->listIsEmpty($tree)) { return null; } return new Menu( $this->listTitle(), $this->listUrl($tree), $this->listMenuClass(), $this->listUrlAttributes() ); }
[ "public", "function", "listMenu", "(", "Tree", "$", "tree", ")", ":", "?", "Menu", "{", "if", "(", "$", "this", "->", "listIsEmpty", "(", "$", "tree", ")", ")", "{", "return", "null", ";", "}", "return", "new", "Menu", "(", "$", "this", "->", "listTitle", "(", ")", ",", "$", "this", "->", "listUrl", "(", "$", "tree", ")", ",", "$", "this", "->", "listMenuClass", "(", ")", ",", "$", "this", "->", "listUrlAttributes", "(", ")", ")", ";", "}" ]
A main menu item for this list, or null if the list is empty. @param Tree $tree @return Menu|null
[ "A", "main", "menu", "item", "for", "this", "list", "or", "null", "if", "the", "list", "is", "empty", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ModuleListTrait.php#L45-L57
train
fisharebest/webtrees
app/Module/ModuleListTrait.php
ModuleListTrait.listUrl
public function listUrl(Tree $tree, array $parameters = []): string { return route('module', [ 'module' => $this->name(), 'action' => 'List', 'ged' => $tree->name(), ] + $parameters); }
php
public function listUrl(Tree $tree, array $parameters = []): string { return route('module', [ 'module' => $this->name(), 'action' => 'List', 'ged' => $tree->name(), ] + $parameters); }
[ "public", "function", "listUrl", "(", "Tree", "$", "tree", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "string", "{", "return", "route", "(", "'module'", ",", "[", "'module'", "=>", "$", "this", "->", "name", "(", ")", ",", "'action'", "=>", "'List'", ",", "'ged'", "=>", "$", "tree", "->", "name", "(", ")", ",", "]", "+", "$", "parameters", ")", ";", "}" ]
The URL for a page showing list options. @param Tree $tree @param string[] $parameters @return string
[ "The", "URL", "for", "a", "page", "showing", "list", "options", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Module/ModuleListTrait.php#L87-L94
train
fisharebest/webtrees
app/Individual.php
Individual.birthDateComparator
public static function birthDateComparator(): Closure { return static function (Individual $x, Individual $y): int { return Date::compare($x->getEstimatedBirthDate(), $y->getEstimatedBirthDate()); }; }
php
public static function birthDateComparator(): Closure { return static function (Individual $x, Individual $y): int { return Date::compare($x->getEstimatedBirthDate(), $y->getEstimatedBirthDate()); }; }
[ "public", "static", "function", "birthDateComparator", "(", ")", ":", "Closure", "{", "return", "static", "function", "(", "Individual", "$", "x", ",", "Individual", "$", "y", ")", ":", "int", "{", "return", "Date", "::", "compare", "(", "$", "x", "->", "getEstimatedBirthDate", "(", ")", ",", "$", "y", "->", "getEstimatedBirthDate", "(", ")", ")", ";", "}", ";", "}" ]
A closure which will compare individuals by birth date. @return Closure
[ "A", "closure", "which", "will", "compare", "individuals", "by", "birth", "date", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L72-L77
train
fisharebest/webtrees
app/Individual.php
Individual.load
public static function load(Tree $tree, array $xrefs): void { $rows = DB::table('individuals') ->where('i_file', '=', $tree->id()) ->whereIn('i_id', array_unique($xrefs)) ->select(['i_id AS xref', 'i_gedcom AS gedcom']) ->get(); foreach ($rows as $row) { self::getInstance($row->xref, $tree, $row->gedcom); } }
php
public static function load(Tree $tree, array $xrefs): void { $rows = DB::table('individuals') ->where('i_file', '=', $tree->id()) ->whereIn('i_id', array_unique($xrefs)) ->select(['i_id AS xref', 'i_gedcom AS gedcom']) ->get(); foreach ($rows as $row) { self::getInstance($row->xref, $tree, $row->gedcom); } }
[ "public", "static", "function", "load", "(", "Tree", "$", "tree", ",", "array", "$", "xrefs", ")", ":", "void", "{", "$", "rows", "=", "DB", "::", "table", "(", "'individuals'", ")", "->", "where", "(", "'i_file'", ",", "'='", ",", "$", "tree", "->", "id", "(", ")", ")", "->", "whereIn", "(", "'i_id'", ",", "array_unique", "(", "$", "xrefs", ")", ")", "->", "select", "(", "[", "'i_id AS xref'", ",", "'i_gedcom AS gedcom'", "]", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "self", "::", "getInstance", "(", "$", "row", "->", "xref", ",", "$", "tree", ",", "$", "row", "->", "gedcom", ")", ";", "}", "}" ]
Sometimes, we'll know in advance that we need to load a set of records. Typically when we load families and their members. @param Tree $tree @param string[] $xrefs @return void
[ "Sometimes", "we", "ll", "know", "in", "advance", "that", "we", "need", "to", "load", "a", "set", "of", "records", ".", "Typically", "when", "we", "load", "families", "and", "their", "members", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L123-L134
train
fisharebest/webtrees
app/Individual.php
Individual.canShowName
public function canShowName(int $access_level = null): bool { if ($access_level === null) { $access_level = Auth::accessLevel($this->tree); } return $this->tree->getPreference('SHOW_LIVING_NAMES') >= $access_level || $this->canShow($access_level); }
php
public function canShowName(int $access_level = null): bool { if ($access_level === null) { $access_level = Auth::accessLevel($this->tree); } return $this->tree->getPreference('SHOW_LIVING_NAMES') >= $access_level || $this->canShow($access_level); }
[ "public", "function", "canShowName", "(", "int", "$", "access_level", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "access_level", "===", "null", ")", "{", "$", "access_level", "=", "Auth", "::", "accessLevel", "(", "$", "this", "->", "tree", ")", ";", "}", "return", "$", "this", "->", "tree", "->", "getPreference", "(", "'SHOW_LIVING_NAMES'", ")", ">=", "$", "access_level", "||", "$", "this", "->", "canShow", "(", "$", "access_level", ")", ";", "}" ]
Can the name of this record be shown? @param int|null $access_level @return bool
[ "Can", "the", "name", "of", "this", "record", "be", "shown?" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L143-L150
train
fisharebest/webtrees
app/Individual.php
Individual.canShowByType
protected function canShowByType(int $access_level): bool { // Dead people... if ($this->tree->getPreference('SHOW_DEAD_PEOPLE') >= $access_level && $this->isDead()) { $keep_alive = false; $KEEP_ALIVE_YEARS_BIRTH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_BIRTH'); if ($KEEP_ALIVE_YEARS_BIRTH) { preg_match_all('/\n1 (?:' . implode('|', Gedcom::BIRTH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $date = new Date($match[1]); if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_BIRTH > date('Y')) { $keep_alive = true; break; } } } $KEEP_ALIVE_YEARS_DEATH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_DEATH'); if ($KEEP_ALIVE_YEARS_DEATH) { preg_match_all('/\n1 (?:' . implode('|', Gedcom::DEATH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $date = new Date($match[1]); if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_DEATH > date('Y')) { $keep_alive = true; break; } } } if (!$keep_alive) { return true; } } // Consider relationship privacy (unless an admin is applying download restrictions) $user_path_length = (int) $this->tree->getUserPreference(Auth::user(), 'RELATIONSHIP_PATH_LENGTH'); $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); if ($gedcomid !== '' && $user_path_length > 0) { return self::isRelated($this, $user_path_length); } // No restriction found - show living people to members only: return Auth::PRIV_USER >= $access_level; }
php
protected function canShowByType(int $access_level): bool { // Dead people... if ($this->tree->getPreference('SHOW_DEAD_PEOPLE') >= $access_level && $this->isDead()) { $keep_alive = false; $KEEP_ALIVE_YEARS_BIRTH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_BIRTH'); if ($KEEP_ALIVE_YEARS_BIRTH) { preg_match_all('/\n1 (?:' . implode('|', Gedcom::BIRTH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $date = new Date($match[1]); if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_BIRTH > date('Y')) { $keep_alive = true; break; } } } $KEEP_ALIVE_YEARS_DEATH = (int) $this->tree->getPreference('KEEP_ALIVE_YEARS_DEATH'); if ($KEEP_ALIVE_YEARS_DEATH) { preg_match_all('/\n1 (?:' . implode('|', Gedcom::DEATH_EVENTS) . ').*(?:\n[2-9].*)*(?:\n2 DATE (.+))/', $this->gedcom, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $date = new Date($match[1]); if ($date->isOK() && $date->gregorianYear() + $KEEP_ALIVE_YEARS_DEATH > date('Y')) { $keep_alive = true; break; } } } if (!$keep_alive) { return true; } } // Consider relationship privacy (unless an admin is applying download restrictions) $user_path_length = (int) $this->tree->getUserPreference(Auth::user(), 'RELATIONSHIP_PATH_LENGTH'); $gedcomid = $this->tree->getUserPreference(Auth::user(), 'gedcomid'); if ($gedcomid !== '' && $user_path_length > 0) { return self::isRelated($this, $user_path_length); } // No restriction found - show living people to members only: return Auth::PRIV_USER >= $access_level; }
[ "protected", "function", "canShowByType", "(", "int", "$", "access_level", ")", ":", "bool", "{", "// Dead people...", "if", "(", "$", "this", "->", "tree", "->", "getPreference", "(", "'SHOW_DEAD_PEOPLE'", ")", ">=", "$", "access_level", "&&", "$", "this", "->", "isDead", "(", ")", ")", "{", "$", "keep_alive", "=", "false", ";", "$", "KEEP_ALIVE_YEARS_BIRTH", "=", "(", "int", ")", "$", "this", "->", "tree", "->", "getPreference", "(", "'KEEP_ALIVE_YEARS_BIRTH'", ")", ";", "if", "(", "$", "KEEP_ALIVE_YEARS_BIRTH", ")", "{", "preg_match_all", "(", "'/\\n1 (?:'", ".", "implode", "(", "'|'", ",", "Gedcom", "::", "BIRTH_EVENTS", ")", ".", "').*(?:\\n[2-9].*)*(?:\\n2 DATE (.+))/'", ",", "$", "this", "->", "gedcom", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "date", "=", "new", "Date", "(", "$", "match", "[", "1", "]", ")", ";", "if", "(", "$", "date", "->", "isOK", "(", ")", "&&", "$", "date", "->", "gregorianYear", "(", ")", "+", "$", "KEEP_ALIVE_YEARS_BIRTH", ">", "date", "(", "'Y'", ")", ")", "{", "$", "keep_alive", "=", "true", ";", "break", ";", "}", "}", "}", "$", "KEEP_ALIVE_YEARS_DEATH", "=", "(", "int", ")", "$", "this", "->", "tree", "->", "getPreference", "(", "'KEEP_ALIVE_YEARS_DEATH'", ")", ";", "if", "(", "$", "KEEP_ALIVE_YEARS_DEATH", ")", "{", "preg_match_all", "(", "'/\\n1 (?:'", ".", "implode", "(", "'|'", ",", "Gedcom", "::", "DEATH_EVENTS", ")", ".", "').*(?:\\n[2-9].*)*(?:\\n2 DATE (.+))/'", ",", "$", "this", "->", "gedcom", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "date", "=", "new", "Date", "(", "$", "match", "[", "1", "]", ")", ";", "if", "(", "$", "date", "->", "isOK", "(", ")", "&&", "$", "date", "->", "gregorianYear", "(", ")", "+", "$", "KEEP_ALIVE_YEARS_DEATH", ">", "date", "(", "'Y'", ")", ")", "{", "$", "keep_alive", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "!", "$", "keep_alive", ")", "{", "return", "true", ";", "}", "}", "// Consider relationship privacy (unless an admin is applying download restrictions)", "$", "user_path_length", "=", "(", "int", ")", "$", "this", "->", "tree", "->", "getUserPreference", "(", "Auth", "::", "user", "(", ")", ",", "'RELATIONSHIP_PATH_LENGTH'", ")", ";", "$", "gedcomid", "=", "$", "this", "->", "tree", "->", "getUserPreference", "(", "Auth", "::", "user", "(", ")", ",", "'gedcomid'", ")", ";", "if", "(", "$", "gedcomid", "!==", "''", "&&", "$", "user_path_length", ">", "0", ")", "{", "return", "self", "::", "isRelated", "(", "$", "this", ",", "$", "user_path_length", ")", ";", "}", "// No restriction found - show living people to members only:", "return", "Auth", "::", "PRIV_USER", ">=", "$", "access_level", ";", "}" ]
Can this individual be shown? @param int $access_level @return bool
[ "Can", "this", "individual", "be", "shown?" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L159-L199
train
fisharebest/webtrees
app/Individual.php
Individual.isRelated
private static function isRelated(Individual $target, $distance): bool { static $cache = null; $user_individual = self::getInstance($target->tree->getUserPreference(Auth::user(), 'gedcomid'), $target->tree); if ($user_individual) { if (!$cache) { $cache = [ 0 => [$user_individual], 1 => [], ]; foreach ($user_individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) { $family = $fact->target(); if ($family instanceof Family) { $cache[1][] = $family; } } } } else { // No individual linked to this account? Cannot use relationship privacy. return true; } // Double the distance, as we count the INDI-FAM and FAM-INDI links separately $distance *= 2; // Consider each path length in turn for ($n = 0; $n <= $distance; ++$n) { if (array_key_exists($n, $cache)) { // We have already calculated all records with this length if ($n % 2 === 0 && in_array($target, $cache[$n], true)) { return true; } } else { // Need to calculate these paths $cache[$n] = []; if ($n % 2 === 0) { // Add FAM->INDI links foreach ($cache[$n - 1] as $family) { foreach ($family->facts(['HUSB', 'WIFE', 'CHIL'], false, Auth::PRIV_HIDE) as $fact) { $individual = $fact->target(); // Don’t backtrack if ($individual instanceof self && !in_array($individual, $cache[$n - 2], true)) { $cache[$n][] = $individual; } } } if (in_array($target, $cache[$n], true)) { return true; } } else { // Add INDI->FAM links foreach ($cache[$n - 1] as $individual) { foreach ($individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) { $family = $fact->target(); // Don’t backtrack if ($family instanceof Family && !in_array($family, $cache[$n - 2], true)) { $cache[$n][] = $family; } } } } } } return false; }
php
private static function isRelated(Individual $target, $distance): bool { static $cache = null; $user_individual = self::getInstance($target->tree->getUserPreference(Auth::user(), 'gedcomid'), $target->tree); if ($user_individual) { if (!$cache) { $cache = [ 0 => [$user_individual], 1 => [], ]; foreach ($user_individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) { $family = $fact->target(); if ($family instanceof Family) { $cache[1][] = $family; } } } } else { // No individual linked to this account? Cannot use relationship privacy. return true; } // Double the distance, as we count the INDI-FAM and FAM-INDI links separately $distance *= 2; // Consider each path length in turn for ($n = 0; $n <= $distance; ++$n) { if (array_key_exists($n, $cache)) { // We have already calculated all records with this length if ($n % 2 === 0 && in_array($target, $cache[$n], true)) { return true; } } else { // Need to calculate these paths $cache[$n] = []; if ($n % 2 === 0) { // Add FAM->INDI links foreach ($cache[$n - 1] as $family) { foreach ($family->facts(['HUSB', 'WIFE', 'CHIL'], false, Auth::PRIV_HIDE) as $fact) { $individual = $fact->target(); // Don’t backtrack if ($individual instanceof self && !in_array($individual, $cache[$n - 2], true)) { $cache[$n][] = $individual; } } } if (in_array($target, $cache[$n], true)) { return true; } } else { // Add INDI->FAM links foreach ($cache[$n - 1] as $individual) { foreach ($individual->facts(['FAMC', 'FAMS'], false, Auth::PRIV_HIDE) as $fact) { $family = $fact->target(); // Don’t backtrack if ($family instanceof Family && !in_array($family, $cache[$n - 2], true)) { $cache[$n][] = $family; } } } } } } return false; }
[ "private", "static", "function", "isRelated", "(", "Individual", "$", "target", ",", "$", "distance", ")", ":", "bool", "{", "static", "$", "cache", "=", "null", ";", "$", "user_individual", "=", "self", "::", "getInstance", "(", "$", "target", "->", "tree", "->", "getUserPreference", "(", "Auth", "::", "user", "(", ")", ",", "'gedcomid'", ")", ",", "$", "target", "->", "tree", ")", ";", "if", "(", "$", "user_individual", ")", "{", "if", "(", "!", "$", "cache", ")", "{", "$", "cache", "=", "[", "0", "=>", "[", "$", "user_individual", "]", ",", "1", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "user_individual", "->", "facts", "(", "[", "'FAMC'", ",", "'FAMS'", "]", ",", "false", ",", "Auth", "::", "PRIV_HIDE", ")", "as", "$", "fact", ")", "{", "$", "family", "=", "$", "fact", "->", "target", "(", ")", ";", "if", "(", "$", "family", "instanceof", "Family", ")", "{", "$", "cache", "[", "1", "]", "[", "]", "=", "$", "family", ";", "}", "}", "}", "}", "else", "{", "// No individual linked to this account? Cannot use relationship privacy.", "return", "true", ";", "}", "// Double the distance, as we count the INDI-FAM and FAM-INDI links separately", "$", "distance", "*=", "2", ";", "// Consider each path length in turn", "for", "(", "$", "n", "=", "0", ";", "$", "n", "<=", "$", "distance", ";", "++", "$", "n", ")", "{", "if", "(", "array_key_exists", "(", "$", "n", ",", "$", "cache", ")", ")", "{", "// We have already calculated all records with this length", "if", "(", "$", "n", "%", "2", "===", "0", "&&", "in_array", "(", "$", "target", ",", "$", "cache", "[", "$", "n", "]", ",", "true", ")", ")", "{", "return", "true", ";", "}", "}", "else", "{", "// Need to calculate these paths", "$", "cache", "[", "$", "n", "]", "=", "[", "]", ";", "if", "(", "$", "n", "%", "2", "===", "0", ")", "{", "// Add FAM->INDI links", "foreach", "(", "$", "cache", "[", "$", "n", "-", "1", "]", "as", "$", "family", ")", "{", "foreach", "(", "$", "family", "->", "facts", "(", "[", "'HUSB'", ",", "'WIFE'", ",", "'CHIL'", "]", ",", "false", ",", "Auth", "::", "PRIV_HIDE", ")", "as", "$", "fact", ")", "{", "$", "individual", "=", "$", "fact", "->", "target", "(", ")", ";", "// Don’t backtrack", "if", "(", "$", "individual", "instanceof", "self", "&&", "!", "in_array", "(", "$", "individual", ",", "$", "cache", "[", "$", "n", "-", "2", "]", ",", "true", ")", ")", "{", "$", "cache", "[", "$", "n", "]", "[", "]", "=", "$", "individual", ";", "}", "}", "}", "if", "(", "in_array", "(", "$", "target", ",", "$", "cache", "[", "$", "n", "]", ",", "true", ")", ")", "{", "return", "true", ";", "}", "}", "else", "{", "// Add INDI->FAM links", "foreach", "(", "$", "cache", "[", "$", "n", "-", "1", "]", "as", "$", "individual", ")", "{", "foreach", "(", "$", "individual", "->", "facts", "(", "[", "'FAMC'", ",", "'FAMS'", "]", ",", "false", ",", "Auth", "::", "PRIV_HIDE", ")", "as", "$", "fact", ")", "{", "$", "family", "=", "$", "fact", "->", "target", "(", ")", ";", "// Don’t backtrack", "if", "(", "$", "family", "instanceof", "Family", "&&", "!", "in_array", "(", "$", "family", ",", "$", "cache", "[", "$", "n", "-", "2", "]", ",", "true", ")", ")", "{", "$", "cache", "[", "$", "n", "]", "[", "]", "=", "$", "family", ";", "}", "}", "}", "}", "}", "}", "return", "false", ";", "}" ]
For relationship privacy calculations - is this individual a close relative? @param Individual $target @param int $distance @return bool
[ "For", "relationship", "privacy", "calculations", "-", "is", "this", "individual", "a", "close", "relative?" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L209-L275
train
fisharebest/webtrees
app/Individual.php
Individual.findHighlightedMediaFile
public function findHighlightedMediaFile(): ?MediaFile { foreach ($this->facts(['OBJE']) as $fact) { $media = $fact->target(); if ($media instanceof Media) { foreach ($media->mediaFiles() as $media_file) { if ($media_file->isImage() && !$media_file->isExternal()) { return $media_file; } } } } return null; }
php
public function findHighlightedMediaFile(): ?MediaFile { foreach ($this->facts(['OBJE']) as $fact) { $media = $fact->target(); if ($media instanceof Media) { foreach ($media->mediaFiles() as $media_file) { if ($media_file->isImage() && !$media_file->isExternal()) { return $media_file; } } } } return null; }
[ "public", "function", "findHighlightedMediaFile", "(", ")", ":", "?", "MediaFile", "{", "foreach", "(", "$", "this", "->", "facts", "(", "[", "'OBJE'", "]", ")", "as", "$", "fact", ")", "{", "$", "media", "=", "$", "fact", "->", "target", "(", ")", ";", "if", "(", "$", "media", "instanceof", "Media", ")", "{", "foreach", "(", "$", "media", "->", "mediaFiles", "(", ")", "as", "$", "media_file", ")", "{", "if", "(", "$", "media_file", "->", "isImage", "(", ")", "&&", "!", "$", "media_file", "->", "isExternal", "(", ")", ")", "{", "return", "$", "media_file", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
Find the highlighted media object for an individual @return MediaFile|null
[ "Find", "the", "highlighted", "media", "object", "for", "an", "individual" ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L430-L444
train
fisharebest/webtrees
app/Individual.php
Individual.displayImage
public function displayImage($width, $height, $fit, $attributes): string { $media_file = $this->findHighlightedMediaFile(); if ($media_file !== null) { return $media_file->displayImage($width, $height, $fit, $attributes); } if ($this->tree->getPreference('USE_SILHOUETTE')) { return '<i class="icon-silhouette-' . $this->sex() . '"></i>'; } return ''; }
php
public function displayImage($width, $height, $fit, $attributes): string { $media_file = $this->findHighlightedMediaFile(); if ($media_file !== null) { return $media_file->displayImage($width, $height, $fit, $attributes); } if ($this->tree->getPreference('USE_SILHOUETTE')) { return '<i class="icon-silhouette-' . $this->sex() . '"></i>'; } return ''; }
[ "public", "function", "displayImage", "(", "$", "width", ",", "$", "height", ",", "$", "fit", ",", "$", "attributes", ")", ":", "string", "{", "$", "media_file", "=", "$", "this", "->", "findHighlightedMediaFile", "(", ")", ";", "if", "(", "$", "media_file", "!==", "null", ")", "{", "return", "$", "media_file", "->", "displayImage", "(", "$", "width", ",", "$", "height", ",", "$", "fit", ",", "$", "attributes", ")", ";", "}", "if", "(", "$", "this", "->", "tree", "->", "getPreference", "(", "'USE_SILHOUETTE'", ")", ")", "{", "return", "'<i class=\"icon-silhouette-'", ".", "$", "this", "->", "sex", "(", ")", ".", "'\"></i>'", ";", "}", "return", "''", ";", "}" ]
Display the prefered image for this individual. Use an icon if no image is available. @param int $width Pixels @param int $height Pixels @param string $fit "crop" or "contain" @param string[] $attributes Additional HTML attributes @return string
[ "Display", "the", "prefered", "image", "for", "this", "individual", ".", "Use", "an", "icon", "if", "no", "image", "is", "available", "." ]
840bd0d721dc479520ec24a065996bc6becb8348
https://github.com/fisharebest/webtrees/blob/840bd0d721dc479520ec24a065996bc6becb8348/app/Individual.php#L457-L470
train