idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
7,200
private function deleteFileOrFolder ( Filesystem $ filesystem , string $ path ) : bool { if ( $ filesystem -> has ( $ path ) ) { try { $ metadata = $ filesystem -> getMetadata ( $ path ) ; if ( $ metadata [ 'type' ] === 'dir' ) { $ filesystem -> deleteDir ( $ path ) ; } if ( $ metadata [ 'type' ] === 'file' ) { $ files...
Delete a file or folder if we can .
7,201
public function setWrapWidth ( float $ wrapwidth , float $ cellwidth ) : float { $ this -> wrapWidthCell = $ cellwidth ; if ( strpos ( $ this -> text , "\n" ) !== false ) { $ this -> wrapWidthRemaining = $ cellwidth ; } else { $ this -> wrapWidthRemaining = $ wrapwidth ; } return $ this -> wrapWidthRemaining ; }
Set the width for word - wrapping .
7,202
public function chartMedia ( array $ media , string $ color_from = null , string $ color_to = null ) : string { $ chart_color1 = ( string ) $ this -> theme -> parameter ( 'distribution-chart-no-values' ) ; $ chart_color2 = ( string ) $ this -> theme -> parameter ( 'distribution-chart-high-values' ) ; $ color_from = $ c...
Create a chart of media types .
7,203
public function setEmail ( $ email ) : User { if ( $ this -> email !== $ email ) { $ this -> email = $ email ; DB :: table ( 'user' ) -> where ( 'user_id' , '=' , $ this -> user_id ) -> update ( [ 'email' => $ email , ] ) ; } return $ this ; }
Set the email address of this user .
7,204
public function setRealName ( $ real_name ) : User { if ( $ this -> real_name !== $ real_name ) { $ this -> real_name = $ real_name ; DB :: table ( 'user' ) -> where ( 'user_id' , '=' , $ this -> user_id ) -> update ( [ 'real_name' => $ real_name , ] ) ; } return $ this ; }
Set the real name of this user .
7,205
public function setUserName ( $ user_name ) : self { if ( $ this -> user_name !== $ user_name ) { $ this -> user_name = $ user_name ; DB :: table ( 'user' ) -> where ( 'user_id' , '=' , $ this -> user_id ) -> update ( [ 'user_name' => $ user_name , ] ) ; } return $ this ; }
Set the login name for this user .
7,206
public function setPreference ( string $ setting_name , string $ setting_value ) : UserInterface { if ( $ this -> user_id !== 0 && $ this -> getPreference ( $ setting_name ) !== $ setting_value ) { DB :: table ( 'user_setting' ) -> updateOrInsert ( [ 'user_id' => $ this -> user_id , 'setting_name' => $ setting_name , ]...
Update a setting for the user .
7,207
public function setPassword ( string $ password ) : User { DB :: table ( 'user' ) -> where ( 'user_id' , '=' , $ this -> user_id ) -> update ( [ 'password' => password_hash ( $ password , PASSWORD_DEFAULT ) , ] ) ; return $ this ; }
Set the password of this user .
7,208
public function checkPassword ( string $ password ) : bool { $ password_hash = DB :: table ( 'user' ) -> where ( 'user_id' , '=' , $ this -> id ( ) ) -> value ( 'password' ) ; if ( $ password_hash !== null && password_verify ( $ password , $ password_hash ) ) { if ( password_needs_rehash ( $ password_hash , PASSWORD_DE...
Validate a supplied password
7,209
public static function rowMapper ( ) : Closure { return static function ( stdClass $ row ) : User { return new static ( ( int ) $ row -> user_id , $ row -> user_name , $ row -> real_name , $ row -> email ) ; } ; }
A closure which will create an object from a database row .
7,210
public function mediaList ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ module = $ request -> get ( 'module' ) ; $ action = $ request -> get ( 'action' ) ; $ formats = GedcomTag :: getFileFormTypes ( ) ; $ action2 = $ request -> get ( 'action2' ) ; $ page = ( int ) $ request -> get ( 'page'...
Show a list of all media records .
7,211
public function noteList ( Tree $ tree ) : ResponseInterface { $ notes = $ this -> allNotes ( $ tree ) ; return $ this -> viewResponse ( 'note-list-page' , [ 'notes' => $ notes , 'title' => I18N :: translate ( 'Shared notes' ) , ] ) ; }
Show a list of all note records .
7,212
public function repositoryList ( Tree $ tree ) : ResponseInterface { $ repositories = $ this -> allRepositories ( $ tree ) ; return $ this -> viewResponse ( 'repository-list-page' , [ 'repositories' => $ repositories , 'title' => I18N :: translate ( 'Repositories' ) , ] ) ; }
Show a list of all repository records .
7,213
public function sourceList ( Tree $ tree ) : ResponseInterface { $ sources = $ this -> allSources ( $ tree ) ; return $ this -> viewResponse ( 'source-list-page' , [ 'sources' => $ sources , 'title' => I18N :: translate ( 'Sources' ) , ] ) ; }
Show a list of all source records .
7,214
private function allFolders ( Tree $ tree ) : array { $ folders = DB :: table ( 'media_file' ) -> where ( 'm_file' , '=' , $ tree -> id ( ) ) -> where ( 'multimedia_file_refn' , 'NOT LIKE' , 'http:%' ) -> where ( 'multimedia_file_refn' , 'NOT LIKE' , 'https:%' ) -> where ( 'multimedia_file_refn' , 'LIKE' , '%/%' ) -> p...
Generate a list of all the folders in a current tree .
7,215
private function allMedia ( Tree $ tree , string $ folder , string $ subfolders , string $ sort , string $ filter , string $ form_type ) : array { $ query = DB :: table ( 'media' ) -> join ( 'media_file' , static function ( JoinClause $ join ) : void { $ join -> on ( 'media_file.m_file' , '=' , 'media.m_file' ) -> on (...
Generate a list of all the media objects matching the criteria in a current tree .
7,216
private function allNotes ( Tree $ tree ) : Collection { return DB :: table ( 'other' ) -> where ( 'o_file' , '=' , $ tree -> id ( ) ) -> where ( 'o_type' , '=' , 'NOTE' ) -> get ( ) -> map ( Note :: rowMapper ( ) ) -> filter ( GedcomRecord :: accessFilter ( ) ) ; }
Find all the note records in a tree .
7,217
private function allRepositories ( Tree $ tree ) : Collection { return DB :: table ( 'other' ) -> where ( 'o_file' , '=' , $ tree -> id ( ) ) -> where ( 'o_type' , '=' , 'REPO' ) -> get ( ) -> map ( Repository :: rowMapper ( ) ) -> filter ( GedcomRecord :: accessFilter ( ) ) ; }
Find all the repository record in a tree .
7,218
private function allSources ( Tree $ tree ) : Collection { return DB :: table ( 'sources' ) -> where ( 's_file' , '=' , $ tree -> id ( ) ) -> get ( ) -> map ( Source :: rowMapper ( ) ) -> filter ( GedcomRecord :: accessFilter ( ) ) ; }
Find all the source records in a tree .
7,219
private function gedcomHead ( ) : array { $ title = '' ; $ version = '' ; $ source = '' ; $ head = GedcomRecord :: getInstance ( 'HEAD' , $ this -> tree ) ; if ( $ head instanceof GedcomRecord ) { $ sour = $ head -> facts ( [ 'SOUR' ] ) -> first ( ) ; if ( $ sour instanceof Fact ) { $ source = $ sour -> value ( ) ; $ t...
Get information from the GEDCOM s HEAD record .
7,220
private function changesQuery ( ServerRequestInterface $ request ) : Builder { $ from = $ request -> getQueryParams ( ) [ 'from' ] ?? '' ; $ to = $ request -> getQueryParams ( ) [ 'to' ] ?? '' ; $ type = $ request -> getQueryParams ( ) [ 'type' ] ?? '' ; $ oldged = $ request -> getQueryParams ( ) [ 'oldged' ] ?? '' ; $...
Generate a query for filtering the changes log .
7,221
public static function getChar ( string $ text , int $ offset ) : array { if ( $ text == '' ) { return [ 'letter' => '' , 'length' => 0 , ] ; } $ char = substr ( $ text , $ offset , 1 ) ; $ length = 1 ; if ( ( ord ( $ char ) & 0xE0 ) == 0xC0 ) { $ length = 2 ; } if ( ( ord ( $ char ) & 0xF0 ) == 0xE0 ) { $ length = 3 ;...
Get the next character from an input string
7,222
public static function beginCurrentSpan ( & $ result ) : void { if ( self :: $ currentState === 'LTR' ) { $ result .= self :: START_LTR ; } if ( self :: $ currentState === 'RTL' ) { $ result .= self :: START_RTL ; } self :: $ posSpanStart = strlen ( $ result ) ; }
Begin current span
7,223
private function applyFilter ( array $ facts , string $ filterof , string $ filtersx ) : array { $ filtered = [ ] ; $ hundred_years = Carbon :: now ( ) -> subYears ( 100 ) -> julianDay ( ) ; foreach ( $ facts as $ fact ) { $ record = $ fact -> record ( ) ; if ( $ filtersx ) { if ( $ record instanceof Individual && $ fi...
Filter a list of anniversaries
7,224
private function calendarListText ( array $ list , string $ tag1 , string $ tag2 , Tree $ tree ) : string { $ html = '' ; foreach ( $ list as $ id => $ facts ) { $ tmp = GedcomRecord :: getInstance ( $ id , $ tree ) ; $ html .= $ tag1 . '<a href="' . e ( $ tmp -> url ( ) ) . '">' . $ tmp -> fullName ( ) . '</a> ' ; $ h...
Format a list of facts for display
7,225
public function icon ( Fact $ fact ) : string { $ asset = 'public/css/' . $ this -> name ( ) . '/images/facts/' . $ fact -> getTag ( ) . '.png' ; if ( file_exists ( Webtrees :: ROOT_DIR . 'public' . $ asset ) ) { return '<img src="' . e ( asset ( $ asset ) ) . '" title="' . GedcomTag :: getLabel ( $ fact -> getTag ( ) ...
Display an icon for this fact .
7,226
public function individualBoxFacts ( Individual $ individual ) : string { $ html = '' ; $ opt_tags = preg_split ( '/\W/' , $ individual -> tree ( ) -> getPreference ( 'CHART_BOX_TAGS' ) , 0 , PREG_SPLIT_NO_EMPTY ) ; foreach ( Gedcom :: BIRTH_EVENTS as $ birttag ) { if ( ! in_array ( $ birttag , $ opt_tags , true ) ) { ...
Generate the facts for display in charts .
7,227
public function individualBoxMenu ( Individual $ individual ) : array { $ menus = array_merge ( $ this -> individualBoxMenuCharts ( $ individual ) , $ this -> individualBoxMenuFamilyLinks ( $ individual ) ) ; return $ menus ; }
Links to show in chart boxes ;
7,228
public function individualBoxMenuCharts ( Individual $ individual ) : array { $ menus = [ ] ; foreach ( app ( ModuleService :: class ) -> findByComponent ( ModuleChartInterface :: class , $ individual -> tree ( ) , Auth :: user ( ) ) as $ chart ) { $ menu = $ chart -> chartBoxMenu ( $ individual ) ; if ( $ menu ) { $ m...
Chart links to show in chart boxes ;
7,229
public function individualBoxMenuFamilyLinks ( Individual $ individual ) : array { $ menus = [ ] ; foreach ( $ individual -> spouseFamilies ( ) as $ family ) { $ menus [ ] = new Menu ( '<strong>' . I18N :: translate ( 'Family with spouse' ) . '</strong>' , $ family -> url ( ) ) ; $ spouse = $ family -> spouse ( $ indiv...
Family links to show in chart boxes .
7,230
public function menuControlPanel ( Tree $ tree ) : ? Menu { if ( Auth :: isAdmin ( ) ) { return new Menu ( I18N :: translate ( 'Control panel' ) , route ( 'admin-control-panel' ) , 'menu-admin' ) ; } if ( Auth :: isManager ( $ tree ) ) { return new Menu ( I18N :: translate ( 'Control panel' ) , route ( 'admin-control-p...
Generate a menu item for the control panel .
7,231
public function menuLanguages ( ) : ? Menu { $ menu = new Menu ( I18N :: translate ( 'Language' ) , '#' , 'menu-language' ) ; foreach ( I18N :: activeLocales ( ) as $ locale ) { $ language_tag = $ locale -> languageTag ( ) ; $ class = 'menu-language-' . $ language_tag . ( WT_LOCALE === $ language_tag ? ' active' : '' )...
A menu to show a list of available languages .
7,232
public function menuMyPage ( Tree $ tree ) : Menu { return new Menu ( I18N :: translate ( 'My page' ) , route ( 'user-page' , [ 'ged' => $ tree -> name ( ) ] ) , 'menu-mypage' ) ; }
A link to the user s personal home page .
7,233
public function menuMyPages ( ? Tree $ tree ) : ? Menu { if ( $ tree instanceof Tree && Auth :: id ( ) ) { return new Menu ( I18N :: translate ( 'My pages' ) , '#' , 'menu-mymenu' , [ ] , array_filter ( [ $ this -> menuMyPage ( $ tree ) , $ this -> menuMyIndividualRecord ( $ tree ) , $ this -> menuMyPedigree ( $ tree )...
A menu for the user s personal pages .
7,234
public function menuMyPedigree ( Tree $ tree ) : ? Menu { $ gedcomid = $ tree -> getUserPreference ( Auth :: user ( ) , 'gedcomid' ) ; $ pedigree_chart = app ( ModuleService :: class ) -> findByComponent ( ModuleChartInterface :: class , $ tree , Auth :: user ( ) ) -> filter ( static function ( ModuleInterface $ module...
A link to the user s individual record .
7,235
public function menuPendingChanges ( ? Tree $ tree ) : ? Menu { if ( $ tree instanceof Tree && $ tree -> hasPendingEdit ( ) && Auth :: isModerator ( $ tree ) ) { $ url = route ( 'show-pending' , [ 'ged' => $ tree -> name ( ) , 'url' => app ( ServerRequestInterface :: class ) -> getUri ( ) , ] ) ; return new Menu ( I18N...
Create a pending changes menu .
7,236
public function menuThemes ( ) : ? Menu { $ themes = app ( ModuleService :: class ) -> findByInterface ( ModuleThemeInterface :: class , false , true ) ; $ current_theme = app ( ModuleThemeInterface :: class ) ; if ( $ themes -> count ( ) > 1 ) { $ submenus = $ themes -> map ( static function ( ModuleThemeInterface $ t...
Themes menu .
7,237
public function genealogyMenuContent ( array $ menus ) : string { return implode ( '' , array_map ( static function ( Menu $ menu ) : string { return $ menu -> bootstrap4 ( ) ; } , $ menus ) ) ; }
Create the genealogy menu .
7,238
public function userMenu ( ? Tree $ tree ) : array { return array_filter ( [ $ this -> menuPendingChanges ( $ tree ) , $ this -> menuMyPages ( $ tree ) , $ this -> menuThemes ( ) , $ this -> menuLanguages ( ) , $ this -> menuLogin ( ) , $ this -> menuLogout ( ) , ] ) ; }
Generate a list of items for the user menu .
7,239
public static function formatText ( string $ text , Tree $ tree ) : string { switch ( $ tree -> getPreference ( 'FORMAT_TEXT' ) ) { case 'markdown' : return '<div class="markdown" dir="auto">' . self :: markdown ( $ text , $ tree ) . '</div>' ; default : return '<div class="markdown" style="white-space: pre-wrap;" dir=...
Format block - level text such as notes or transcripts etc .
7,240
public static function expandUrls ( string $ text , Tree $ tree ) : string { $ text = preg_replace ( '/' . addcslashes ( self :: URL_REGEX , '/' ) . '/' , '<$0>' , $ text ) ; $ environment = new Environment ( ) ; $ environment -> mergeConfig ( [ 'renderer' => [ 'block_separator' => "\n" , 'inner_separator' => "\n" , 's...
Format a block of text expanding URLs and XREFs .
7,241
public static function markdown ( string $ text , Tree $ tree ) : string { $ environment = Environment :: createCommonMarkEnvironment ( ) ; $ environment -> mergeConfig ( [ 'html_input' => 'escape' ] ) ; $ environment -> addExtension ( new TableExtension ( ) ) ; $ environment -> addExtension ( new CensusTableExtension ...
Format a block of text using Markdown .
7,242
public function addText ( string $ t ) { $ t = trim ( $ t , "\r\n\t" ) ; $ t = str_replace ( [ '<br>' , '&nbsp;' , ] , [ "\n" , ' ' , ] , $ t ) ; $ t = strip_tags ( $ t ) ; $ t = htmlspecialchars_decode ( $ t ) ; $ this -> text .= $ t ; }
Add text .
7,243
public function findByInterface ( string $ interface , $ include_disabled = false , $ sort = false ) : Collection { $ modules = $ this -> all ( $ include_disabled ) -> filter ( $ this -> interfaceFilter ( $ interface ) ) ; switch ( $ interface ) { case ModuleFooterInterface :: class : return $ modules -> sort ( $ this ...
All modules which provide a specific function .
7,244
public function all ( bool $ include_disabled = false ) : Collection { return app ( 'cache.array' ) -> rememberForever ( 'all_modules' , function ( ) : Collection { $ module_info = DB :: table ( 'module' ) -> get ( ) -> mapWithKeys ( static function ( stdClass $ row ) : array { return [ $ row -> module_name => $ row ] ...
All modules .
7,245
private function coreModules ( ) : Collection { return Collection :: make ( self :: CORE_MODULES ) -> map ( static function ( string $ class , string $ name ) : ModuleInterface { $ module = app ( $ class ) ; $ module -> setName ( $ name ) ; return $ module ; } ) ; }
All core modules in the system .
7,246
public function setupLanguages ( ) : Collection { return $ this -> coreModules ( ) -> filter ( static function ( ModuleInterface $ module ) { return $ module instanceof ModuleLanguageInterface && $ module -> isEnabledByDefault ( ) ; } ) -> sort ( static function ( ModuleLanguageInterface $ x , ModuleLanguageInterface $...
During setup we ll need access to some languages .
7,247
private function footerSorter ( ) : Closure { return static function ( ModuleFooterInterface $ x , ModuleFooterInterface $ y ) : int { return $ x -> getFooterOrder ( ) <=> $ y -> getFooterOrder ( ) ; } ; }
A function to sort footers
7,248
private function moduleSorter ( ) : Closure { return static function ( ModuleInterface $ x , ModuleInterface $ y ) : int { $ title1 = $ x instanceof ModuleLanguageInterface ? $ x -> locale ( ) -> endonymSortable ( ) : $ x -> title ( ) ; $ title2 = $ y instanceof ModuleLanguageInterface ? $ y -> locale ( ) -> endonymSor...
A function to sort modules by name .
7,249
public function findByName ( string $ module_name , bool $ include_disabled = false ) : ? ModuleInterface { return $ this -> all ( $ include_disabled ) -> first ( static function ( ModuleInterface $ module ) use ( $ module_name ) : bool { return $ module -> name ( ) === $ module_name ; } ) ; }
Find a specified module if it is currently active .
7,250
public function otherModules ( bool $ include_disabled = false ) : Collection { return $ this -> findByInterface ( ModuleInterface :: class , $ include_disabled , true ) -> filter ( static function ( ModuleInterface $ module ) : bool { foreach ( self :: COMPONENTS as $ interface ) { if ( $ module instanceof $ interface...
Configuration settings are available through the various module component pages . For modules that do not provide a component we need to list them separately .
7,251
public function deletedModules ( ) : Collection { $ database_modules = DB :: table ( 'module' ) -> pluck ( 'module_name' ) ; $ disk_modules = $ this -> all ( true ) -> map ( static function ( ModuleInterface $ module ) : string { return $ module -> name ( ) ; } ) ; return $ database_modules -> diff ( $ disk_modules ) ;...
Generate a list of module names which exist in the database but not on disk .
7,252
public static function regenerate ( bool $ destroy = false ) : void { if ( $ destroy ) { self :: clear ( ) ; } if ( session_status ( ) === PHP_SESSION_ACTIVE ) { session_regenerate_id ( $ destroy ) ; } }
After any change in authentication level we should use a new session ID .
7,253
public static function getCsrfToken ( ) : string { if ( ! self :: has ( 'CSRF_TOKEN' ) ) { self :: put ( 'CSRF_TOKEN' , Str :: random ( 32 ) ) ; } return self :: get ( 'CSRF_TOKEN' ) ; }
Cross - Site Request Forgery tokens - ensure that the user is submitting a form that was generated by the current session .
7,254
private function checkLinkMessage ( Tree $ tree , $ type1 , $ xref1 , $ type2 , $ xref2 ) : string { return I18N :: translate ( '%1$s %2$s has a %3$s link to %4$s.' , $ this -> formatType ( $ type1 ) , $ this -> checkLink ( $ tree , $ xref1 ) , $ this -> formatType ( $ type2 ) , $ this -> checkLink ( $ tree , $ xref2 )...
Create a message linking one record to another .
7,255
private function checkLink ( Tree $ tree , string $ xref ) : string { return '<b><a href="' . e ( route ( 'record' , [ 'xref' => $ xref , 'ged' => $ tree -> name ( ) , ] ) ) . '">' . $ xref . '</a></b>' ; }
Format a link to a record .
7,256
private function countCommonXrefs ( Tree $ tree1 , Tree $ tree2 ) : int { $ subquery1 = DB :: table ( 'individuals' ) -> where ( 'i_file' , '=' , $ tree1 -> id ( ) ) -> select ( [ 'i_id AS xref' ] ) -> union ( DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ tree1 -> id ( ) ) -> select ( [ 'f_id AS xref' ] ) ) ...
Count of XREFs used by two trees at the same time .
7,257
private function duplicateXrefs ( Tree $ tree ) : array { $ subquery1 = DB :: table ( 'individuals' ) -> where ( 'i_file' , '=' , $ tree -> id ( ) ) -> select ( [ 'i_id AS xref' , DB :: raw ( "'INDI' AS type" ) ] ) -> union ( DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ tree -> id ( ) ) -> select ( [ 'f_id ...
Every XREF used by this tree and also used by some other tree
7,258
private function gedcomFiles ( string $ folder ) : array { $ d = opendir ( $ folder ) ; $ files = [ ] ; while ( ( $ f = readdir ( $ d ) ) !== false ) { if ( ! is_dir ( WT_DATA_DIR . $ f ) && is_readable ( WT_DATA_DIR . $ f ) ) { $ fp = fopen ( WT_DATA_DIR . $ f , 'rb' ) ; $ header = fread ( $ fp , 64 ) ; fclose ( $ fp ...
Find a list of GEDCOM files in a folder
7,259
private function generateNewTreeName ( ) : string { $ tree_name = 'tree' ; $ tree_number = 1 ; $ existing_trees = Tree :: getNameList ( ) ; while ( array_key_exists ( $ tree_name . $ tree_number , $ existing_trees ) ) { $ tree_number ++ ; } return $ tree_name . $ tree_number ; }
Generate a unqiue name for new trees
7,260
public function treePageBlockUpdate ( ServerRequestInterface $ request , Tree $ tree , UserInterface $ user ) : ResponseInterface { $ block = $ this -> treeBlock ( $ request , $ tree , $ user ) ; $ block_id = ( int ) $ request -> get ( 'block_id' ) ; $ block -> saveBlockConfiguration ( $ request , $ block_id ) ; return...
Update block config options .
7,261
private function treeBlock ( ServerRequestInterface $ request , Tree $ tree , UserInterface $ user ) : ModuleBlockInterface { $ block_id = ( int ) $ request -> get ( 'block_id' ) ; $ block = DB :: table ( 'block' ) -> where ( 'block_id' , '=' , $ block_id ) -> where ( 'gedcom_id' , '=' , $ tree -> id ( ) ) -> whereNull...
Load a block and check we have permission to edit it .
7,262
public function treePage ( Tree $ tree ) : ResponseInterface { $ has_blocks = DB :: table ( 'block' ) -> where ( 'gedcom_id' , '=' , $ tree -> id ( ) ) -> exists ( ) ; if ( ! $ has_blocks ) { $ this -> checkDefaultTreeBlocksExist ( ) ; ( new Builder ( DB :: connection ( ) ) ) -> from ( 'block' ) -> insertUsing ( [ 'ged...
Show a tree s page .
7,263
public function treePageBlock ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ block_id = $ request -> get ( 'block_id' ) ; $ block_id = ( int ) DB :: table ( 'block' ) -> where ( 'block_id' , '=' , $ block_id ) -> where ( 'gedcom_id' , '=' , $ tree -> id ( ) ) -> value ( 'block_id' ) ; $ modu...
Load block asynchronously .
7,264
public function treePageDefaultEdit ( ) : ResponseInterface { $ this -> checkDefaultTreeBlocksExist ( ) ; $ main_blocks = $ this -> treeBlocks ( - 1 , 'main' ) ; $ side_blocks = $ this -> treeBlocks ( - 1 , 'side' ) ; $ all_blocks = $ this -> availableTreeBlocks ( ) ; $ title = I18N :: translate ( 'Set the default bloc...
Show a form to edit the default blocks for new trees .
7,265
public function treePageDefaultUpdate ( ServerRequestInterface $ request ) : ResponseInterface { $ main_blocks = ( array ) $ request -> get ( 'main' ) ; $ side_blocks = ( array ) $ request -> get ( 'side' ) ; $ this -> updateTreeBlocks ( - 1 , $ main_blocks , $ side_blocks ) ; return redirect ( route ( 'admin-control-p...
Save updated default blocks for new trees .
7,266
public function treePageUpdate ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ defaults = ( bool ) $ request -> get ( 'defaults' ) ; if ( $ defaults ) { $ main_blocks = $ this -> treeBlocks ( - 1 , 'main' ) -> all ( ) ; $ side_blocks = $ this -> treeBlocks ( - 1 , 'side' ) -> all ( ) ; } else...
Save updated blocks on a tree s page .
7,267
public function userPage ( UserInterface $ user ) : ResponseInterface { $ has_blocks = DB :: table ( 'block' ) -> where ( 'user_id' , '=' , $ user -> id ( ) ) -> exists ( ) ; if ( ! $ has_blocks ) { $ this -> checkDefaultUserBlocksExist ( ) ; ( new Builder ( DB :: connection ( ) ) ) -> from ( 'block' ) -> insertUsing (...
Show a users s page .
7,268
public function userPageDefaultEdit ( ) : ResponseInterface { $ this -> checkDefaultUserBlocksExist ( ) ; $ main_blocks = $ this -> userBlocks ( - 1 , 'main' ) ; $ side_blocks = $ this -> userBlocks ( - 1 , 'side' ) ; $ all_blocks = $ this -> availableUserBlocks ( ) ; $ title = I18N :: translate ( 'Set the default bloc...
Show a form to edit the default blocks for new uesrs .
7,269
public function userPageDefaultUpdate ( ServerRequestInterface $ request ) : ResponseInterface { $ main_blocks = ( array ) $ request -> get ( 'main' ) ; $ side_blocks = ( array ) $ request -> get ( 'side' ) ; $ this -> updateUserBlocks ( - 1 , $ main_blocks , $ side_blocks ) ; return redirect ( route ( 'admin-control-p...
Save the updated default blocks for new users .
7,270
public function userPageUpdate ( ServerRequestInterface $ request , Tree $ tree , UserInterface $ user ) : ResponseInterface { $ defaults = ( bool ) $ request -> get ( 'defaults' ) ; if ( $ defaults ) { $ main_blocks = $ this -> userBlocks ( - 1 , 'main' ) -> all ( ) ; $ side_blocks = $ this -> userBlocks ( - 1 , 'side...
Save the updted blocks on a user s page .
7,271
public function userPageUserUpdate ( ServerRequestInterface $ request ) : ResponseInterface { $ user_id = ( int ) $ request -> get ( 'user_id' ) ; $ main_blocks = ( array ) $ request -> get ( 'main' ) ; $ side_blocks = ( array ) $ request -> get ( 'side' ) ; $ this -> updateUserBlocks ( $ user_id , $ main_blocks , $ si...
Save the updated blocks for another user s page .
7,272
private function getBlockModule ( Tree $ tree , int $ block_id ) : ModuleBlockInterface { $ active_blocks = $ this -> module_service -> findByComponent ( ModuleBlockInterface :: class , $ tree , Auth :: user ( ) ) ; $ module_name = DB :: table ( 'block' ) -> where ( 'block_id' , '=' , $ block_id ) -> value ( 'module_na...
Get a specific block .
7,273
private function availableTreeBlocks ( ) : Collection { return $ this -> module_service -> findByInterface ( ModuleBlockInterface :: class , false , true ) -> filter ( static function ( ModuleBlockInterface $ block ) : bool { return $ block -> isTreeBlock ( ) ; } ) -> mapWithKeys ( static function ( ModuleInterface $ b...
Get all the available blocks for a tree page .
7,274
private function availableUserBlocks ( ) : Collection { return $ this -> module_service -> findByInterface ( ModuleBlockInterface :: class , false , true ) -> filter ( static function ( ModuleBlockInterface $ block ) : bool { return $ block -> isUserBlock ( ) ; } ) -> mapWithKeys ( static function ( ModuleInterface $ b...
Get all the available blocks for a user page .
7,275
private function treeBlocks ( int $ tree_id , string $ location ) : Collection { $ rows = DB :: table ( 'block' ) -> where ( 'gedcom_id' , '=' , $ tree_id ) -> where ( 'location' , '=' , $ location ) -> orderBy ( 'block_order' ) -> pluck ( 'module_name' , 'block_id' ) ; return $ this -> filterActiveBlocks ( $ rows , $ ...
Get the blocks for a specified tree .
7,276
private function checkDefaultTreeBlocksExist ( ) : void { $ has_blocks = DB :: table ( 'block' ) -> where ( 'gedcom_id' , '=' , - 1 ) -> exists ( ) ; if ( ! $ has_blocks ) { foreach ( [ 'main' , 'side' ] as $ location ) { foreach ( self :: DEFAULT_TREE_PAGE_BLOCKS [ $ location ] as $ block_order => $ class ) { $ module...
Make sure that default blocks exist for a tree .
7,277
private function userBlocks ( int $ user_id , string $ location ) : Collection { $ rows = DB :: table ( 'block' ) -> where ( 'user_id' , '=' , $ user_id ) -> where ( 'location' , '=' , $ location ) -> orderBy ( 'block_order' ) -> pluck ( 'module_name' , 'block_id' ) ; return $ this -> filterActiveBlocks ( $ rows , $ th...
Get the blocks for a specified user .
7,278
private function updateUserBlocks ( int $ user_id , array $ main_blocks , array $ side_blocks ) : void { $ existing_block_ids = DB :: table ( 'block' ) -> where ( 'user_id' , '=' , $ user_id ) -> pluck ( 'block_id' ) ; foreach ( $ existing_block_ids as $ existing_block_id ) { if ( ! in_array ( $ existing_block_id , $ m...
Save the updated blocks for a user .
7,279
public function render ( $ renderer , $ sub = false ) { if ( ! empty ( $ this -> attrs [ 'style' ] ) ) { $ renderer -> setCurrentStyle ( $ this -> attrs [ 'style' ] ) ; } if ( ! empty ( $ this -> attrs [ 'width' ] ) ) { $ this -> attrs [ 'width' ] *= 3.9 ; } $ this -> text = $ this -> getStart ( ) . $ this -> text ; fo...
Render the output .
7,280
private function familyQuery ( string $ type ) : string { $ row = DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> orderBy ( 'f_numchil' , 'desc' ) -> first ( ) ; if ( $ row === null ) { return '' ; } $ family = Family :: rowMapper ( ) ( $ row ) ; if ( ! $ family -> canShow ( ) ) { r...
General query on family .
7,281
private function topTenGrandFamilyQuery ( int $ total ) : array { return DB :: table ( 'families' ) -> join ( 'link AS children' , static function ( JoinClause $ join ) : void { $ join -> on ( 'children.l_from' , '=' , 'f_id' ) -> on ( 'children.l_file' , '=' , 'f_file' ) -> where ( 'children.l_type' , '=' , 'CHIL' ) ;...
Find the couple with the most grandchildren .
7,282
private function ageBetweenSiblingsQuery ( int $ total ) : array { $ prefix = DB :: connection ( ) -> getTablePrefix ( ) ; return DB :: table ( 'link AS link1' ) -> join ( 'link AS link2' , static function ( JoinClause $ join ) : void { $ join -> on ( 'link2.l_from' , '=' , 'link1.l_from' ) -> on ( 'link2.l_type' , '='...
Returns the ages between siblings .
7,283
private function calculateAge ( int $ age ) : string { if ( ( int ) ( $ age / 365.25 ) > 0 ) { $ result = ( int ) ( $ age / 365.25 ) . 'y' ; } elseif ( ( int ) ( $ age / 30.4375 ) > 0 ) { $ result = ( int ) ( $ age / 30.4375 ) . 'm' ; } else { $ result = $ age . 'd' ; } return FunctionsDate :: getAgeAtEvent ( $ result ...
Returns the calculated age the time of event .
7,284
public function topAgeBetweenSiblingsFullName ( int $ total = 10 ) : string { $ record = $ this -> ageBetweenSiblingsNoList ( $ total ) ; if ( empty ( $ record ) ) { return I18N :: translate ( 'This information is not available.' ) ; } return view ( 'statistics/families/top10-nolist-age' , [ 'record' => $ record , ] ) ...
Find the name of siblings with the widest age gap .
7,285
public function topAgeBetweenSiblingsList ( int $ total = 10 , string $ one = '' ) : string { $ records = $ this -> ageBetweenSiblingsList ( $ total , ( bool ) $ one ) ; return view ( 'statistics/families/top10-list-age' , [ 'records' => $ records , ] ) ; }
Find the siblings with the widest age gaps .
7,286
public function totalChildren ( ) : string { $ total = ( int ) DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> sum ( 'f_numchil' ) ; return I18N :: number ( $ total ) ; }
Count the total children .
7,287
public function averageChildren ( ) : string { $ average = ( float ) DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> avg ( 'f_numchil' ) ; return I18N :: number ( $ average , 2 ) ; }
Find the average number of children in families .
7,288
private function topTenFamilyQuery ( int $ total ) : array { return DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> orderBy ( 'f_numchil' , 'DESC' ) -> limit ( $ total ) -> get ( ) -> map ( Family :: rowMapper ( ) ) -> filter ( GedcomRecord :: accessFilter ( ) ) -> map ( static func...
General query on families .
7,289
public function topTenLargestFamily ( int $ total = 10 ) : string { $ records = $ this -> topTenFamilyQuery ( $ total ) ; return view ( 'statistics/families/top10-nolist' , [ 'records' => $ records , ] ) ; }
The the families with the most children .
7,290
public function topTenLargestFamilyList ( int $ total = 10 ) : string { $ records = $ this -> topTenFamilyQuery ( $ total ) ; return view ( 'statistics/families/top10-list' , [ 'records' => $ records , ] ) ; }
Find the families with the most children .
7,291
public function totalMarriedMales ( ) : string { $ n = ( int ) DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> where ( 'f_gedcom' , 'LIKE' , "%\n1 MARR%" ) -> distinct ( ) -> count ( 'f_husb' ) ; return I18N :: number ( $ n ) ; }
Number of husbands .
7,292
private function ageBetweenSpousesQuery ( string $ age_dir , int $ total ) : array { $ prefix = DB :: connection ( ) -> getTablePrefix ( ) ; $ query = DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> tree -> id ( ) ) -> join ( 'dates AS wife' , static function ( JoinClause $ join ) : void { $ join -> on...
Find the ages between spouses .
7,293
public function statsDiv ( string $ color_from = null , string $ color_to = null ) : string { return ( new ChartDivorce ( $ this -> tree ) ) -> chartDivorce ( $ color_from , $ color_to ) ; }
General divorce query .
7,294
public function bootstrap4 ( ) : string { if ( ! empty ( $ this -> submenus ) ) { $ submenus = '' ; foreach ( $ this -> submenus as $ submenu ) { $ attrs = '' ; foreach ( $ submenu -> attrs as $ key => $ value ) { $ attrs .= ' ' . $ key . '="' . e ( $ value ) . '"' ; } $ class = trim ( 'dropdown-item ' . $ submenu -> c...
Render this menu using Bootstrap4 markup
7,295
public function chartUrl ( Individual $ individual , array $ parameters = [ ] ) : string { return route ( 'module' , [ 'module' => $ this -> name ( ) , 'action' => 'Chart' , 'xrefs[]' => $ individual -> xref ( ) , 'ged' => $ individual -> tree ( ) -> name ( ) , ] + $ parameters ) ; }
The URL for this chart .
7,296
protected function maxYear ( array $ individuals ) : int { $ jd = array_reduce ( $ individuals , static function ( $ carry , Individual $ item ) { return max ( $ carry , $ item -> getEstimatedDeathDate ( ) -> maximumJulianDay ( ) ) ; } , 0 ) ; $ year = $ this -> jdToYear ( $ jd ) ; return min ( $ year , ( int ) date ( ...
Find the latest event year for individuals
7,297
protected function minYear ( array $ individuals ) : int { $ jd = array_reduce ( $ individuals , static function ( $ carry , Individual $ item ) { return min ( $ carry , $ item -> getEstimatedBirthDate ( ) -> minimumJulianDay ( ) ) ; } , PHP_INT_MAX ) ; return $ this -> jdToYear ( $ jd ) ; }
Find the earliest event year for individuals
7,298
protected function jdToYear ( int $ jd ) : int { if ( $ jd === 0 ) { return 0 ; } $ gregorian = new GregorianCalendar ( ) ; [ $ y ] = $ gregorian -> jdToYmd ( $ jd ) ; return $ y ; }
Convert a julian day to a gregorian year
7,299
protected function closeFamily ( Individual $ individual ) : array { $ xrefs = [ ] ; foreach ( $ individual -> spouseFamilies ( ) as $ family ) { foreach ( $ family -> children ( ) as $ child ) { $ xrefs [ ] = $ child -> xref ( ) ; } foreach ( $ family -> spouses ( ) as $ spouse ) { $ xrefs [ ] = $ spouse -> xref ( ) ;...
Find the close family members of an individual .