idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
6,900
|
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 .
|
6,901
|
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 .
|
6,902
|
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 .
|
6,903
|
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 .
|
6,904
|
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 .
|
6,905
|
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 .
|
6,906
|
public function attachPermission ( $ permission ) { return ( ! $ this -> permissions ( ) -> get ( ) -> contains ( $ permission ) ) ? $ this -> permissions ( ) -> attach ( $ permission ) : true ; }
|
Attach permission to a role .
|
6,907
|
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
|
6,908
|
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
|
6,909
|
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 .
|
6,910
|
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 .
|
6,911
|
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 .
|
6,912
|
protected function buildSMSString ( ) { $ sms = $ this -> prefix . $ this -> phoneNumber ; if ( isset ( $ this -> message ) ) { $ sms .= $ this -> separator . $ this -> message ; } return $ sms ; }
|
Builds a SMS string .
|
6,913
|
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 .
|
6,914
|
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 .
|
6,915
|
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 .
|
6,916
|
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 .
|
6,917
|
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 .
|
6,918
|
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 .
|
6,919
|
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 .
|
6,920
|
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 .
|
6,921
|
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 .
|
6,922
|
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 .
|
6,923
|
public function size ( $ pixels ) { $ this -> writer -> getRenderer ( ) -> setHeight ( $ pixels ) ; $ this -> writer -> getRenderer ( ) -> setWidth ( $ pixels ) ; return $ this ; }
|
Changes the size of the QrCode .
|
6,924
|
public function color ( $ red , $ green , $ blue ) { $ this -> writer -> getRenderer ( ) -> setForegroundColor ( new Rgb ( $ red , $ green , $ blue ) ) ; return $ this ; }
|
Changes the foreground color of a QrCode .
|
6,925
|
public function backgroundColor ( $ red , $ green , $ blue ) { $ this -> writer -> getRenderer ( ) -> setBackgroundColor ( new Rgb ( $ red , $ green , $ blue ) ) ; return $ this ; }
|
Changes the background color of a QrCode .
|
6,926
|
public static function login ( UserInterface $ user ) : void { Session :: regenerate ( false ) ; Session :: put ( 'wt_user' , $ user -> id ( ) ) ; }
|
Login directly as an explicit user - for masquerading .
|
6,927
|
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 ( ) ; } 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" ; } 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" ; } $ renderer -> addMaxY ( $ this -> y1 ) ; $ renderer -> addMaxY ( $ this -> y2 ) ; }
|
HTML line renderer
|
6,928
|
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
|
6,929
|
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 .
|
6,930
|
private function getCommonFacts ( ) : array { 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 .
|
6,931
|
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
|
6,932
|
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
|
6,933
|
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
|
6,934
|
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 .
|
6,935
|
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 .
|
6,936
|
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 ) ; } } } }
|
Create a list of all descendants .
|
6,937
|
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 ; } $ 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 .
|
6,938
|
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 { $ value = $ match [ 1 ] ; } } if ( $ level != 0 || $ t != 'NOTE' ) { $ value .= Functions :: getCont ( $ level + 1 , $ subrec ) ; } return $ value ; } return '' ; }
|
get gedcom tag value
|
6,939
|
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 .
|
6,940
|
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
|
6,941
|
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 ) { $ 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 .
|
6,942
|
public static function surnameList ( $ surnames , $ style , $ totals , ? ModuleListInterface $ module , Tree $ tree ) : string { $ html = [ ] ; foreach ( $ surnames as $ surn => $ surns ) { if ( $ module instanceof ModuleListInterface ) { if ( $ surn ) { $ url = $ module -> listUrl ( $ tree , [ 'surname' => $ surn ] ) ; } else { $ url = $ module -> listUrl ( $ tree , [ 'alpha' => ',' ] ) ; } } else { $ url = null ; } $ 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 .= ' (' . 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 .
|
6,943
|
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 .
|
6,944
|
public function menuPalette ( ) : Menu { $ request = app ( ServerRequestInterface :: class ) ; $ 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
|
6,945
|
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 .
|
6,946
|
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 .
|
6,947
|
private function associateFacts ( Individual $ person ) : array { $ facts = [ ] ; $ 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 ( ) ) { $ 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 .
|
6,948
|
public function quick ( ServerRequestInterface $ request , Tree $ tree ) : ResponseInterface { $ query = $ request -> get ( 'query' , '' ) ; $ 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 .
|
6,949
|
private function extractSearchTerms ( string $ query ) : array { $ search_terms = [ ] ; while ( preg_match ( '/"([^"]+)"/' , $ query , $ match ) ) { $ search_terms [ ] = trim ( $ match [ 1 ] ) ; $ query = str_replace ( $ match [ 0 ] , '' , $ query ) ; } 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
|
6,950
|
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' ) ; 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 .
|
6,951
|
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 .
|
6,952
|
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
|
6,953
|
private function getIso3166Countries ( ) : array { $ countries = $ this -> country_service -> getAllCountries ( ) ; $ 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 .
|
6,954
|
private function createChartData ( array $ places ) : array { $ data = [ [ I18N :: translate ( 'Country' ) , I18N :: translate ( 'Total' ) , ] , ] ; 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 .
|
6,955
|
private function getBirthChartData ( ) : array { $ surn_countries = [ ] ; $ b_countries = $ this -> placeRepository -> statsPlaces ( 'INDI' , 'BIRT' , 0 , true ) ; foreach ( $ b_countries as $ country => $ count ) { 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 .
|
6,956
|
private function getDeathChartData ( ) : array { $ surn_countries = [ ] ; $ d_countries = $ this -> placeRepository -> statsPlaces ( 'INDI' , 'DEAT' , 0 , true ) ; foreach ( $ d_countries as $ country => $ count ) { 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 .
|
6,957
|
private function getMarriageChartData ( ) : array { $ surn_countries = [ ] ; $ m_countries = $ this -> placeRepository -> statsPlaces ( 'FAM' ) ; foreach ( $ m_countries as $ place ) { 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 .
|
6,958
|
private function getSurnameChartData ( string $ surname ) : array { if ( $ surname === '' ) { $ surname = $ this -> individualRepository -> getCommonSurname ( ) ; } $ surn_countries = [ ] ; $ records = $ this -> queryRecords ( $ surname ) ; foreach ( $ records as $ row ) { if ( preg_match_all ( '/^2 PLAC (?:.*, *)*(.*)/m' , $ row -> i_gedcom , $ matches ) ) { foreach ( $ matches [ 1 ] as $ country ) { 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 .
|
6,959
|
private function getIndivdualChartData ( ) : array { $ surn_countries = [ ] ; $ a_countries = $ this -> placeRepository -> statsPlaces ( 'INDI' ) ; foreach ( $ a_countries as $ place ) { 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 .
|
6,960
|
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 .
|
6,961
|
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 .
|
6,962
|
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 .
|
6,963
|
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 .
|
6,964
|
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 ) ) { FunctionsImport :: updateRecord ( $ change -> old_gedcom , $ tree , true ) ; } else { 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 .
|
6,965
|
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 .
|
6,966
|
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 .
|
6,967
|
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 .
|
6,968
|
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
|
6,969
|
public function render ( $ renderer ) { $ renderer -> setCurrentStyle ( 'footnotenum' ) ; $ renderer -> Write ( $ renderer -> getCurrentStyleHeight ( ) , $ this -> numText , $ this -> addlink ) ; }
|
PDF Footnotes number renderer
|
6,970
|
public function getWidth ( $ renderer ) { $ renderer -> setCurrentStyle ( 'footnotenum' ) ; $ fsize = $ renderer -> getCurrentStyleHeight ( ) ; if ( $ fsize > $ renderer -> largestFontHeight ) { $ renderer -> largestFontHeight = $ fsize ; } if ( empty ( $ this -> num ) ) { $ renderer -> checkFootnote ( $ this ) ; } $ lw = ceil ( $ renderer -> GetStringWidth ( $ this -> numText ) ) ; $ lfct = substr_count ( $ this -> numText , "\n" ) + 1 ; if ( $ this -> wrapWidthRemaining > 0 ) { $ wrapWidthRemaining = $ this -> wrapWidthRemaining ; if ( $ lw >= $ wrapWidthRemaining || $ lfct > 1 ) { $ newtext = '' ; $ lines = explode ( "\n" , $ this -> numText ) ; foreach ( $ lines as $ line ) { $ lw = ceil ( $ renderer -> GetStringWidth ( $ line ) ) ; 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 .= ' ' ; } $ wrapWidthRemaining = $ this -> wrapWidthCell ; } } } else { $ newtext .= $ line ; } if ( $ lfct > 1 ) { $ newtext .= "\n" ; $ lw = 0 ; $ 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
|
6,971
|
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
|
6,972
|
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 .
|
6,973
|
public function getNote ( ) : string { $ fact = $ this -> facts ( [ 'NOTE' ] ) -> first ( ) ; if ( $ fact instanceof Fact ) { $ note = $ fact -> target ( ) ; if ( $ note instanceof Note ) { return $ note -> getNote ( ) ; } return $ fact -> value ( ) ; } return '' ; }
|
Get the first note attached to this media object
|
6,974
|
protected function countHit ( Tree $ tree , string $ page , string $ parameter ) : int { 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 .
|
6,975
|
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 .
|
6,976
|
private function runHousekeeping ( ) : void { $ data_filesystem = app ( FilesystemInterface :: class ) ; $ root_filesystem = new Filesystem ( new Local ( Webtrees :: ROOT_DIR ) ) ; $ this -> housekeeping_service -> deleteOldFiles ( $ data_filesystem , 'cache' , self :: MAX_CACHE_AGE ) ; $ this -> housekeeping_service -> deleteOldFiles ( $ data_filesystem , 'thumbnail-cache' , self :: MAX_THUMBNAIL_AGE ) ; $ this -> housekeeping_service -> deleteOldFiles ( $ root_filesystem , self :: TMP_DIR , self :: MAX_TMP_FILE_AGE ) ; $ this -> housekeeping_service -> deleteOldLogs ( self :: MAX_LOG_AGE ) ; $ this -> housekeeping_service -> deleteOldSessions ( self :: MAX_SESSION_AGE ) ; }
|
Run the various housekeeping services .
|
6,977
|
private static function convertMediaPath ( $ rec , $ path ) : string { if ( $ path && preg_match ( '/\n1 FILE (.+)/' , $ rec , $ match ) ) { $ old_file_name = $ match [ 1 ] ; if ( strpos ( $ old_file_name , '://' ) === false ) { if ( strpos ( $ path , '\\' ) !== false ) { $ new_file_name = preg_replace ( '~/+~' , '\\' , $ old_file_name ) ; } else { $ new_file_name = $ old_file_name ; } 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 .
|
6,978
|
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 ( ) ) { continue ; } if ( $ month_number === 7 && $ calendar_date instanceof JewishDate && ! $ calendar_date -> isLeapYear ( ) ) { $ 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 .
|
6,979
|
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 ( ) ; 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
|
6,980
|
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 .
|
6,981
|
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 .
|
6,982
|
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 .
|
6,983
|
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 .
|
6,984
|
private function isChild ( Individual $ individual ) : bool { $ age = Date :: getAgeYears ( $ individual -> getEstimatedBirthDate ( ) , $ this -> date ( ) ) ; return $ age < $ this -> age_adult ; }
|
Is the individual a child .
|
6,985
|
private function isDead ( Individual $ individual ) : bool { return $ individual -> getDeathDate ( ) -> isOK ( ) && Date :: compare ( $ individual -> getDeathDate ( ) , $ this -> date ( ) ) < 0 ; }
|
Is the individual dead .
|
6,986
|
public static function calendarNames ( ) : array { return [ 'gregorian' => I18N :: translate ( 'Gregorian' ) , 'julian' => I18N :: translate ( 'Julian' ) , 'french' => I18N :: translate ( 'French' ) , 'jewish' => I18N :: translate ( 'Jewish' ) , 'hijri' => I18N :: translate ( 'Hijri' ) , 'jalali' => I18N :: translate ( 'Jalali' ) , ] ; }
|
A list of supported calendars and their names .
|
6,987
|
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 .
|
6,988
|
public static function getAge ( Date $ d1 , Date $ d2 = null ) : string { if ( $ d2 instanceof self ) { if ( $ d2 -> maximumJulianDay ( ) >= $ d1 -> minimumJulianDay ( ) && $ d2 -> minimumJulianDay ( ) <= $ d1 -> maximumJulianDay ( ) ) { $ jd = $ d1 -> minimumJulianDay ( ) ; } else { $ jd = $ d2 -> minimumJulianDay ( ) ; } } else { $ jd = Carbon :: now ( ) -> julianDay ( ) ; } 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 .
|
6,989
|
public static function compare ( Date $ a , Date $ b ) : int { 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 .
|
6,990
|
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 .
|
6,991
|
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 .
|
6,992
|
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 .
|
6,993
|
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 .
|
6,994
|
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 .
|
6,995
|
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?
|
6,996
|
protected function canShowByType ( int $ access_level ) : bool { 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 ; } } $ 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 ) ; } return Auth :: PRIV_USER >= $ access_level ; }
|
Can this individual be shown?
|
6,997
|
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 { return true ; } $ distance *= 2 ; for ( $ n = 0 ; $ n <= $ distance ; ++ $ n ) { if ( array_key_exists ( $ n , $ cache ) ) { if ( $ n % 2 === 0 && in_array ( $ target , $ cache [ $ n ] , true ) ) { return true ; } } else { $ cache [ $ n ] = [ ] ; if ( $ n % 2 === 0 ) { foreach ( $ cache [ $ n - 1 ] as $ family ) { foreach ( $ family -> facts ( [ 'HUSB' , 'WIFE' , 'CHIL' ] , false , Auth :: PRIV_HIDE ) as $ fact ) { $ individual = $ fact -> target ( ) ; if ( $ individual instanceof self && ! in_array ( $ individual , $ cache [ $ n - 2 ] , true ) ) { $ cache [ $ n ] [ ] = $ individual ; } } } if ( in_array ( $ target , $ cache [ $ n ] , true ) ) { return true ; } } else { foreach ( $ cache [ $ n - 1 ] as $ individual ) { foreach ( $ individual -> facts ( [ 'FAMC' , 'FAMS' ] , false , Auth :: PRIV_HIDE ) as $ fact ) { $ family = $ fact -> target ( ) ; 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?
|
6,998
|
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
|
6,999
|
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 .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.