idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
7,000
public function getBirthDate ( ) : Date { foreach ( $ this -> getAllBirthDates ( ) as $ date ) { if ( $ date -> isOK ( ) ) { return $ date ; } } return new Date ( '' ) ; }
Get the date of birth
7,001
public function getBirthPlace ( ) : Place { foreach ( $ this -> getAllBirthPlaces ( ) as $ place ) { return $ place ; } return new Place ( '' , $ this -> tree ) ; }
Get the place of birth
7,002
public function getDeathDate ( ) : Date { foreach ( $ this -> getAllDeathDates ( ) as $ date ) { if ( $ date -> isOK ( ) ) { return $ date ; } } return new Date ( '' ) ; }
Get the date of death
7,003
public function getDeathPlace ( ) : Place { foreach ( $ this -> getAllDeathPlaces ( ) as $ place ) { return $ place ; } return new Place ( '' , $ this -> tree ) ; }
Get the place of death
7,004
public function getAllBirthDates ( ) : array { foreach ( Gedcom :: BIRTH_EVENTS as $ event ) { $ tmp = $ this -> getAllEventDates ( [ $ event ] ) ; if ( $ tmp ) { return $ tmp ; } } return [ ] ; }
Get all the birth dates - for the individual lists .
7,005
public function getAllBirthPlaces ( ) : array { foreach ( Gedcom :: BIRTH_EVENTS as $ event ) { $ places = $ this -> getAllEventPlaces ( [ $ event ] ) ; if ( ! empty ( $ places ) ) { return $ places ; } } return [ ] ; }
Gat all the birth places - for the individual lists .
7,006
public function getAllDeathDates ( ) : array { foreach ( Gedcom :: DEATH_EVENTS as $ event ) { $ tmp = $ this -> getAllEventDates ( [ $ event ] ) ; if ( $ tmp ) { return $ tmp ; } } return [ ] ; }
Get all the death dates - for the individual lists .
7,007
public function getAllDeathPlaces ( ) : array { foreach ( Gedcom :: DEATH_EVENTS as $ event ) { $ places = $ this -> getAllEventPlaces ( [ $ event ] ) ; if ( ! empty ( $ places ) ) { return $ places ; } } return [ ] ; }
Get all the death places - for the individual lists .
7,008
public function getEstimatedDeathDate ( ) : Date { if ( $ this -> estimated_death_date === null ) { foreach ( $ this -> getAllDeathDates ( ) as $ date ) { if ( $ date -> isOK ( ) ) { $ this -> estimated_death_date = $ date ; break ; } } if ( $ this -> estimated_death_date === null ) { if ( $ this -> getEstimatedBirthDa...
Generate an estimated date of death .
7,009
public function getCurrentSpouse ( ) : ? Individual { $ family = $ this -> spouseFamilies ( ) -> last ( ) ; if ( $ family instanceof Family ) { return $ family -> spouse ( $ this ) ; } return null ; }
Get the current spouse of this individual .
7,010
public function numberOfChildren ( ) : int { if ( preg_match ( '/\n1 NCHI (\d+)(?:\n|$)/' , $ this -> gedcom ( ) , $ match ) ) { return ( int ) $ match [ 1 ] ; } $ children = [ ] ; foreach ( $ this -> spouseFamilies ( ) as $ fam ) { foreach ( $ fam -> children ( ) as $ child ) { $ children [ $ child -> xref ( ) ] = tru...
Count the children belonging to this individual .
7,011
public function primaryChildFamily ( ) : ? Family { $ families = $ this -> childFamilies ( ) ; switch ( $ families -> count ( ) ) { case 0 : return null ; case 1 : return $ families [ 0 ] ; default : foreach ( $ families as $ fam ) { $ famid = $ fam -> xref ( ) ; if ( preg_match ( "/\n1 FAMC @{$famid}@\n(?:[2-9].*\n)*(...
Get the preferred parents for this individual .
7,012
public function getSpouseFamilyLabel ( Family $ family ) : string { $ spouse = $ family -> spouse ( $ this ) ; if ( $ spouse ) { return I18N :: translate ( 'Family with %s' , $ spouse -> fullName ( ) ) ; } return $ family -> fullName ( ) ; }
Get the description for the family .
7,013
public function getPrimaryParentsNames ( $ classname = '' , $ display = '' ) : string { $ fam = $ this -> primaryChildFamily ( ) ; if ( ! $ fam ) { return '' ; } $ txt = '<div' ; if ( $ classname ) { $ txt .= ' class="' . $ classname . '"' ; } if ( $ display ) { $ txt .= ' style="display:' . $ display . '"' ; } $ txt ....
get primary parents names for this individual
7,014
public function formatListDetails ( ) : string { return $ this -> formatFirstMajorFact ( Gedcom :: BIRTH_EVENTS , 1 ) . $ this -> formatFirstMajorFact ( Gedcom :: DEATH_EVENTS , 1 ) ; }
Extra info to display when displaying this record in a list of selection items or favorites .
7,015
protected function allAncestors ( Individual $ individual ) : array { $ ancestors = [ 1 => $ individual , ] ; do { $ sosa = key ( $ ancestors ) ; $ family = $ ancestors [ $ sosa ] -> primaryChildFamily ( ) ; if ( $ family !== null ) { if ( $ family -> husband ( ) !== null ) { $ ancestors [ $ sosa * 2 ] = $ family -> hu...
Find all ancestors of an individual indexed by the Sosa - Stradonitz number .
7,016
private function loadIndividuals ( Tree $ tree , string $ surname , bool $ soundex_dm , bool $ soundex_std ) : array { $ individuals = DB :: table ( 'individuals' ) -> join ( 'name' , static function ( JoinClause $ join ) : void { $ join -> on ( 'name.n_file' , '=' , 'individuals.i_file' ) -> on ( 'name.n_id' , '=' , '...
Fetch all individuals with a matching surname
7,017
public function getPatriarchsHtml ( Tree $ tree , array $ individuals , array $ ancestors , string $ surname , bool $ soundex_dm , bool $ soundex_std ) : string { $ html = '' ; foreach ( $ individuals as $ individual ) { foreach ( $ individual -> childFamilies ( ) as $ family ) { foreach ( $ family -> spouses ( ) as $ ...
For each individual with no ancestors list their descendants .
7,018
public function historicEventsForIndividual ( Individual $ individual ) : Collection { $ min_date = $ individual -> getEstimatedBirthDate ( ) ; $ max_date = $ individual -> getEstimatedDeathDate ( ) ; return ( new Collection ( $ this -> historicEventsAll ( ) ) ) -> map ( static function ( string $ gedcom ) use ( $ indi...
Which events should we show for an individual?
7,019
private function hitCountQuery ( $ page_name , string $ page_parameter = '' ) : string { if ( $ page_name === '' ) { $ page_name = 'index.php' ; $ page_parameter = 'gedcom:' . $ this -> tree -> id ( ) ; } elseif ( $ page_name === 'index.php' ) { $ user = $ this -> user_service -> findByIdentifier ( $ page_parameter ) ;...
These functions provide access to hitcounter for use in the HTML block .
7,020
private function getPlaceListLocation ( int $ id ) : array { if ( $ id === 0 ) { $ fqpn = '' ; } else { $ hierarchy = $ this -> getHierarchy ( $ id ) ; $ fqpn = ', ' . $ hierarchy [ 0 ] -> fqpn ; } $ rows = DB :: table ( 'placelocation' ) -> where ( 'pl_parent_id' , '=' , $ id ) -> orderBy ( 'pl_place' ) -> get ( ) ; $...
Find all of the places in the hierarchy
7,021
private function childLocationStatus ( int $ parent_id ) : stdClass { $ prefix = DB :: connection ( ) -> getTablePrefix ( ) ; $ expression = $ prefix . 'p0.pl_place IS NOT NULL AND ' . $ prefix . 'p0.pl_lati IS NULL OR ' . $ prefix . 'p1.pl_place IS NOT NULL AND ' . $ prefix . 'p1.pl_lati IS NULL OR ' . $ prefix . 'p2....
How many children does place have? How many have co - ordinates?
7,022
private function isLocationActive ( string $ place_name ) : bool { $ places = explode ( Gedcom :: PLACE_SEPARATOR , $ place_name ) ; $ query = DB :: table ( 'places AS p0' ) -> where ( 'p0.p_place' , '=' , $ places [ 0 ] ) -> select ( [ 'pl0.*' ] ) ; array_shift ( $ places ) ; foreach ( $ places as $ n => $ place ) { $...
Is a place name used in any tree?
7,023
public function createServerRequest ( ) : ServerRequestInterface { $ server_request_creator = new ServerRequestCreator ( app ( ServerRequestFactoryInterface :: class ) , app ( UriFactoryInterface :: class ) , app ( UploadedFileFactoryInterface :: class ) , app ( StreamFactoryInterface :: class ) ) ; if ( class_exists (...
We can use any PSR - 7 compatible requests .
7,024
public function middleware ( ) : array { return [ PhpEnvironment :: class , EmitResponse :: class , HandleExceptions :: class , ReadConfigIni :: class , UseDatabase :: class , UseDebugbar :: class , UpdateDatabaseSchema :: class , UseCache :: class , UseFilesystem :: class , UseSession :: class , UseTree :: class , Use...
The webtrees application is built from middleware .
7,025
private function privacyRestrictions ( Tree $ tree ) : array { return DB :: table ( 'default_resn' ) -> where ( 'gedcom_id' , '=' , $ tree -> id ( ) ) -> get ( ) -> map ( static function ( stdClass $ row ) use ( $ tree ) : stdClass { $ row -> record = null ; $ row -> label = '' ; if ( $ row -> xref !== null ) { $ row -...
The current privacy restrictions for a tree .
7,026
private function tagsForPrivacy ( Tree $ tree ) : array { $ tags = array_unique ( array_merge ( explode ( ',' , $ tree -> getPreference ( 'INDI_FACTS_ADD' ) ) , explode ( ',' , $ tree -> getPreference ( 'INDI_FACTS_UNIQUE' ) ) , explode ( ',' , $ tree -> getPreference ( 'FAM_FACTS_ADD' ) ) , explode ( ',' , $ tree -> g...
Generate a list of potential problems with the server .
7,027
public function serverErrors ( $ driver = '' ) : Collection { $ errors = Collection :: make ( [ $ this -> databaseDriverErrors ( $ driver ) , $ this -> checkPhpExtension ( 'mbstring' ) , $ this -> checkPhpExtension ( 'iconv' ) , $ this -> checkPhpExtension ( 'pcre' ) , $ this -> checkPhpExtension ( 'session' ) , $ this...
Things that may cause webtrees to break .
7,028
public function serverWarnings ( $ driver = '' ) : Collection { $ warnings = Collection :: make ( [ $ this -> databaseDriverWarnings ( $ driver ) , $ this -> checkPhpExtension ( 'curl' ) , $ this -> checkPhpExtension ( 'gd' ) , $ this -> checkPhpExtension ( 'simplexml' ) , $ this -> checkPhpIni ( 'file_uploads' , true ...
Things that should be fixed but which won t stop completely webtrees from running .
7,029
public function isFunctionDisabled ( string $ function ) : bool { $ disable_functions = explode ( ',' , ini_get ( 'disable_functions' ) ) ; $ disable_functions = array_map ( static function ( string $ func ) : string { return strtolower ( trim ( $ func ) ) ; } , $ disable_functions ) ; $ function = strtolower ( $ funct...
Check if a PHP function is in the list of disabled functions .
7,030
public function analyticsCanShow ( ) : bool { $ request = app ( ServerRequestInterface :: class ) ; $ dnt = $ request -> getServerParams ( ) [ 'HTTP_DNT' ] ?? '' ; if ( $ dnt === '1' ) { return false ; } foreach ( $ this -> analyticsParameters ( ) as $ parameter ) { if ( $ parameter === '' ) { return false ; } } return...
Should we add this tracker?
7,031
public function contactPage ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ referer = $ request -> getHeaderLine ( 'referer' ) ; $ body = $ request -> get ( 'body' , '' ) ; $ from_email = $ request -> get ( 'from_email' , '' ) ; $ from_name = $ request -> get ( 'from_name' , '' ) ; $ subject ...
A form to compose a message from a visitor .
7,032
private function validContacts ( Tree $ tree ) : array { $ contacts = [ $ this -> user_service -> find ( ( int ) $ tree -> getPreference ( 'CONTACT_USER_ID' ) ) , $ this -> user_service -> find ( ( int ) $ tree -> getPreference ( 'WEBMASTER_USER_ID' ) ) , ] ; return array_filter ( $ contacts ) ; }
Contact messages can only be sent to the designated contacts
7,033
private function deliverMessage ( Tree $ tree , UserInterface $ sender , UserInterface $ recipient , string $ subject , string $ body , string $ url , string $ ip ) : bool { $ success = true ; I18N :: init ( $ recipient -> getPreference ( 'language' ) ) ; $ body_text = view ( 'emails/message-user-text' , [ 'sender' => ...
Add a message to a user s inbox send it to them via email or both .
7,034
public function searchFamilyNames ( array $ trees , array $ search , int $ offset = 0 , int $ limit = PHP_INT_MAX ) : Collection { $ query = DB :: table ( 'families' ) -> leftJoin ( 'name AS husb_name' , static function ( JoinClause $ join ) : void { $ join -> on ( 'husb_name.n_file' , '=' , 'families.f_file' ) -> on (...
Search for families by name .
7,035
public function searchIndividualNames ( array $ trees , array $ search , int $ offset = 0 , int $ limit = PHP_INT_MAX ) : Collection { $ query = DB :: table ( 'individuals' ) -> join ( 'name' , static function ( JoinClause $ join ) : void { $ join -> on ( 'name.n_file' , '=' , 'individuals.i_file' ) -> on ( 'name.n_id'...
Search for individuals by name .
7,036
public function searchMedia ( array $ trees , array $ search , int $ offset = 0 , int $ limit = PHP_INT_MAX ) : Collection { $ query = DB :: table ( 'media' ) ; $ this -> whereTrees ( $ query , 'media.m_file' , $ trees ) ; $ this -> whereSearch ( $ query , 'm_gedcom' , $ search ) ; return $ this -> paginateQuery ( $ qu...
Search for media objects .
7,037
public function searchPlaces ( Tree $ tree , string $ search , int $ offset = 0 , int $ limit = PHP_INT_MAX ) : Collection { $ query = DB :: table ( 'places AS p0' ) -> where ( 'p0.p_file' , '=' , $ tree -> id ( ) ) -> leftJoin ( 'places AS p1' , 'p1.p_id' , '=' , 'p0.p_parent_id' ) -> leftJoin ( 'places AS p2' , 'p2.p...
Search for places .
7,038
private function paginateQuery ( Builder $ query , Closure $ row_mapper , Closure $ row_filter , int $ offset , int $ limit ) : Collection { $ collection = new Collection ( ) ; foreach ( $ query -> cursor ( ) as $ row ) { $ record = $ row_mapper ( $ row ) ; if ( $ row_filter ( $ record ) ) { if ( $ offset > 0 ) { $ off...
Paginate a search query .
7,039
private function whereSearch ( Builder $ query , $ field , array $ search_terms ) : void { if ( $ field instanceof Expression ) { $ field = $ field -> getValue ( ) ; } foreach ( $ search_terms as $ search_term ) { $ query -> whereContains ( DB :: raw ( $ field ) , $ search_term ) ; } }
Apply search filters to a SQL query column . Apply collation rules to MySQL .
7,040
private function wherePhonetic ( Builder $ query , $ field , string $ soundex ) : void { if ( $ soundex !== '' ) { $ query -> where ( static function ( Builder $ query ) use ( $ soundex , $ field ) : void { foreach ( explode ( ':' , $ soundex ) as $ sdx ) { $ query -> orWhere ( $ field , 'LIKE' , '%' . $ sdx . '%' ) ; ...
Apply soundex search filters to a SQL query column .
7,041
private function rawGedcomFilter ( array $ search_terms ) : Closure { return static function ( GedcomRecord $ record ) use ( $ search_terms ) : bool { $ gedcom = preg_replace ( '/\n\d (?:_UID) .*/' , '' , $ record -> gedcom ( ) ) ; $ gedcom = preg_replace ( '/\n\d ' . Gedcom :: REGEX_TAG . '( @' . Gedcom :: REGEX_XREF ...
A closure to filter records by privacy - filtered GEDCOM data .
7,042
private function rowLimiter ( int $ limit = 1000 ) : Closure { return static function ( ) use ( $ limit ) : void { static $ n = 0 ; if ( ++ $ n > $ limit ) { $ message = I18N :: translate ( 'The search returned too many results.' ) ; throw new InternalServerErrorException ( $ message ) ; } } ; }
Searching for short or common text can give more results than the system can process .
7,043
public function mediaDownload ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ xref = $ request -> get ( 'xref' , '' ) ; $ fact_id = $ request -> get ( 'fact_id' ) ; $ media = Media :: getInstance ( $ xref , $ tree ) ; if ( $ media === null ) { throw new MediaNotFoundException ( ) ; } if ( ! $...
Download a non - image media file .
7,044
private function generateImage ( MediaFile $ media_file , array $ params ) : ResponseInterface { try { $ signature = $ this -> glideSignature ( ) ; $ signature -> validateRequest ( parse_url ( WT_BASE_URL . 'index.php' , PHP_URL_PATH ) , $ params ) ; $ server = $ this -> glideServer ( $ media_file -> folder ( ) ) ; $ p...
Generate a thumbnail image for a file .
7,045
private function httpStatusAsImage ( int $ status ) : ResponseInterface { $ svg = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="#F88" /><text x="5" y="55" font-family="Verdana" font-size="35">' . $ status . '</text></svg>' ; return response ( $ svg , StatusCodeIn...
Send a dummy image to replace one that could not be found or created .
7,046
private function fileExtensionAsImage ( string $ extension ) : ResponseInterface { $ extension = '.' . strtolower ( $ extension ) ; $ svg = '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="#88F" /><text x="5" y="60" font-family="Verdana" font-size="30">' . $ extensi...
Send a dummy image to replace a non - image file .
7,047
public function handle ( ServerRequestInterface $ request , Builder $ query , array $ search_columns , array $ sort_columns , Closure $ callback ) : ResponseInterface { $ search = $ request -> getQueryParams ( ) [ 'search' ] [ 'value' ] ?? '' ; $ start = ( int ) ( $ request -> getQueryParams ( ) [ 'start' ] ?? 0 ) ; $ ...
Apply filtering and pagination to a query and generate a response suitable for datatables .
7,048
protected function endElement ( $ parser , string $ name ) : void { $ method = $ name . 'EndHandler' ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( ) ; } }
XML handler for a closing tag .
7,049
public function addUnlinked ( Tree $ tree ) : ResponseInterface { return $ this -> viewResponse ( 'edit/new-individual' , [ 'tree' => $ tree , 'title' => I18N :: translate ( 'Create an individual' ) , 'nextaction' => 'add_unlinked_indi_action' , 'individual' => null , 'family' => null , 'name_fact' => null , 'famtag' =...
Add an unlinked individual
7,050
public function editName ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ fact_id = $ request -> get ( 'fact_id' , '' ) ; $ xref = $ request -> get ( 'xref' , '' ) ; $ individual = Individual :: getInstance ( $ xref , $ tree ) ; Auth :: checkIndividualAccess ( $ individual , true ) ; foreach (...
Edit a name record .
7,051
protected function formatDay ( ) : string { $ locale = app ( LocaleInterface :: class ) -> language ( ) -> code ( ) ; if ( $ locale === 'he' || $ locale === 'yi' ) { return ( new JewishCalendar ( ) ) -> numberToHebrewNumerals ( $ this -> day , true ) ; } return parent :: formatDay ( ) ; }
Generate the %j format for a date .
7,052
protected function formatShortYear ( ) : string { $ locale = app ( LocaleInterface :: class ) -> language ( ) -> code ( ) ; if ( $ locale === 'he' || $ locale === 'yi' ) { return ( new JewishCalendar ( ) ) -> numberToHebrewNumerals ( $ this -> year , false ) ; } return parent :: formatLongYear ( ) ; }
Generate the %y format for a date .
7,053
protected function monthNameNominativeCase ( int $ month , bool $ leap_year ) : string { static $ translated_month_names ; if ( $ translated_month_names === null ) { $ translated_month_names = [ 0 => '' , 1 => I18N :: translateContext ( 'NOMINATIVE' , 'Tishrei' ) , 2 => I18N :: translateContext ( 'NOMINATIVE' , 'Heshva...
Full month name in nominative case .
7,054
protected function monthNameAbbreviated ( int $ month , bool $ leap_year ) : string { return $ this -> monthNameNominativeCase ( $ month , $ leap_year ) ; }
Abbreviated month name
7,055
public function dayNames ( int $ day_number ) : string { static $ translated_day_names ; if ( $ translated_day_names === null ) { $ translated_day_names = [ 0 => I18N :: translate ( 'Monday' ) , 1 => I18N :: translate ( 'Tuesday' ) , 2 => I18N :: translate ( 'Wednesday' ) , 3 => I18N :: translate ( 'Thursday' ) , 4 => ...
Full day of the week
7,056
protected function dayNamesAbbreviated ( int $ day_number ) : string { static $ translated_day_names ; if ( $ translated_day_names === null ) { $ translated_day_names = [ 0 => I18N :: translate ( 'Mon' ) , 1 => I18N :: translate ( 'Tue' ) , 2 => I18N :: translate ( 'Wed' ) , 3 => I18N :: translate ( 'Thu' ) , 4 => I18N...
Abbreviated day of the week
7,057
public static function compare ( AbstractCalendarDate $ d1 , AbstractCalendarDate $ d2 ) : int { if ( $ d1 -> maximum_julian_day < $ d2 -> minimum_julian_day ) { return - 1 ; } if ( $ d2 -> maximum_julian_day < $ d1 -> minimum_julian_day ) { return 1 ; } return 0 ; }
Compare two dates for sorting
7,058
public function getAge ( int $ jd ) : int { if ( $ this -> year === 0 || $ jd === 0 ) { return 0 ; } if ( $ this -> minimum_julian_day < $ jd && $ this -> maximum_julian_day > $ jd ) { return 0 ; } if ( $ this -> minimum_julian_day === $ jd ) { return 0 ; } [ $ y , $ m , $ d ] = $ this -> calendar -> jdToYmd ( $ jd ) ;...
How long between an event and a given julian day Return result as a number of years .
7,059
public function getAgeFull ( int $ jd ) : string { if ( $ this -> year === 0 || $ jd === 0 ) { return '' ; } if ( $ this -> minimum_julian_day < $ jd && $ this -> maximum_julian_day > $ jd ) { return '' ; } if ( $ this -> minimum_julian_day === $ jd ) { return '' ; } if ( $ jd < $ this -> minimum_julian_day ) { return ...
How long between an event and a given julian day Return result as a gedcom - style age string .
7,060
public function convertToCalendar ( string $ calendar ) : AbstractCalendarDate { switch ( $ calendar ) { case 'gregorian' : return new GregorianDate ( $ this ) ; case 'julian' : return new JulianDate ( $ this ) ; case 'jewish' : return new JewishDate ( $ this ) ; case 'french' : return new FrenchDate ( $ this ) ; case ...
Convert a date from one calendar to another .
7,061
public function inValidRange ( ) : bool { return $ this -> minimum_julian_day >= $ this -> calendar -> jdStart ( ) && $ this -> maximum_julian_day <= $ this -> calendar -> jdEnd ( ) ; }
Is this date within the valid range of the calendar
7,062
public function daysInMonth ( ) : int { try { return $ this -> calendar -> daysInMonth ( $ this -> year , $ this -> month ) ; } catch ( InvalidArgumentException $ ex ) { return 0 ; } }
How many days in the current month
7,063
protected function formatDayZeros ( ) : string { if ( $ this -> day > 9 ) { return I18N :: digits ( $ this -> day ) ; } return I18N :: digits ( '0' . $ this -> day ) ; }
Generate the %d format for a date .
7,064
protected function formatDayOfYear ( ) : string { return I18N :: digits ( $ this -> minimum_julian_day - $ this -> calendar -> ymdToJd ( $ this -> year , 1 , 1 ) ) ; }
Generate the %z format for a date .
7,065
protected function formatMonthZeros ( ) : string { if ( $ this -> month > 9 ) { return I18N :: digits ( $ this -> month ) ; } return I18N :: digits ( '0' . $ this -> month ) ; }
Generate the %m format for a date .
7,066
protected function formatLongMonth ( $ case = 'NOMINATIVE' ) : string { switch ( $ case ) { case 'GENITIVE' : return $ this -> monthNameGenitiveCase ( $ this -> month , $ this -> isLeapYear ( ) ) ; case 'NOMINATIVE' : return $ this -> monthNameNominativeCase ( $ this -> month , $ this -> isLeapYear ( ) ) ; case 'LOCATI...
Generate the %F format for a date .
7,067
protected function formatGedcomMonth ( ) : string { if ( $ this -> month === 7 && $ this -> calendar instanceof JewishCalendar && ! $ this -> calendar -> isLeapYear ( $ this -> year ) ) { return 'ADR' ; } return array_search ( $ this -> month , static :: MONTH_ABBREVIATIONS , true ) ; }
Generate the %O format for a date .
7,068
public function calendarUrl ( string $ date_format , Tree $ tree ) : string { if ( $ this -> day !== 0 && strpbrk ( $ date_format , 'dDj' ) ) { $ view = 'day' ; } elseif ( $ this -> month !== 0 && strpbrk ( $ date_format , 'FMmn' ) ) { $ view = 'month' ; } else { $ view = 'year' ; } return route ( 'calendar' , [ 'cal' ...
Create a URL that links this date to the WT calendar
7,069
public static function endpushunique ( ) : void { $ content = ob_get_clean ( ) ; self :: $ stacks [ self :: $ stack ] [ sha1 ( $ content ) ] = $ content ; }
Variant of push that will only add one copy of each item .
7,070
public static function stack ( string $ stack ) : string { $ content = implode ( '' , self :: $ stacks [ $ stack ] ?? [ ] ) ; self :: $ stacks [ $ stack ] = [ ] ; return $ content ; }
Implementation of Blade stacks .
7,071
public function getFilenameForView ( string $ view_name ) : string { $ explicit = Str :: startsWith ( $ view_name , self :: NAMESPACE_SEPARATOR ) ; if ( ! Str :: contains ( $ view_name , self :: NAMESPACE_SEPARATOR ) ) { $ view_name = self :: NAMESPACE_SEPARATOR . $ view_name ; } while ( ! $ explicit && array_key_exist...
Find the file for a view .
7,072
public static function make ( $ name , $ data = [ ] ) : string { $ view = new static ( $ name , $ data ) ; DebugBar :: addView ( $ name , $ data ) ; return $ view -> render ( ) ; }
Cerate and render a view in a single operation .
7,073
public function pasteFact ( string $ fact_id , GedcomRecord $ record ) : bool { $ clipboard = Session :: get ( 'clipboard' ) ; $ record_type = $ record :: RECORD_TYPE ; if ( isset ( $ clipboard [ $ record_type ] [ $ fact_id ] ) ) { $ record -> createFact ( $ clipboard [ $ record_type ] [ $ fact_id ] [ 'factrec' ] , tru...
Copy a fact from the clipboard to a record .
7,074
public function pastableFacts ( GedcomRecord $ record , Collection $ exclude_types ) : Collection { return ( new Collection ( Session :: get ( 'clipboard' , [ ] ) [ $ record :: RECORD_TYPE ] ?? [ ] ) ) -> reverse ( ) -> map ( static function ( array $ clipping ) use ( $ record ) : Fact { return new Fact ( $ clipping [ ...
Create a list of facts that can be pasted into a given record
7,075
public function pastableFactsOfType ( GedcomRecord $ record , Collection $ types ) : Collection { return ( new Collection ( Session :: get ( 'clipboard' , [ ] ) ) ) -> flatten ( 1 ) -> reverse ( ) -> map ( static function ( array $ clipping ) use ( $ record ) : Fact { return new Fact ( $ clipping [ 'factrec' ] , $ reco...
Find facts of a given type from all records .
7,076
public static function getAll ( ) : array { if ( empty ( self :: $ trees ) ) { self :: $ trees = self :: all ( ) -> all ( ) ; } return self :: $ trees ; }
Fetch all the trees that we have permission to access .
7,077
public static function all ( ) : Collection { return app ( 'cache.array' ) -> rememberForever ( __CLASS__ , static function ( ) : Collection { $ query = DB :: table ( 'gedcom' ) -> leftJoin ( 'gedcom_setting' , static function ( JoinClause $ join ) : void { $ join -> on ( 'gedcom_setting.gedcom_id' , '=' , 'gedcom.gedc...
All the trees that we have permission to access .
7,078
public static function create ( string $ tree_name , string $ tree_title ) : Tree { try { DB :: table ( 'gedcom' ) -> insert ( [ 'gedcom_name' => $ tree_name , ] ) ; $ tree_id = ( int ) DB :: connection ( ) -> getPdo ( ) -> lastInsertId ( ) ; $ tree = new self ( $ tree_id , $ tree_name , $ tree_title ) ; } catch ( PDOE...
Create a new tree
7,079
public static function findByName ( $ tree_name ) : ? Tree { foreach ( self :: getAll ( ) as $ tree ) { if ( $ tree -> name === $ tree_name ) { return $ tree ; } } return null ; }
Find the tree with a specific name .
7,080
public function delete ( ) : void { if ( Site :: getPreference ( 'DEFAULT_GEDCOM' ) === $ this -> name ) { Site :: setPreference ( 'DEFAULT_GEDCOM' , '' ) ; } $ this -> deleteGenealogyData ( false ) ; DB :: table ( 'block_setting' ) -> join ( 'block' , 'block.block_id' , '=' , 'block_setting.block_id' ) -> where ( 'ged...
Delete everything relating to a tree
7,081
public function exportGedcom ( $ stream ) : void { $ buffer = FunctionsExport :: reformatRecord ( FunctionsExport :: gedcomHeader ( $ this , 'UTF-8' ) ) ; $ union_families = DB :: table ( 'families' ) -> where ( 'f_file' , '=' , $ this -> id ) -> select ( [ 'f_gedcom AS gedcom' , 'f_id AS xref' , DB :: raw ( 'LENGTH(f_...
Export the tree to a GEDCOM file
7,082
public function importGedcomFile ( StreamInterface $ stream , string $ filename ) : void { $ file_data = '' ; $ this -> deleteGenealogyData ( ( bool ) $ this -> getPreference ( 'keep_media' ) ) ; $ this -> setPreference ( 'gedcom_filename' , $ filename ) ; $ this -> setPreference ( 'imported' , '0' ) ; while ( ! $ stre...
Import data from a gedcom file into this tree .
7,083
public function createRecord ( string $ gedcom ) : GedcomRecord { if ( ! Str :: startsWith ( $ gedcom , '0 @@ ' ) ) { throw new InvalidArgumentException ( 'GedcomRecord::createRecord(' . $ gedcom . ') does not begin 0 @@' ) ; } $ xref = $ this -> getNewXref ( ) ; $ gedcom = '0 @' . $ xref . '@ ' . Str :: after ( $ gedc...
Create a new record from GEDCOM data .
7,084
public function getNewXref ( ) : string { DB :: table ( 'site_setting' ) -> where ( 'setting_name' , '=' , 'next_xref' ) -> lockForUpdate ( ) -> get ( ) ; $ prefix = 'X' ; $ increment = 1.0 ; do { $ num = ( int ) Site :: getPreference ( 'next_xref' ) + ( int ) $ increment ; $ increment *= 1.01 ; $ xref = $ prefix . $ n...
Generate a new XREF unique across all family trees
7,085
public function significantIndividual ( UserInterface $ user ) : Individual { $ individual = null ; if ( $ this -> getUserPreference ( $ user , 'rootid' ) !== '' ) { $ individual = Individual :: getInstance ( $ this -> getUserPreference ( $ user , 'rootid' ) , $ this ) ; } if ( $ individual === null && $ this -> getUse...
What is the most significant individual in this tree .
7,086
public function setup ( ServerRequestInterface $ request ) : ResponseInterface { define ( 'WT_DATA_DIR' , 'data/' ) ; app ( ) -> instance ( ServerRequestInterface :: class , $ request ) ; app ( ) -> instance ( 'cache.array' , new Repository ( new ArrayStore ( ) ) ) ; $ data = $ this -> userData ( $ request ) ; $ step =...
Installation wizard - check user input and proceed to the next step .
7,087
private function setupLocales ( ) : array { return app ( ModuleService :: class ) -> setupLanguages ( ) -> map ( static function ( ModuleLanguageInterface $ module ) : LocaleInterface { return $ module -> locale ( ) ; } ) -> all ( ) ; }
Which languages are available during the installation .
7,088
private function checkFolderIsWritable ( string $ data_dir ) : bool { $ text1 = random_bytes ( 32 ) ; try { file_put_contents ( $ data_dir . 'test.txt' , $ text1 ) ; $ text2 = file_get_contents ( WT_DATA_DIR . 'test.txt' ) ; unlink ( WT_DATA_DIR . 'test.txt' ) ; } catch ( Exception $ ex ) { return false ; } return $ te...
Check we can write to the data folder .
7,089
public function chartBirth ( 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 = $ color_from ?? $ c...
Create a chart of birth places .
7,090
public function mapTwoLetterToName ( string $ twoLetterCode ) : string { $ threeLetterCode = array_search ( $ twoLetterCode , $ this -> iso3166 ( ) , true ) ; $ threeLetterCode = $ threeLetterCode ? : '???' ; return $ this -> getAllCountries ( ) [ $ threeLetterCode ] ; }
Returns the translated country name based on the given two letter country code .
7,091
public function show ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ xref = $ request -> get ( 'xref' , '' ) ; $ record = GedcomRecord :: getInstance ( $ xref , $ tree ) ; Auth :: checkRecordAccess ( $ record ) ; if ( $ this -> hasCustomPage ( $ record ) ) { return redirect ( $ record -> url ...
Show a gedcom record s page .
7,092
private function hasCustomPage ( GedcomRecord $ record ) : bool { return $ record instanceof Individual || $ record instanceof Family || $ record instanceof Source || $ record instanceof Repository || $ record instanceof Note || $ record instanceof Media ; }
Is there a better place to display this record?
7,093
public function canonicalTag ( string $ tag ) : string { $ tag = strtoupper ( $ tag ) ; $ tag = self :: TAG_NAMES [ $ tag ] ?? self :: TAG_SYNONYMS [ $ tag ] ?? $ tag ; return $ tag ; }
Convert a GEDCOM tag to a canonical form .
7,094
public function readSex ( string $ text ) : string { $ text = strtoupper ( $ text ) ; if ( $ text !== self :: SEX_MALE && $ text !== self :: SEX_FEMALE ) { $ text = self :: SEX_UNKNOWN ; } return $ text ; }
Some applications use non - standard values for unknown .
7,095
public function assetUrl ( string $ asset ) : string { $ file = $ this -> resourcesFolder ( ) . $ asset ; $ hash = filemtime ( $ file ) ; return route ( 'module' , [ 'module' => $ this -> name ( ) , 'action' => 'asset' , 'asset' => $ asset , 'hash' => $ hash , ] ) ; }
Create a URL for an asset .
7,096
public function render ( $ renderer ) { $ renderer -> setCurrentStyle ( 'footnotenum' ) ; echo '<a href="#footnote' , $ this -> num , '"><sup>' ; $ renderer -> write ( $ renderer -> entityRTL . $ this -> num ) ; echo "</sup></a>\n" ; }
HTML Footnotes number renderer
7,097
public function getFootnoteHeight ( $ html , float $ cellWidth = 0 ) : float { if ( $ html -> getCurrentStyle ( ) != $ this -> styleName ) { $ html -> setCurrentStyle ( $ this -> styleName ) ; } if ( $ cellWidth > 0 ) { $ this -> text = $ html -> textWrap ( $ this -> text , $ cellWidth ) ; } $ this -> text .= "\n\n" ; ...
Calculates the Footnotes height
7,098
public function interpolateRgb ( string $ startColor , string $ endColor , int $ steps ) : array { if ( ! $ steps ) { return [ ] ; } $ s = $ this -> hexToRgb ( $ startColor ) ; $ e = $ this -> hexToRgb ( $ endColor ) ; $ colors = [ ] ; $ factorR = ( $ e [ 0 ] - $ s [ 0 ] ) / $ steps ; $ factorG = ( $ e [ 1 ] - $ s [ 1 ...
Interpolates the number of color steps between a given start and end color .
7,099
private function rgbToHex ( int $ r , int $ g , int $ b ) : string { return sprintf ( '#%02x%02x%02x' , $ r , $ g , $ b ) ; }
Converts the color values to the HTML hex representation .