idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
44,500 | protected function _languages ( ) { if ( ! empty ( $ this -> params [ 'languages' ] ) ) { $ this -> _languages = explode ( ',' , $ this -> params [ 'languages' ] ) ; return ; } $ langs = Configure :: read ( 'I18n.languages' ) ; if ( empty ( $ langs ) ) { return ; } $ this -> _languages = [ ] ; $ langs = Hash :: normalize ( $ langs ) ; foreach ( $ langs as $ key => $ value ) { if ( isset ( $ value [ 'locale' ] ) ) { $ this -> _languages [ ] = $ value [ 'locale' ] ; } else { $ this -> _languages [ ] = $ key ; } } } | Get app languages . |
44,501 | protected function _messages ( ResultSetInterface $ results ) { if ( ! $ results -> count ( ) ) { return [ ] ; } $ messages = [ ] ; $ pluralForms = 0 ; $ item = $ results -> first ( ) ; for ( $ i = 5 ; $ i > 0 ; $ i -- ) { if ( isset ( $ item [ 'value_' . $ i ] ) ) { $ pluralForms = $ i ; break ; } } foreach ( $ results as $ item ) { $ singular = $ item [ 'singular' ] ; $ context = $ item [ 'context' ] ; $ translation = $ item [ 'value_0' ] ; if ( $ context ) { $ messages [ $ singular ] [ '_context' ] [ $ context ] = $ item [ 'value_0' ] ; } else { $ messages [ $ singular ] = $ item [ 'value_0' ] ; } if ( empty ( $ item [ 'plural' ] ) ) { continue ; } $ key = $ item [ 'plural' ] ; $ plurals = [ ] ; for ( $ i = 0 ; $ i <= $ pluralForms ; $ i ++ ) { $ plurals [ ] = $ item [ 'value_' . $ i ] ; } if ( $ context ) { $ messages [ $ key ] [ '_context' ] [ $ context ] = $ plurals ; } else { $ messages [ $ key ] = $ plurals ; } } return $ messages ; } | Convert db resultset to messages array . |
44,502 | protected function _processRules ( $ field , ValidationSet $ rules , $ data , $ newRecord ) { $ errors = [ ] ; $ this -> getProvider ( 'default' ) ; foreach ( $ rules as $ name => $ rule ) { $ result = $ rule -> process ( $ data [ $ field ] , $ this -> _providers , compact ( 'newRecord' , 'data' , 'field' ) ) ; if ( $ result === true ) { continue ; } if ( is_array ( $ result ) && $ name === static :: NESTED ) { $ errors = $ result ; } elseif ( is_string ( $ result ) ) { $ errors [ $ name ] = $ result ; } else { $ args = $ rule -> get ( 'pass' ) ; $ errors [ $ name ] = __d ( $ this -> _validationDomain , $ name , $ this -> _translateArgs ( $ args ) ) ; } if ( $ rule -> isLast ( ) ) { break ; } } return $ errors ; } | Iterates over each rule in the validation set and collects the errors resulting from executing them . |
44,503 | protected function _identifierList ( $ options ) { if ( empty ( $ options ) ) { $ options = [ 'Africa' => DateTimeZone :: AFRICA , 'America' => DateTimeZone :: AMERICA , 'Antarctica' => DateTimeZone :: ANTARCTICA , 'Arctic' => DateTimeZone :: ARCTIC , 'Asia' => DateTimeZone :: ASIA , 'Atlantic' => DateTimeZone :: ATLANTIC , 'Australia' => DateTimeZone :: AUSTRALIA , 'Europe' => DateTimeZone :: EUROPE , 'Indian' => DateTimeZone :: INDIAN , 'Pacific' => DateTimeZone :: PACIFIC , 'UTC' => DateTimeZone :: UTC , ] ; } $ identifiers = [ ] ; foreach ( $ options as $ name => $ region ) { $ list = DateTimeZone :: listIdentifiers ( $ region ) ; $ identifiers [ $ name ] = array_combine ( $ list , $ list ) ; } if ( count ( $ identifiers ) === 1 ) { $ identifiers = current ( $ identifiers ) ; } return $ identifiers ; } | Converts list of regions to identifiers list . |
44,504 | public function init ( $ language = null ) { if ( ! $ language ) { $ language = $ this -> in ( 'Please specify language code, e.g. `en`, `eng`, `en_US` etc.' ) ; } if ( strlen ( $ language ) < 2 ) { return $ this -> error ( 'Invalid language code. Valid is `en`, `eng`, `en_US` etc.' ) ; } $ model = $ this -> param ( 'model' ) ; if ( empty ( $ model ) ) { $ model = 'I18nMessages' ; } $ fields = [ 'domain' , 'singular' , 'plural' , 'context' ] ; $ model = TableRegistry :: get ( $ model ) ; $ messages = $ model -> find ( ) -> select ( $ fields ) -> distinct ( [ 'domain' , 'singular' , 'context' ] ) -> enableHydration ( false ) -> toArray ( ) ; $ entities = $ model -> newEntities ( $ messages ) ; $ return = $ model -> getConnection ( ) -> transactional ( function ( ) use ( $ model , $ entities , $ language ) { $ model -> deleteAll ( [ 'locale' => $ language , ] ) ; foreach ( $ entities as $ entity ) { $ entity -> set ( 'locale' , $ language ) ; if ( $ model -> save ( $ entity ) === false ) { return false ; } } } ) ; if ( $ return ) { $ this -> out ( 'Created ' . count ( $ messages ) . ' messages for "' . $ language . '"' ) ; } else { $ this -> out ( 'Unable to create messages for "' . $ language . '"' ) ; } } | Initialize a new languages from exiting messages . |
44,505 | public static function enable_direct_download ( ) { global $ pagenow ; if ( $ pagenow === 'tools.php' && isset ( $ _GET [ 'report' ] ) ) { if ( current_user_can ( 'administrator' ) && preg_match ( '/[0-9]{4}-[0-9]{2}\.html/' , $ _GET [ 'report' ] , $ matches ) ) { header ( 'Content-type: text/html' ) ; readfile ( '/data/slog/html/goaccess-' . $ matches [ 0 ] ) ; exit ( ) ; } else { exit ( 'Report file not found.' ) ; } } } | Pass report file on to admin users |
44,506 | public function updates ( $ args , $ assoc_args ) { require_once dirname ( __FILE__ ) . '/../modules/updates.php' ; $ site_info = Seravo \ Updates :: seravo_admin_get_site_info ( ) ; if ( $ site_info [ 'seravo_updates' ] === true ) { WP_CLI :: success ( 'Seravo Updates: enabled' ) ; } elseif ( $ site_info [ 'seravo_updates' ] === true ) { WP_CLI :: success ( 'Seravo Updates: disabled' ) ; } else { WP_CLI :: error ( 'Seravo API failed to return information about updates.' ) ; } } | Seravo wp - cli functions . |
44,507 | public static function getName ( int $ type ) : string { static $ types ; if ( 0 > $ type || 0xffff < $ type ) { $ message = \ sprintf ( '%d does not correspond to a valid record type (must be between 0 and 65535).' , $ type ) ; throw new \ Error ( $ message ) ; } if ( $ types === null ) { $ types = \ array_flip ( ( new \ ReflectionClass ( self :: class ) ) -> getConstants ( ) ) ; } return $ types [ $ type ] ?? "unknown ({$type})" ; } | Converts an record type integer back into its name as defined in this class . |
44,508 | public static function createBoundValidator ( $ methodName , ... $ boundArgs ) { return function ( ... $ args ) use ( $ methodName , $ boundArgs ) { return call_user_func_array ( "self::$methodName" , array_merge ( $ boundArgs , $ args ) ) ; } ; } | This provides a way to pass multiple arguments to a validator which would normally only be passed the single value argument . |
44,509 | private function locate ( $ file ) { if ( isset ( $ file [ 0 ] ) && '@' === $ file [ 0 ] ) { if ( false !== strpos ( $ file , '..' ) ) { throw new \ RuntimeException ( sprintf ( 'File name "%s" contains invalid characters (..).' , $ file ) ) ; } $ bundleName = substr ( $ file , 1 ) ; $ path = '' ; if ( false !== strpos ( $ bundleName , '/' ) ) { list ( $ bundleName , $ path ) = explode ( '/' , $ bundleName , 2 ) ; } $ bundle = $ this -> kernel -> getBundle ( $ bundleName ) ; $ file = $ bundle -> getPath ( ) . '/' . $ path ; } return $ file ; } | The implementation of this in FileLocator doesn t allow for files which don t exist so this is a simple reimplementation of that |
44,510 | public function reloadConfig ( ) : Promise { if ( $ this -> pendingConfig ) { return $ this -> pendingConfig ; } $ promise = call ( function ( ) { $ this -> config = yield $ this -> configLoader -> loadConfig ( ) ; } ) ; $ this -> pendingConfig = $ promise ; $ promise -> onResolve ( function ( ) { $ this -> pendingConfig = null ; } ) ; return $ promise ; } | Reloads the configuration in the background . |
44,511 | public static function isJson ( string $ string ) : bool { if ( is_numeric ( $ string ) || $ string === 'true' || $ string === 'false' || $ string === 'null' || empty ( $ string ) ) : return false ; endif ; json_decode ( $ string ) ; return json_last_error ( ) === JSON_ERROR_NONE ; } | Check JSON format |
44,512 | public static function prepareParse ( string $ input , bool $ allowFile ) : array { if ( $ allowFile === true && is_file ( $ input ) ) : $ input = file_get_contents ( $ input ) ; endif ; $ input = preg_replace ( "(\r\n|\n|\r)" , ';' , $ input ) ; $ input = explode ( ';' , $ input ) ; foreach ( $ input as & $ line ) : $ is_comment = mb_strpos ( $ line , '#' ) ; if ( $ is_comment !== false ) : $ line = substr ( $ line , 0 , $ is_comment ) ; endif ; $ line = trim ( $ line ) ; endforeach ; return $ input ; } | Generic action before parsing data from string input |
44,513 | public static function format ( $ input , bool $ convertObject = true ) { if ( is_object ( $ input ) ) : $ r = $ input ; if ( $ convertObject ) : if ( $ input instanceof Candidate ) : $ r = ( string ) $ input ; elseif ( $ input instanceof Vote ) : $ r = $ input -> getRanking ( ) ; elseif ( $ input instanceof Result ) : $ r = $ input -> getResultAsArray ( true ) ; endif ; endif ; elseif ( ! is_array ( $ input ) ) : $ r = $ input ; else : foreach ( $ input as $ key => $ line ) : $ input [ $ key ] = self :: format ( $ line , $ convertObject ) ; endforeach ; if ( count ( $ input ) === 1 && is_int ( key ( $ input ) ) && ( ! is_array ( reset ( $ input ) ) || count ( reset ( $ input ) ) === 1 ) ) : $ r = reset ( $ input ) ; else : $ r = $ input ; endif ; endif ; return $ r ; } | Simplify Condorcet Var_Dump . Transform object to String . |
44,514 | protected function prepareResult ( ) : bool { if ( $ this -> _State > 2 ) : return false ; elseif ( $ this -> _State === 2 ) : $ this -> cleanupResult ( ) ; $ this -> makePairwise ( ) ; $ this -> _State = 3 ; return true ; else : throw new CondorcetException ( 6 ) ; endif ; } | Prepare to compute results & caching system |
44,515 | protected function getStats ( ) : array { $ explicit = [ ] ; foreach ( $ this -> _StrongestPaths as $ candidate_key => $ candidate_value ) : $ candidate_key = $ this -> _selfElection -> getCandidateId ( $ candidate_key , true ) ; foreach ( $ candidate_value as $ challenger_key => $ challenger_value ) : $ explicit [ $ candidate_key ] [ $ this -> _selfElection -> getCandidateId ( $ challenger_key , true ) ] = $ challenger_value ; endforeach ; endforeach ; return $ explicit ; } | Get the Schulze ranking |
44,516 | protected function prepareStrongestPath ( ) : void { $ this -> _StrongestPaths = [ ] ; foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ candidate_key => $ candidate_id ) : $ this -> _StrongestPaths [ $ candidate_key ] = [ ] ; foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ candidate_key_r => $ candidate_id_r ) : if ( $ candidate_key_r != $ candidate_key ) : $ this -> _StrongestPaths [ $ candidate_key ] [ $ candidate_key_r ] = 0 ; endif ; endforeach ; endforeach ; } | Calculate the strongest Paths for Schulze Method |
44,517 | protected function makeStrongestPaths ( ) : void { foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ i => $ i_value ) : foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ j => $ j_value ) : if ( $ i !== $ j ) : if ( $ this -> _selfElection -> getPairwise ( false ) [ $ i ] [ 'win' ] [ $ j ] > $ this -> _selfElection -> getPairwise ( false ) [ $ j ] [ 'win' ] [ $ i ] ) : $ this -> _StrongestPaths [ $ i ] [ $ j ] = $ this -> schulzeVariant ( $ i , $ j ) ; else : $ this -> _StrongestPaths [ $ i ] [ $ j ] = 0 ; endif ; endif ; endforeach ; endforeach ; foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ i => $ i_value ) : foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ j => $ j_value ) : if ( $ i !== $ j ) : foreach ( $ this -> _selfElection -> getCandidatesList ( ) as $ k => $ k_value ) : if ( $ i !== $ k && $ j !== $ k ) : $ this -> _StrongestPaths [ $ j ] [ $ k ] = max ( $ this -> _StrongestPaths [ $ j ] [ $ k ] , min ( $ this -> _StrongestPaths [ $ j ] [ $ i ] , $ this -> _StrongestPaths [ $ i ] [ $ k ] ) ) ; endif ; endforeach ; endif ; endforeach ; endforeach ; } | Calculate the Strongest Paths |
44,518 | protected function makeRanking ( ) : void { $ result = [ ] ; $ done = array ( ) ; $ rank = 1 ; while ( count ( $ done ) < $ this -> _selfElection -> countCandidates ( ) ) : $ to_done = [ ] ; foreach ( $ this -> _StrongestPaths as $ candidate_key => $ challengers_key ) : if ( in_array ( $ candidate_key , $ done , true ) ) : continue ; endif ; $ winner = true ; foreach ( $ challengers_key as $ beaten_key => $ beaten_value ) : if ( in_array ( $ beaten_key , $ done , true ) ) : continue ; endif ; if ( $ beaten_value < $ this -> _StrongestPaths [ $ beaten_key ] [ $ candidate_key ] ) : $ winner = false ; endif ; endforeach ; if ( $ winner ) : $ result [ $ rank ] [ ] = $ candidate_key ; $ to_done [ ] = $ candidate_key ; endif ; endforeach ; $ done = array_merge ( $ done , $ to_done ) ; $ rank ++ ; endwhile ; $ this -> _Result = $ this -> createResult ( $ result ) ; } | Calculate && Format human readable ranking |
44,519 | public static function createFromKeys ( array $ keys ) : self { $ keys = \ array_filter ( $ keys , function ( ) { return true ; } ) ; foreach ( $ keys as $ k => $ v ) { if ( $ v -> has ( 'kid' ) ) { unset ( $ keys [ $ k ] ) ; $ keys [ $ v -> get ( 'kid' ) ] = $ v ; } } return new self ( $ keys ) ; } | Creates a JWKSet object using the given JWK objects . |
44,520 | public function getResult ( $ method = true , array $ options = [ ] ) : Result { $ options = self :: formatResultOptions ( $ options ) ; if ( $ options [ '%tagFilter' ] ) : $ chrono = new Timer_Chrono ( $ this -> _timer , 'GetResult with filter' ) ; $ filter = new self ; foreach ( $ this -> getCandidatesList ( ) as $ candidate ) : $ filter -> addCandidate ( $ candidate ) ; endforeach ; foreach ( $ this -> getVotesList ( $ options [ 'tags' ] , $ options [ 'withTag' ] ) as $ vote ) : $ filter -> addVote ( $ vote ) ; endforeach ; unset ( $ chrono ) ; return $ filter -> getResult ( $ method ) ; endif ; $ this -> prepareResult ( ) ; $ chrono = new Timer_Chrono ( $ this -> _timer ) ; if ( $ method === true ) : $ this -> initResult ( Condorcet :: getDefaultMethod ( ) ) ; $ result = $ this -> _Calculator [ Condorcet :: getDefaultMethod ( ) ] -> getResult ( ) ; elseif ( $ method = Condorcet :: isAuthMethod ( ( string ) $ method ) ) : $ this -> initResult ( $ method ) ; $ result = $ this -> _Calculator [ $ method ] -> getResult ( ) ; else : throw new CondorcetException ( 8 , $ method ) ; endif ; $ chrono -> setRole ( 'GetResult for ' . $ method ) ; return $ result ; } | Generic function for default result with ability to change default object method |
44,521 | protected function cleanupResult ( ) : void { if ( $ this -> _State > 2 ) : $ this -> _State = 2 ; endif ; $ this -> _Pairwise = null ; $ this -> _Calculator = null ; } | Cleanup results to compute again with new votes |
44,522 | public function countVotes ( $ tag = null , bool $ with = true ) : int { return $ this -> _Votes -> countVotes ( VoteUtil :: tagsConvert ( $ tag ) , $ with ) ; } | How many votes are registered ? |
44,523 | public function getVotesList ( $ tag = null , bool $ with = true ) : array { return $ this -> _Votes -> getVotesList ( VoteUtil :: tagsConvert ( $ tag ) , $ with ) ; } | Get the votes registered list |
44,524 | public function addVote ( $ vote , $ tag = null ) : Vote { $ this -> prepareVoteInput ( $ vote , $ tag ) ; if ( self :: $ _maxVoteNumber !== null && ! $ this -> _ignoreStaticMaxVote && $ this -> countVotes ( ) >= self :: $ _maxVoteNumber ) : throw new CondorcetException ( 16 , self :: $ _maxVoteNumber ) ; endif ; return $ this -> registerVote ( $ vote , $ tag ) ; } | Add a single vote . Array key is the rank each candidate in a rank are separate by It is not necessary to register the last rank . |
44,525 | public function prepareModifyVote ( Vote $ existVote ) : void { try { $ this -> prepareVoteInput ( $ existVote ) ; $ this -> setStateToVote ( ) ; if ( $ this -> _Votes -> isUsingHandler ( ) ) : $ this -> _Votes [ $ this -> getVoteKey ( $ existVote ) ] = $ existVote ; endif ; } catch ( \ Exception $ e ) { throw $ e ; } } | return True or throw an Exception |
44,526 | protected function registerVote ( Vote $ vote , $ tag = null ) : Vote { $ vote -> addTags ( $ tag ) ; try { $ vote -> registerLink ( $ this ) ; $ this -> _Votes [ ] = $ vote ; } catch ( CondorcetException $ e ) { throw new CondorcetException ( 6 , 'Vote object already registred' ) ; } return $ vote ; } | Write a new vote |
44,527 | protected function prepareVoteInput ( & $ vote , $ tag = null ) : void { if ( ! ( $ vote instanceof Vote ) ) : $ vote = new Vote ( $ vote , $ tag ) ; endif ; if ( ! $ this -> checkVoteCandidate ( $ vote ) ) : throw new CondorcetException ( 5 ) ; endif ; } | Return the well formated vote to use . |
44,528 | public static function getVersion ( string $ option = 'FULL' ) : string { if ( $ option === 'MAJOR' ) : $ version = explode ( '.' , self :: VERSION ) ; return $ version [ 0 ] . '.' . $ version [ 1 ] ; else : return self :: VERSION ; endif ; } | Return library version numer |
44,529 | public static function getAuthMethods ( bool $ basic = false ) : array { $ auth = self :: $ _authMethods ; if ( ! $ basic ) : unset ( $ auth [ self :: CONDORCET_BASIC_CLASS ] ) ; endif ; return array_column ( $ auth , 0 ) ; } | Return an array with auth methods |
44,530 | public static function isAuthMethod ( string $ method ) { $ auth = self :: $ _authMethods ; if ( empty ( $ method ) ) : throw new CondorcetException ( 8 ) ; endif ; if ( isset ( $ auth [ $ method ] ) ) : return $ method ; else : foreach ( $ auth as $ class => & $ alias ) : foreach ( $ alias as & $ entry ) : if ( strcasecmp ( $ method , $ entry ) === 0 ) : return $ class ; endif ; endforeach ; endforeach ; endif ; return false ; } | Check if the method is supported |
44,531 | public static function setDefaultMethod ( string $ method ) : bool { if ( ( $ method = self :: isAuthMethod ( $ method ) ) && $ method !== self :: CONDORCET_BASIC_CLASS ) : self :: $ _defaultMethod = $ method ; return true ; else : return false ; endif ; } | Change default method for this class . |
44,532 | public function selectOneEntity ( int $ key ) { try { $ this -> _prepare [ 'selectOneEntity' ] -> bindParam ( 1 , $ key , \ PDO :: PARAM_INT ) ; $ this -> _prepare [ 'selectOneEntity' ] -> execute ( ) ; $ r = $ this -> _prepare [ 'selectOneEntity' ] -> fetchAll ( \ PDO :: FETCH_NUM ) ; $ this -> _prepare [ 'selectOneEntity' ] -> closeCursor ( ) ; if ( ! empty ( $ r ) ) : return $ this -> _dataContextObject -> dataCallBack ( $ r [ 0 ] [ 1 ] ) ; else : return false ; endif ; } catch ( \ Exception $ e ) { throw $ e ; } } | return false if Entity does not exist . |
44,533 | public function getResult ( ) : Result { if ( $ this -> _Result === null ) : $ this -> calcPossibleRanking ( ) ; $ this -> calcRankingScore ( ) ; $ this -> makeRanking ( ) ; $ this -> conflictInfos ( ) ; endif ; return $ this -> _Result ; } | Get the Kemeny ranking |
44,534 | public function getResult ( ) : Result { if ( $ this -> _Result !== null ) : return $ this -> _Result ; endif ; $ this -> _Comparison = PairwiseStats :: PairwiseComparison ( $ this -> _selfElection -> getPairwise ( false ) ) ; $ this -> makeRanking ( ) ; return $ this -> _Result ; } | Get the ranking |
44,535 | protected function getStats ( ) : array { $ explicit = [ ] ; foreach ( $ this -> _Comparison as $ candidate_key => $ value ) : $ explicit [ $ this -> _selfElection -> getCandidateId ( $ candidate_key , true ) ] = [ $ this -> _countType => $ value [ $ this -> _countType ] ] ; endforeach ; return $ explicit ; } | Get the stats |
44,536 | public function getCandidatesList ( bool $ stringMode = false ) : array { if ( ! $ stringMode ) : return $ this -> _Candidates ; else : $ result = [ ] ; foreach ( $ this -> _Candidates as $ candidateKey => & $ oneCandidate ) : $ result [ $ candidateKey ] = $ oneCandidate -> getName ( ) ; endforeach ; return $ result ; endif ; } | Get the list of registered CANDIDATES |
44,537 | public function addCandidate ( $ candidate_id = null ) : Candidate { if ( $ this -> _State > 1 ) : throw new CondorcetException ( 2 ) ; endif ; if ( is_bool ( $ candidate_id ) || is_array ( $ candidate_id ) || ( is_object ( $ candidate_id ) && ! ( $ candidate_id instanceof Candidate ) ) ) : throw new CondorcetException ( 1 , $ candidate_id ) ; endif ; if ( empty ( $ candidate_id ) ) : while ( ! $ this -> canAddCandidate ( $ this -> _i_CandidateId ) ) : $ this -> _i_CandidateId ++ ; endwhile ; $ newCandidate = new Candidate ( $ this -> _i_CandidateId ) ; else : $ newCandidate = ( $ candidate_id instanceof Candidate ) ? $ candidate_id : new Candidate ( ( string ) $ candidate_id ) ; if ( ! $ this -> canAddCandidate ( $ newCandidate ) ) : throw new CondorcetException ( 3 , $ candidate_id ) ; endif ; endif ; $ this -> _Candidates [ ] = $ newCandidate ; $ newCandidate -> registerLink ( $ this ) ; $ newCandidate -> setProvisionalState ( false ) ; return $ newCandidate ; } | Add a vote candidate before voting |
44,538 | public function removeCandidate ( $ list ) : array { if ( $ this -> _State > 1 ) : throw new CondorcetException ( 2 ) ; endif ; if ( ! is_array ( $ list ) ) : $ list = [ $ list ] ; endif ; foreach ( $ list as & $ candidate_id ) : $ candidate_key = $ this -> getCandidateKey ( $ candidate_id ) ; if ( $ candidate_key === false ) : throw new CondorcetException ( 4 , $ candidate_id ) ; endif ; $ candidate_id = $ candidate_key ; endforeach ; $ rem = [ ] ; foreach ( $ list as $ candidate_key ) : $ this -> _Candidates [ $ candidate_key ] -> destroyLink ( $ this ) ; $ rem [ ] = $ this -> _Candidates [ $ candidate_key ] ; unset ( $ this -> _Candidates [ $ candidate_key ] ) ; endforeach ; return $ rem ; } | Destroy a register vote candidate before voting |
44,539 | public static function convertVoteInput ( string $ formula ) : array { $ ranking = explode ( '>' , $ formula ) ; foreach ( $ ranking as & $ rank_vote ) : $ rank_vote = explode ( '=' , $ rank_vote ) ; foreach ( $ rank_vote as & $ value ) : $ value = trim ( $ value ) ; endforeach ; endforeach ; return $ ranking ; } | From a string like A > B = C = H > G = T > Q |
44,540 | public function getResult ( ) : Result { if ( $ this -> _Result !== null ) : return $ this -> _Result ; endif ; $ this -> _PairwiseSort = $ this -> pairwiseSort ( ) ; $ this -> makeArcs ( ) ; $ this -> _Stats [ 'tally' ] = $ this -> _PairwiseSort ; $ this -> _Stats [ 'arcs' ] = $ this -> _Arcs ; return $ this -> _Result = $ this -> createResult ( $ this -> makeResult ( ) ) ; } | Get the Ranked Pairs ranking |
44,541 | protected function getStats ( ) : array { if ( ! $ this -> _StatsDone ) : foreach ( $ this -> _Stats [ 'tally' ] as & $ Roundvalue ) : foreach ( $ Roundvalue as $ ArcKey => & $ Arcvalue ) : foreach ( $ Arcvalue as $ key => & $ value ) : if ( $ key === 'from' || $ key === 'to' ) : $ value = $ this -> _selfElection -> getCandidateId ( $ value , true ) ; endif ; endforeach ; endforeach ; endforeach ; foreach ( $ this -> _Stats [ 'arcs' ] as $ ArcKey => & $ Arcvalue ) : foreach ( $ Arcvalue as $ key => & $ value ) : if ( $ key === 'from' || $ key === 'to' ) : $ value = $ this -> _selfElection -> getCandidateId ( $ value , true ) ; endif ; endforeach ; endforeach ; $ this -> _StatsDone = true ; endif ; return $ this -> _Stats ; } | Get the Ranked Pair ranking |
44,542 | public static function ini ( $ ini_file ) { if ( ! static :: _debug ( ) ) { return false ; } if ( ! $ _ = @ parse_ini_file ( $ ini_file , 1 ) ) { return false ; } if ( realpath ( $ ini_file ) ) { $ ini_file = realpath ( $ ini_file ) ; } static :: heading ( "This is a list of all the values from the " , $ ini_file , "INI file" ) ; return static :: dump ( $ _ ) ; } | Prints a list of all the values from an INI file . |
44,543 | private static function _config ( $ group , $ name , $ fallback = null ) { $ krumo_ini = KRUMO_DIR . 'krumo.ini' ; if ( empty ( static :: $ _config ) && is_readable ( $ krumo_ini ) ) { static :: $ _config = ( array ) parse_ini_file ( $ krumo_ini , true ) ; } if ( isset ( static :: $ _config [ $ group ] [ $ name ] ) ) { return static :: $ _config [ $ group ] [ $ name ] ; } else { return $ fallback ; } } | Returns values from Krumo s configuration |
44,544 | private static function _isCollapsed ( $ level , $ childCount ) { if ( static :: $ expand_all ) { return false ; } $ cascade = static :: $ _cascade ; if ( $ cascade == null ) { $ cascade = static :: _config ( 'display' , 'cascade' , array ( ) ) ; } if ( isset ( $ cascade [ $ level ] ) ) { return $ childCount >= $ cascade [ $ level ] ; } return true ; } | Determines if a given node will be collapsed or not . |
44,545 | public static function calculate_relative_path ( $ file , $ returnDir = false ) { $ doc_root = $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ ret = "/" . str_replace ( $ doc_root , "" , $ file , $ ok ) ; if ( ! $ ok ) { return false ; } if ( $ returnDir ) { $ ret = dirname ( $ ret ) . "/" ; } $ ret = preg_replace ( "|//|" , "/" , $ ret ) ; return $ ret ; } | Calculate the relative path of a given absolute URL |
44,546 | private static function _resource ( $ data , $ name ) { $ html = '<li class="krumo-child"> <div class="krumo-element" onMouseOver="krumo.over(this);" onMouseOut="krumo.out(this);"> <a class="krumo-name">%s</a> <em class="krumo-type">Resource</em> %s<strong class="krumo-resource">%s</strong> </div></li>' ; $ html = sprintf ( $ html , $ name , static :: get_separator ( ) , get_resource_type ( $ data ) ) ; echo $ html ; } | Render a dump for a resource |
44,547 | private static function _boolean ( $ data , $ name ) { $ value = '' ; if ( $ data == false ) { $ value = "FALSE" ; } elseif ( $ data == true ) { $ value = "TRUE" ; } $ html = '<li class="krumo-child"> <div class="krumo-element" onMouseOver="krumo.over(this);" onMouseOut="krumo.out(this);"> <a class="krumo-name">%s</a> <em class="krumo-type">Boolean</em> %s<strong class="krumo-boolean">%s</strong> </div></li>' ; $ html = sprintf ( $ html , $ name , static :: get_separator ( ) , $ value ) ; echo $ html ; } | Render a dump for a boolean value |
44,548 | protected function escape ( array $ data ) : array { $ arrayDot = array_filter ( array_dot ( $ data ) ) ; foreach ( $ arrayDot as $ key => $ value ) { if ( is_string ( $ value ) ) { $ arrayDot [ $ key ] = e ( $ value ) ; } } foreach ( $ arrayDot as $ key => $ value ) { array_set ( $ data , $ key , $ value ) ; } return $ data ; } | Escape all values . |
44,549 | private function registerAceEditorParameters ( array $ config , ContainerBuilder $ container ) { $ debug = $ container -> getParameter ( 'kernel.debug' ) ; if ( ! $ debug && $ config [ 'debug' ] ) { $ debug = true ; } $ mode = 'src' . ( $ debug ? '' : '-min' ) . ( $ config [ 'noconflict' ] ? '-noconflict' : '' ) ; $ container -> setParameter ( 'norzechowicz_ace_editor.options.autoinclude' , $ config [ 'autoinclude' ] ) ; $ container -> setParameter ( 'norzechowicz_ace_editor.options.base_path' , $ config [ 'base_path' ] ) ; $ container -> setParameter ( 'norzechowicz_ace_editor.options.mode' , $ mode ) ; } | Register parameters for the DI . |
44,550 | public static function registry ( ObjectRegistry $ registry = null ) { if ( $ registry ) { static :: $ _registry = $ registry ; } if ( empty ( static :: $ _registry ) ) { static :: $ _registry = new QueueEngineRegistry ( ) ; } return static :: $ _registry ; } | Returns the Queue Registry instance used for creating and using queue engines . Also allows for injecting of a new registry instance . |
44,551 | public static function queue ( $ config ) { if ( isset ( static :: $ _queuers [ $ config ] ) ) { return static :: $ _queuers [ $ config ] ; } $ engine = static :: engine ( $ config ) ; return static :: $ _queuers [ $ config ] = new Queuer ( $ engine ) ; } | Fetch the queue attached to a specific engine configuration name . |
44,552 | protected function _create ( $ class , $ alias , $ settings ) { if ( is_callable ( $ class ) ) { $ class = $ class ( $ alias ) ; } if ( is_object ( $ class ) ) { $ instance = $ class ; } if ( ! isset ( $ instance ) ) { $ key = PHP_SAPI === 'cli' ? 'stdout' : 'default' ; $ logger = Hash :: get ( $ settings , 'logger' , $ key ) ; if ( ! ( $ logger instanceof LoggerInterface ) ) { $ logger = Log :: engine ( $ logger ) ; } if ( ! ( $ logger instanceof LoggerInterface ) ) { $ logger = Log :: engine ( 'debug' ) ; } if ( $ logger === false ) { $ logger = null ; } $ instance = new $ class ( $ logger , $ settings ) ; } if ( $ instance instanceof EngineInterface ) { return $ instance ; } throw new RuntimeException ( 'Queue Engines must implement josegonzalez\Queuesadilla\Engine\EngineInterface.' ) ; } | Create the queue engine instance . |
44,553 | public function getEngine ( $ logger ) { $ config = Hash :: get ( $ this -> params , 'config' ) ; $ engine = Queue :: engine ( $ config ) ; $ engine -> setLogger ( $ logger ) ; if ( ! empty ( $ this -> params [ 'queue' ] ) ) { $ engine -> config ( 'queue' , $ this -> params [ 'queue' ] ) ; } return $ engine ; } | Retrieves a queue engine |
44,554 | public function getWorker ( $ engine , $ logger ) { $ worker = $ this -> params [ 'worker' ] ; $ WorkerClass = "josegonzalez\\Queuesadilla\\Worker\\" . $ worker . "Worker" ; return new $ WorkerClass ( $ engine , $ logger , [ 'queue' => $ engine -> config ( 'queue' ) , 'maxRuntime' => $ engine -> config ( 'maxRuntime' ) , 'maxIterations' => $ engine -> config ( 'maxIterations' ) ] ) ; } | Retrieves a queue worker |
44,555 | protected function cleanData ( array $ data ) : array { $ options = $ this -> getOptions ( ) ; $ disallowedDataKeys = array ( $ options -> getIdColumnName ( ) , $ options -> getLeftColumnName ( ) , $ options -> getRightColumnName ( ) , $ options -> getLevelColumnName ( ) , $ options -> getParentIdColumnName ( ) , ) ; if ( null !== $ options -> getScopeColumnName ( ) ) { $ disallowedDataKeys [ ] = $ options -> getScopeColumnName ( ) ; } return array_diff_key ( $ data , array_flip ( $ disallowedDataKeys ) ) ; } | Data cannot contain keys like idColumnName levelColumnName ... |
44,556 | public function initializeBackendEndUser ( ) { if ( $ this -> isBackEndUserInitialized === true ) { return ; } $ bootstrapObj = Bootstrap :: getInstance ( ) ; $ bootstrapObj -> loadExtensionTables ( true ) ; $ bootstrapObj -> initializeBackendUser ( ) ; $ bootstrapObj -> initializeBackendAuthentication ( true ) ; $ bootstrapObj -> initializeLanguageObject ( ) ; $ this -> isBackEndUserInitialized = true ; } | enable the usage of backend - user |
44,557 | public function initializeFrontEndUser ( $ pageId = 0 , $ type = 0 ) { if ( array_key_exists ( 'TSFE' , $ GLOBALS ) && is_object ( $ GLOBALS [ 'TSFE' ] -> fe_user ) ) { $ this -> isFrontEndUserInitialized = true ; } if ( $ this -> isFrontEndUserInitialized === true ) { return ; } $ tsfe = $ this -> getTsfe ( $ pageId , $ type ) ; $ tsfe -> initFEUser ( ) ; $ this -> isFrontEndUserInitialized = true ; } | enable the usage of frontend - user |
44,558 | public function initializeFrontEndRendering ( $ pageId = 0 , $ type = 0 ) { if ( array_key_exists ( 'TSFE' , $ GLOBALS ) && is_object ( $ GLOBALS [ 'TSFE' ] -> tmpl ) ) { $ this -> isFrontEndRenderingInitialized = true ; } if ( $ this -> isFrontEndRenderingInitialized === true ) { return ; } $ GLOBALS [ 'TT' ] = new NullTimeTracker ( ) ; if ( $ this -> isFrontEndUserInitialized === false ) { $ this -> initializeFrontEndUser ( $ pageId , $ type ) ; } EidUtility :: initTCA ( ) ; $ tsfe = $ this -> getTsfe ( $ pageId , $ type ) ; $ tsfe -> determineId ( ) ; $ tsfe -> initTemplate ( ) ; $ tsfe -> getConfigArray ( ) ; $ tsfe -> newCObj ( ) ; $ tsfe -> calculateLinkVars ( ) ; $ this -> isFrontEndRenderingInitialized = true ; } | enable the frontend - rendering |
44,559 | private function formatJson ( $ json ) { $ tab = ' ' ; $ newJson = '' ; $ indentLevel = 0 ; $ inString = false ; $ len = strlen ( $ json ) ; for ( $ c = 0 ; $ c < $ len ; $ c ++ ) { $ char = $ json [ $ c ] ; switch ( $ char ) { case '{' : case '[' : if ( ! $ inString ) { $ newJson .= $ char . "\n" . str_repeat ( $ tab , $ indentLevel + 1 ) ; $ indentLevel ++ ; } else { $ newJson .= $ char ; } break ; case '}' : case ']' : if ( ! $ inString ) { $ indentLevel -- ; $ newJson .= "\n" . str_repeat ( $ tab , $ indentLevel ) . $ char ; } else { $ newJson .= $ char ; } break ; case ',' : if ( ! $ inString ) { $ newJson .= ",\n" . str_repeat ( $ tab , $ indentLevel ) ; } else { $ newJson .= $ char ; } break ; case ':' : if ( ! $ inString ) { $ newJson .= ': ' ; } else { $ newJson .= $ char ; } break ; case '"' : if ( $ c == 0 ) { $ inString = true ; } elseif ( $ c > 0 && $ json [ $ c - 1 ] != '\\' ) { $ inString = ! $ inString ; } default : $ newJson .= $ char ; break ; } } return $ newJson ; } | Pretty print JSON string |
44,560 | public function restoreOriginalRestApiAuthenticationObjects ( ) { $ this -> removeRestApiAuthenticationObjects ( ) ; foreach ( $ this -> originalRestApiAuthenticationObjects as $ className => $ object ) { static :: $ instances [ $ className ] = $ object ; } } | Restore all initialized REST - API - authentication - objects which were already initialized before we call the REST - API - request via PHP |
44,561 | public function storeOriginalRestApiAuthenticationObjects ( ) { foreach ( $ this -> getOriginalRestApiRequest ( ) -> _authClasses as $ className ) { if ( array_key_exists ( $ className , static :: $ instances ) ) { $ this -> originalRestApiAuthenticationObjects [ $ className ] = static :: $ instances [ $ className ] ; } } } | store all REST - API - authentication - objects which where already initialized before we call the REST - API - request via PHP |
44,562 | public function getRequestData ( $ includeQueryParameters = true ) { $ requestData = array ( ) ; if ( $ this -> restApiRequestMethod == 'PUT' || $ this -> restApiRequestMethod == 'PATCH' || $ this -> restApiRequestMethod == 'POST' ) { $ requestData = array_merge ( $ this -> restApiPostData , array ( Defaults :: $ fullRequestDataName => $ this -> restApiPostData ) ) ; } if ( $ includeQueryParameters === true ) { return $ requestData + $ this -> restApiGetData ; } return $ requestData ; } | Override parent method ... because we must return the request - data of THIS REST - API request! The original method would return the request - data of the ORIGINAL called REST - API request |
44,563 | public function handle ( ) { $ this -> get ( ) ; if ( $ this -> requestMethod === 'GET' && $ this -> typo3Cache -> hasCacheEntry ( $ this -> url , $ _GET ) ) { return $ this -> handleRequestByTypo3Cache ( ) ; } if ( Defaults :: $ useVendorMIMEVersioning ) { $ this -> responseFormat = $ this -> negotiateResponseFormat ( ) ; } $ this -> route ( ) ; $ this -> negotiate ( ) ; $ this -> preAuthFilter ( ) ; $ this -> authenticate ( ) ; $ this -> postAuthFilter ( ) ; $ this -> validate ( ) ; $ this -> preCall ( ) ; $ this -> call ( ) ; $ this -> compose ( ) ; $ this -> postCall ( ) ; if ( $ this -> responseFormat instanceof JsonFormat ) { return $ this -> getRestApiJsonFormat ( ) -> decode ( $ this -> responseData ) ; } return $ this -> responseFormat -> decode ( $ this -> responseData ) ; } | Override parent method ... because we must return the data of the REST - API request and we need NO exception - handling! |
44,564 | public function build ( ) { $ this -> setAutoLoading ( ) ; $ this -> setCacheDirectory ( ) ; $ this -> setServerConfiguration ( ) ; $ restlerObj = $ this -> createRestlerObject ( ) ; $ this -> configureRestler ( $ restlerObj ) ; $ this -> addApiClassesByGlobalArray ( $ restlerObj ) ; return $ restlerObj ; } | initialize and configure restler - framework and return restler - object |
44,565 | private function addApiClassesByGlobalArray ( RestlerExtended $ restler ) { $ addApiController = $ GLOBALS [ 'TYPO3_Restler' ] [ 'addApiClass' ] ; if ( is_array ( $ addApiController ) ) { foreach ( $ addApiController as $ apiEndpoint => $ apiControllers ) { $ uniqueApiControllers = array_unique ( $ apiControllers ) ; foreach ( $ uniqueApiControllers as $ apiController ) { $ restler -> addAPIClass ( $ apiController , $ apiEndpoint ) ; } } } } | Add API - Controller - Classes that are registered by global array |
44,566 | public function handleRequest ( \ Psr \ Http \ Message \ ServerRequestInterface $ request ) { define ( 'REST_API_IS_RUNNING' , true ) ; $ objectManager = GeneralUtility :: makeInstance ( ObjectManager :: class ) ; $ objectManager -> get ( Dispatcher :: class ) -> dispatch ( ) ; } | Handles a frontend request |
44,567 | public function handle ( ) { $ this -> get ( ) ; if ( $ this -> requestMethod === 'GET' && $ this -> typo3Cache -> hasCacheEntry ( $ this -> url , $ _GET ) ) { return $ this -> handleRequestByTypo3Cache ( ) ; } return parent :: handle ( ) ; } | Main function for processing the api request and return the response |
44,568 | protected function postCall ( ) { parent :: postCall ( ) ; if ( $ this -> typo3Cache -> isResponseCacheableByTypo3Cache ( $ this -> requestMethod , $ this -> apiMethodInfo -> metadata ) ) { $ this -> typo3Cache -> cacheResponseByTypo3Cache ( $ this -> url , $ _GET , $ this -> apiMethodInfo -> metadata , $ this -> responseData , get_class ( $ this -> responseFormat ) , headers_list ( ) ) ; } } | override postCall so that we can cache response via TYPO3 - caching - framework - if it s possible |
44,569 | private function determinePageIdFromArguments ( ) { if ( empty ( $ this -> argumentNameOfPageId ) ) { return 0 ; } if ( false === array_key_exists ( $ this -> argumentNameOfPageId , $ this -> restler -> apiMethodInfo -> arguments ) ) { return 0 ; } $ index = $ this -> restler -> apiMethodInfo -> arguments [ $ this -> argumentNameOfPageId ] ; $ pageId = ( integer ) $ this -> restler -> apiMethodInfo -> parameters [ $ index ] ; return $ pageId ; } | determine pageId from arguments which restler has detected We need the pageId when we want to render TYPO3 - contentElements after the user is authenticated |
44,570 | protected function linkify ( $ text , $ urls = true , $ emails = true , array $ options = array ( ) ) { if ( false === $ urls && false === $ emails ) { return $ text ; } $ options = array_merge_recursive ( $ this -> options , $ options ) ; $ attr = '' ; if ( true === array_key_exists ( 'attr' , $ options ) ) { foreach ( $ options [ 'attr' ] as $ key => $ value ) { if ( true === is_array ( $ value ) ) { $ value = array_pop ( $ value ) ; } $ attr .= sprintf ( ' %s="%s"' , $ key , $ value ) ; } } $ options [ 'attr' ] = $ attr ; $ ignoreTags = array ( 'head' , 'link' , 'a' , 'script' , 'style' , 'code' , 'pre' , 'select' , 'textarea' , 'button' ) ; $ chunks = preg_split ( '/(<.+?>)/is' , $ text , 0 , PREG_SPLIT_DELIM_CAPTURE ) ; $ openTag = null ; for ( $ i = 0 ; $ i < count ( $ chunks ) ; $ i ++ ) { if ( $ i % 2 === 0 ) { if ( null === $ openTag ) { if ( true === $ urls ) { $ chunks [ $ i ] = $ this -> linkifyUrls ( $ chunks [ $ i ] , $ options ) ; } if ( true === $ emails ) { $ chunks [ $ i ] = $ this -> linkifyEmails ( $ chunks [ $ i ] , $ options ) ; } } } else { if ( null === $ openTag ) { if ( preg_match ( "`<(" . implode ( '|' , $ ignoreTags ) . ").*(?<!/)>$`is" , $ chunks [ $ i ] , $ matches ) ) { $ openTag = $ matches [ 1 ] ; } } else { if ( preg_match ( '`</\s*' . $ openTag . '>`i' , $ chunks [ $ i ] , $ matches ) ) { $ openTag = null ; } } } } $ text = implode ( $ chunks ) ; return $ text ; } | Add links to text . |
44,571 | protected function linkifyUrls ( $ text , $ options = array ( 'attr' => '' ) ) { $ pattern = '~(?xi) (?: ((ht|f)tps?://) # scheme:// | # or www\d{0,3}\. # "www.", "www1.", "www2." ... "www999." | # or www\- # "www-" | # or [a-z0-9.\-]+\.[a-z]{2,4}(?=/) # looks like domain name followed by a slash ) (?: # Zero or more: [^\s()<>]+ # Run of non-space, non-()<> | # or \((?>[^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels )* (?: # End with: \((?>[^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels | # or [^\s`!\-()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars ) ~u' ; $ callback = function ( $ match ) use ( $ options ) { $ caption = $ match [ 0 ] ; $ pattern = "~^(ht|f)tps?://~" ; if ( 0 === preg_match ( $ pattern , $ match [ 0 ] ) ) { $ match [ 0 ] = 'http://' . $ match [ 0 ] ; } if ( isset ( $ options [ 'callback' ] ) ) { $ cb = $ options [ 'callback' ] ( $ match [ 0 ] , $ caption , false ) ; if ( ! is_null ( $ cb ) ) { return $ cb ; } } return '<a href="' . $ match [ 0 ] . '"' . $ options [ 'attr' ] . '>' . $ caption . '</a>' ; } ; return preg_replace_callback ( $ pattern , $ callback , $ text ) ; } | Add HTML links to URLs in plain text . |
44,572 | protected function linkifyEmails ( $ text , $ options = array ( 'attr' => '' ) ) { $ pattern = '~(?xi) \b (?<!=) # Not part of a query string [A-Z0-9._\'%+-]+ # Username @ # At [A-Z0-9.-]+ # Domain \. # Dot [A-Z]{2,4} # Something ~u' ; $ callback = function ( $ match ) use ( $ options ) { if ( isset ( $ options [ 'callback' ] ) ) { $ cb = $ options [ 'callback' ] ( $ match [ 0 ] , $ match [ 0 ] , true ) ; if ( ! is_null ( $ cb ) ) { return $ cb ; } } return '<a href="mailto:' . $ match [ 0 ] . '"' . $ options [ 'attr' ] . '>' . $ match [ 0 ] . '</a>' ; } ; return preg_replace_callback ( $ pattern , $ callback , $ text ) ; } | Add HTML links to email addresses in plain text . |
44,573 | protected function parseXMLFromResponse ( ) { $ xml = $ this -> response -> getBody ( ) -> getContents ( ) ; $ parse = simplexml_load_string ( str_replace ( [ 'soap:' , 'ns2:' , ] , null , $ xml ) ) ; $ this -> parsedXML = json_decode ( json_encode ( $ parse -> Body ) , true ) ; return $ this ; } | Formata o XML do corpo da resposta . |
44,574 | protected function setFreightDimensionsOnPayload ( ) { if ( $ this -> items ) { $ this -> payload [ 'nVlLargura' ] = $ this -> width ( ) ; $ this -> payload [ 'nVlAltura' ] = $ this -> height ( ) ; $ this -> payload [ 'nVlComprimento' ] = $ this -> length ( ) ; $ this -> payload [ 'nVlDiametro' ] = 0 ; $ this -> payload [ 'nVlPeso' ] = $ this -> useWeightOrVolume ( ) ; } return $ this ; } | Calcula largura altura comprimento peso e volume do frete no payload . |
44,575 | public function getData ( ) { return [ self :: GIVEN_NAMES_ATTR => $ this -> givenNames , self :: FAMILY_NAME_ATTR => $ this -> familyName , self :: SSN_ATTR => $ this -> ssn , self :: ADDRESS_ATTR => $ this -> amlAddress -> getData ( ) , ] ; } | Get Aml profile data . |
44,576 | function _stream_seek ( $ offset , $ whence ) { switch ( $ whence ) { case SEEK_SET : if ( $ offset >= $ this -> size || $ offset < 0 ) { return false ; } break ; case SEEK_CUR : $ offset += $ this -> pos ; break ; case SEEK_END : $ offset += $ this -> size ; } $ this -> pos = $ offset ; $ this -> eof = false ; return true ; } | Seeks to specific location in a stream |
44,577 | function _stream_metadata ( $ path , $ option , $ var ) { $ path = $ this -> _parse_path ( $ path ) ; if ( $ path === false ) { return false ; } switch ( $ option ) { case 1 : return $ this -> sftp -> touch ( $ path , $ var [ 0 ] , $ var [ 1 ] ) ; case 2 : case 3 : return false ; case 4 : return $ this -> sftp -> chown ( $ path , $ var ) ; case 5 : return $ this -> sftp -> chgrp ( $ path , $ var ) ; case 6 : return $ this -> sftp -> chmod ( $ path , $ var ) !== false ; } } | Change stream options |
44,578 | function _nlist_helper ( $ dir , $ recursive , $ relativeDir ) { $ files = $ this -> _list ( $ dir , false ) ; if ( ! $ recursive || $ files === false ) { return $ files ; } $ result = array ( ) ; foreach ( $ files as $ value ) { if ( $ value == '.' || $ value == '..' ) { if ( $ relativeDir == '' ) { $ result [ ] = $ value ; } continue ; } if ( is_array ( $ this -> _query_stat_cache ( $ this -> _realpath ( $ dir . '/' . $ value ) ) ) ) { $ temp = $ this -> _nlist_helper ( $ dir . '/' . $ value , true , $ relativeDir . $ value . '/' ) ; $ result = array_merge ( $ result , $ temp ) ; } else { $ result [ ] = $ relativeDir . $ value ; } } return $ result ; } | Helper method for nlist |
44,579 | function _query_stat_cache ( $ path ) { $ dirs = explode ( '/' , preg_replace ( '#^/|/(?=/)|/$#' , '' , $ path ) ) ; $ temp = & $ this -> stat_cache ; foreach ( $ dirs as $ dir ) { if ( ! isset ( $ temp [ $ dir ] ) ) { return null ; } $ temp = & $ temp [ $ dir ] ; } return $ temp ; } | Checks cache for path |
44,580 | function _stat ( $ filename , $ type ) { $ packet = pack ( 'Na*' , strlen ( $ filename ) , $ filename ) ; if ( ! $ this -> _send_sftp_packet ( $ type , $ packet ) ) { return false ; } $ response = $ this -> _get_sftp_packet ( ) ; switch ( $ this -> packet_type ) { case NET_SFTP_ATTRS : return $ this -> _parseAttributes ( $ response ) ; case NET_SFTP_STATUS : $ this -> _logError ( $ response ) ; return false ; } user_error ( 'Expected SSH_FXP_ATTRS or SSH_FXP_STATUS' ) ; return false ; } | Returns general information about a file or symbolic link |
44,581 | function _setstat_recursive ( $ path , $ attr , & $ i ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; $ entries = $ this -> _list ( $ path , true ) ; if ( $ entries === false ) { return $ this -> _setstat ( $ path , $ attr , false ) ; } if ( empty ( $ entries ) ) { return false ; } unset ( $ entries [ '.' ] , $ entries [ '..' ] ) ; foreach ( $ entries as $ filename => $ props ) { if ( ! isset ( $ props [ 'type' ] ) ) { return false ; } $ temp = $ path . '/' . $ filename ; if ( $ props [ 'type' ] == NET_SFTP_TYPE_DIRECTORY ) { if ( ! $ this -> _setstat_recursive ( $ temp , $ attr , $ i ) ) { return false ; } } else { if ( ! $ this -> _send_sftp_packet ( NET_SFTP_SETSTAT , pack ( 'Na*a*' , strlen ( $ temp ) , $ temp , $ attr ) ) ) { return false ; } $ i ++ ; if ( $ i >= NET_SFTP_QUEUE_SIZE ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } } } if ( ! $ this -> _send_sftp_packet ( NET_SFTP_SETSTAT , pack ( 'Na*a*' , strlen ( $ path ) , $ path , $ attr ) ) ) { return false ; } $ i ++ ; if ( $ i >= NET_SFTP_QUEUE_SIZE ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } return true ; } | Recursively sets information on directories on the SFTP server |
44,582 | function _delete_recursive ( $ path , & $ i ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; $ entries = $ this -> _list ( $ path , true ) ; if ( empty ( $ entries ) ) { return false ; } unset ( $ entries [ '.' ] , $ entries [ '..' ] ) ; foreach ( $ entries as $ filename => $ props ) { if ( ! isset ( $ props [ 'type' ] ) ) { return false ; } $ temp = $ path . '/' . $ filename ; if ( $ props [ 'type' ] == NET_SFTP_TYPE_DIRECTORY ) { if ( ! $ this -> _delete_recursive ( $ temp , $ i ) ) { return false ; } } else { if ( ! $ this -> _send_sftp_packet ( NET_SFTP_REMOVE , pack ( 'Na*' , strlen ( $ temp ) , $ temp ) ) ) { return false ; } $ this -> _remove_from_stat_cache ( $ temp ) ; $ i ++ ; if ( $ i >= NET_SFTP_QUEUE_SIZE ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } } } if ( ! $ this -> _send_sftp_packet ( NET_SFTP_RMDIR , pack ( 'Na*' , strlen ( $ path ) , $ path ) ) ) { return false ; } $ this -> _remove_from_stat_cache ( $ path ) ; $ i ++ ; if ( $ i >= NET_SFTP_QUEUE_SIZE ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } return true ; } | Recursively deletes directories on the SFTP server |
44,583 | function file_exists ( $ path ) { if ( $ this -> use_stat_cache ) { $ path = $ this -> _realpath ( $ path ) ; $ result = $ this -> _query_stat_cache ( $ path ) ; if ( isset ( $ result ) ) { return $ result !== false ; } } return $ this -> stat ( $ path ) !== false ; } | Checks whether a file or directory exists |
44,584 | function is_dir ( $ path ) { $ result = $ this -> _get_stat_cache_prop ( $ path , 'type' ) ; if ( $ result === false ) { return false ; } return $ result === NET_SFTP_TYPE_DIRECTORY ; } | Tells whether the filename is a directory |
44,585 | function is_file ( $ path ) { $ result = $ this -> _get_stat_cache_prop ( $ path , 'type' ) ; if ( $ result === false ) { return false ; } return $ result === NET_SFTP_TYPE_REGULAR ; } | Tells whether the filename is a regular file |
44,586 | function is_link ( $ path ) { $ result = $ this -> _get_lstat_cache_prop ( $ path , 'type' ) ; if ( $ result === false ) { return false ; } return $ result === NET_SFTP_TYPE_SYMLINK ; } | Tells whether the filename is a symbolic link |
44,587 | function is_readable ( $ path ) { $ path = $ this -> _realpath ( $ path ) ; $ packet = pack ( 'Na*N2' , strlen ( $ path ) , $ path , NET_SFTP_OPEN_READ , 0 ) ; if ( ! $ this -> _send_sftp_packet ( NET_SFTP_OPEN , $ packet ) ) { return false ; } $ response = $ this -> _get_sftp_packet ( ) ; switch ( $ this -> packet_type ) { case NET_SFTP_HANDLE : return true ; case NET_SFTP_STATUS : return false ; default : user_error ( 'Expected SSH_FXP_HANDLE or SSH_FXP_STATUS' ) ; return false ; } } | Tells whether a file exists and is readable |
44,588 | function filetype ( $ path ) { $ type = $ this -> _get_stat_cache_prop ( $ path , 'type' ) ; if ( $ type === false ) { return false ; } switch ( $ type ) { case NET_SFTP_TYPE_BLOCK_DEVICE : return 'block' ; case NET_SFTP_TYPE_CHAR_DEVICE : return 'char' ; case NET_SFTP_TYPE_DIRECTORY : return 'dir' ; case NET_SFTP_TYPE_FIFO : return 'fifo' ; case NET_SFTP_TYPE_REGULAR : return 'file' ; case NET_SFTP_TYPE_SYMLINK : return 'link' ; default : return false ; } } | Gets file type |
44,589 | function _get_xstat_cache_prop ( $ path , $ prop , $ type ) { if ( $ this -> use_stat_cache ) { $ path = $ this -> _realpath ( $ path ) ; $ result = $ this -> _query_stat_cache ( $ path ) ; if ( is_object ( $ result ) && isset ( $ result -> $ type ) ) { return $ result -> { $ type } [ $ prop ] ; } } $ result = $ this -> $ type ( $ path ) ; if ( $ result === false || ! isset ( $ result [ $ prop ] ) ) { return false ; } return $ result [ $ prop ] ; } | Return a stat or lstat properity |
44,590 | function getSupportedVersions ( ) { $ temp = array ( 'version' => $ this -> version ) ; if ( isset ( $ this -> extensions [ 'versions' ] ) ) { $ temp [ 'extensions' ] = $ this -> extensions [ 'versions' ] ; } return $ temp ; } | Get supported SFTP versions |
44,591 | private function setExpirationDate ( array $ parsedValues ) { $ expirationDate = null ; if ( isset ( $ parsedValues [ self :: EXPIRATION_INDEX ] ) ) { $ dateStr = $ parsedValues [ self :: EXPIRATION_INDEX ] ; if ( $ dateStr !== '-' ) { $ expirationDate = \ DateTime :: createFromFormat ( 'Y-m-d' , $ dateStr ) ; if ( ! $ expirationDate ) { throw new AttributeException ( 'Invalid Date provided' ) ; } } } $ this -> expirationDate = $ expirationDate ; } | Set expirationDate to DateTime object or NULL if the value is - |
44,592 | public function setMethods ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Method :: class ) ; $ this -> methods = $ arr ; return $ this ; } | The methods of this interface in unspecified order . |
44,593 | public function setOptions ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Option :: class ) ; $ this -> options = $ arr ; return $ this ; } | Any metadata attached to the interface . |
44,594 | public function setReservedName ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> reserved_name = $ arr ; $ this -> has_reserved_name = true ; return $ this ; } | Reserved field names which may not be used by fields in the same message . A given name may only be reserved once . |
44,595 | public function getData ( ) { return [ self :: POSTCODE_ATTR => $ this -> postcode , self :: COUNTRY_ATTR => $ this -> country -> getCode ( ) , ] ; } | Get address data . |
44,596 | function setPublicKey ( $ key = false , $ type = false ) { if ( ! empty ( $ this -> publicExponent ) ) { return false ; } if ( $ key === false && ! empty ( $ this -> modulus ) ) { $ this -> publicExponent = $ this -> exponent ; return true ; } if ( $ type === false ) { $ types = array ( self :: PUBLIC_FORMAT_RAW , self :: PUBLIC_FORMAT_PKCS1 , self :: PUBLIC_FORMAT_XML , self :: PUBLIC_FORMAT_OPENSSH ) ; foreach ( $ types as $ type ) { $ components = $ this -> _parseKey ( $ key , $ type ) ; if ( $ components !== false ) { break ; } } } else { $ components = $ this -> _parseKey ( $ key , $ type ) ; } if ( $ components === false ) { return false ; } if ( empty ( $ this -> modulus ) || ! $ this -> modulus -> equals ( $ components [ 'modulus' ] ) ) { $ this -> modulus = $ components [ 'modulus' ] ; $ this -> exponent = $ this -> publicExponent = $ components [ 'publicExponent' ] ; return true ; } $ this -> publicExponent = $ components [ 'publicExponent' ] ; return true ; } | Defines the public key |
44,597 | function getPublicKeyFingerprint ( $ algorithm = 'md5' ) { if ( empty ( $ this -> modulus ) || empty ( $ this -> publicExponent ) ) { return false ; } $ modulus = $ this -> modulus -> toBytes ( true ) ; $ publicExponent = $ this -> publicExponent -> toBytes ( true ) ; $ RSAPublicKey = pack ( 'Na*Na*Na*' , strlen ( 'ssh-rsa' ) , 'ssh-rsa' , strlen ( $ publicExponent ) , $ publicExponent , strlen ( $ modulus ) , $ modulus ) ; switch ( $ algorithm ) { case 'sha256' : $ hash = new Hash ( 'sha256' ) ; $ base = base64_encode ( $ hash -> hash ( $ RSAPublicKey ) ) ; return substr ( $ base , 0 , strlen ( $ base ) - 1 ) ; case 'md5' : return substr ( chunk_split ( md5 ( $ RSAPublicKey ) , 2 , ':' ) , 0 , - 1 ) ; default : return false ; } } | Returns the public key s fingerprint |
44,598 | function getPrivateKey ( $ type = self :: PUBLIC_FORMAT_PKCS1 ) { if ( empty ( $ this -> primes ) ) { return false ; } $ oldFormat = $ this -> privateKeyFormat ; $ this -> privateKeyFormat = $ type ; $ temp = $ this -> _convertPrivateKey ( $ this -> modulus , $ this -> publicExponent , $ this -> exponent , $ this -> primes , $ this -> exponents , $ this -> coefficients ) ; $ this -> privateKeyFormat = $ oldFormat ; return $ temp ; } | Returns the private key |
44,599 | function _encodeLength ( $ length ) { if ( $ length <= 0x7F ) { return chr ( $ length ) ; } $ temp = ltrim ( pack ( 'N' , $ length ) , chr ( 0 ) ) ; return pack ( 'Ca*' , 0x80 | strlen ( $ temp ) , $ temp ) ; } | DER - encode the length |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.