idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
24,600 | public static function readFile ( $ package ) { $ root = dirname ( dirname ( dirname ( dirname ( dirname ( dirname ( __FILE__ ) ) ) ) ) ) ; $ path = implode ( DIRECTORY_SEPARATOR , array ( $ root , $ package , 'composer.json' ) ) ; Logger :: trace ( "Reading composer file %s" , $ path ) ; if ( file_exists ( $ path ) ) { $ composer = json_decode ( file_get_contents ( $ path ) , true ) ; if ( array_key_exists ( 'require' , $ composer ) && ! empty ( $ composer [ 'require' ] ) ) { $ directories = array ( $ package ) ; Logger :: trace ( "Checking dependencies for package %s" , $ package ) ; foreach ( $ composer [ 'require' ] as $ requirement => $ version ) { $ directories = array_merge ( self :: readFile ( $ requirement ) , $ directories ) ; } return $ directories ; } else { Logger :: trace ( "Package %s has no dependencies" , $ package ) ; return array ( $ package ) ; } } else { return array ( ) ; } } | Recursively reads a package and all the child dependency packages and returns a list of packages |
24,601 | protected function writePaymentSlipLines ( $ elementName , array $ element ) { if ( ! is_string ( $ elementName ) ) { throw new \ InvalidArgumentException ( '$elementName is not a string!' ) ; } if ( ! isset ( $ element [ 'lines' ] ) ) { throw new \ InvalidArgumentException ( '$element contains not "lines" key!' ) ; } if ( ! isset ( $ element [ 'attributes' ] ) ) { throw new \ InvalidArgumentException ( '$element contains not "attributes" key!' ) ; } $ lines = $ element [ 'lines' ] ; $ attributes = $ element [ 'attributes' ] ; if ( ! is_array ( $ lines ) ) { throw new \ InvalidArgumentException ( '$lines is not an array!' ) ; } if ( ! is_array ( $ attributes ) ) { throw new \ InvalidArgumentException ( '$attributes is not an array!' ) ; } $ posX = $ attributes [ 'PosX' ] ; $ posY = $ attributes [ 'PosY' ] ; $ height = $ attributes [ 'Height' ] ; $ width = $ attributes [ 'Width' ] ; $ fontFamily = $ attributes [ 'FontFamily' ] ; $ background = $ attributes [ 'Background' ] ; $ fontSize = $ attributes [ 'FontSize' ] ; $ fontColor = $ attributes [ 'FontColor' ] ; $ lineHeight = $ attributes [ 'LineHeight' ] ; $ textAlign = $ attributes [ 'TextAlign' ] ; $ this -> setFont ( $ fontFamily , $ fontSize , $ fontColor ) ; if ( $ background != 'transparent' ) { $ this -> setBackground ( $ background ) ; $ fill = true ; } else { $ fill = false ; } foreach ( $ lines as $ lineNr => $ line ) { $ this -> setPosition ( $ this -> paymentSlip -> getSlipPosX ( ) + $ posX , $ this -> paymentSlip -> getSlipPosY ( ) + $ posY + ( $ lineNr * $ lineHeight ) ) ; $ this -> createCell ( $ width , $ height , $ line , $ textAlign , $ fill ) ; } return $ this ; } | Write the lines of an element to the PDf |
24,602 | public function createPaymentSlip ( PaymentSlip $ paymentSlip ) { $ this -> paymentSlip = $ paymentSlip ; if ( $ paymentSlip -> getDisplayBackground ( ) ) { $ this -> displayImage ( $ paymentSlip -> getSlipBackground ( ) ) ; } $ elements = $ paymentSlip -> getAllElements ( ) ; foreach ( $ elements as $ elementName => $ element ) { $ this -> writePaymentSlipLines ( $ elementName , $ element ) ; } $ this -> paymentSlip = null ; return $ this ; } | Create a payment slip as a PDF using the PDF engine |
24,603 | public function setTable ( string $ table ) : self { $ this -> table = $ this -> agent -> escapeIdentifier ( $ table ) ; return $ this ; } | Set table . |
24,604 | public function selectMore ( $ field , string $ as = null ) : self { return $ this -> select ( $ field , $ as , false ) ; } | Select more . |
24,605 | public function selectJsonMore ( $ field , string $ as , string $ type = 'object' ) : self { return $ this -> selectJson ( $ field , $ as , $ type , false ) ; } | Select json more . |
24,606 | public function selectRandom ( $ field ) : self { return $ this -> push ( 'select' , $ this -> prepareField ( $ field ) ) -> push ( 'where' , [ [ $ this -> sql ( 'random() < 0.01' ) , '' ] ] ) ; } | Select random . |
24,607 | public function joinLeft ( string $ to , string $ as , string $ on , $ onParams = null ) : self { return $ this -> join ( $ to , $ as , $ on , $ onParams , 'LEFT' ) ; } | Join left . |
24,608 | public function joinUsing ( string $ to , string $ as , string $ using , $ usingParams = null , string $ type = '' ) : self { return $ this -> push ( 'join' , sprintf ( '%sJOIN %s AS %s USING (%s)' , $ type ? strtoupper ( $ type ) . ' ' : '' , $ this -> prepareField ( $ to ) , $ this -> agent -> quoteField ( $ as ) , $ this -> agent -> prepareIdentifier ( $ using , $ usingParams ) ) ) ; } | Join using . |
24,609 | public function joinLeftUsing ( string $ to , string $ as , string $ using , $ usingParams = null ) : self { return $ this -> joinUsing ( $ to , $ as , $ using , $ usingParams , 'LEFT' ) ; } | Join left using . |
24,610 | public function whereEqual ( $ field , $ param , string $ op = '' ) : self { return $ this -> where ( $ this -> prepareField ( $ field ) . ' = ?' , $ param , $ op ) ; } | Where equal . |
24,611 | public function whereNull ( $ field , string $ op = '' ) : self { return $ this -> where ( $ this -> prepareField ( $ field ) . ' IS NULL' , null , $ op ) ; } | Where null . |
24,612 | public function whereIn ( $ field , $ param , string $ op = '' ) : self { $ ops = [ '?' ] ; if ( is_array ( $ param ) ) { $ ops = array_fill ( 0 , count ( $ param ) , '?' ) ; } return $ this -> where ( $ this -> prepareField ( $ field ) . ' IN (' . join ( ', ' , $ ops ) . ')' , $ param , $ op ) ; } | Where in . |
24,613 | public function whereBetween ( $ field , array $ params , string $ op = '' ) : self { return $ this -> where ( $ this -> prepareField ( $ field ) . ' BETWEEN ? AND ?' , $ params , $ op ) ; } | Where between . |
24,614 | public function whereLike ( $ field , $ arguments , bool $ ilike = false , bool $ not = false , string $ op = '' ) : self { $ arguments = ( array ) $ arguments ; $ searchArguments = array_slice ( $ arguments , 0 , 3 ) ; if ( $ arguments != null ) { $ field = $ this -> agent -> prepare ( $ field , array_slice ( $ arguments , 3 ) ) ; } $ search = '' ; switch ( count ( $ searchArguments ) ) { case 1 : [ $ start , $ search , $ end ] = [ '' , $ searchArguments [ 0 ] , '' ] ; break ; case 2 : if ( $ searchArguments [ 0 ] == '%' ) { [ $ start , $ search , $ end ] = [ '%' , $ searchArguments [ 1 ] , '' ] ; } elseif ( $ searchArguments [ 1 ] == '%' ) { [ $ start , $ search , $ end ] = [ '' , $ searchArguments [ 0 ] , '%' ] ; } break ; case 3 : [ $ start , $ search , $ end ] = $ searchArguments ; break ; } $ search = trim ( ( string ) $ search ) ; if ( $ search == '' ) { throw new BuilderException ( 'Like search cannot be empty!' ) ; } $ not = $ not ? 'NOT ' : '' ; if ( is_string ( $ field ) && strpos ( $ field , '(' ) === false ) { $ field = $ this -> prepareField ( $ field , false ) ; } $ search = $ end . $ this -> agent -> escape ( $ search , '%sl' , false ) . $ start ; $ where = [ ] ; $ fields = ( array ) $ field ; if ( ! $ ilike ) { foreach ( $ fields as $ field ) { $ where [ ] = sprintf ( "%s %sLIKE '%s'" , $ field , $ not , $ search ) ; } } else { foreach ( $ fields as $ field ) { if ( $ this -> agent -> isMysql ( ) ) { $ where [ ] = sprintf ( "lower(%s) %sLIKE lower('%s')" , $ field , $ not , $ search ) ; } elseif ( $ this -> agent -> isPgsql ( ) ) { $ where [ ] = sprintf ( "%s %sILIKE '%s'" , $ field , $ not , $ search ) ; } } } $ where = count ( $ where ) > 1 ? '(' . join ( ' OR ' , $ where ) . ')' : join ( ' OR ' , $ where ) ; return $ this -> where ( $ where ) ; } | Where like . |
24,615 | public function whereNotLike ( $ field , $ arguments , bool $ ilike = false , string $ op = '' ) : self { return $ this -> whereLike ( $ field , $ arguments , $ ilike , true , $ op ) ; } | Where not like . |
24,616 | public function whereLikeBoth ( $ field , string $ search , bool $ ilike = false , bool $ not = false , string $ op = '' ) : self { return $ this -> whereLike ( $ field , [ '%' , $ search , '%' ] , $ ilike , $ not , $ op ) ; } | Where like both . |
24,617 | public function whereExists ( $ query , array $ queryParams = null , string $ op = '' ) : self { if ( $ query instanceof Builder ) { $ query = $ query -> toString ( ) ; } if ( $ queryParams != null ) { $ query = $ this -> agent -> prepare ( $ query , $ queryParams ) ; } return $ this -> where ( 'EXISTS (' . $ query . ')' , null , $ op ) ; } | Where exists . |
24,618 | public function whereId ( string $ field , $ id , string $ op = '' ) : self { return $ this -> where ( '?? = ?' , [ $ field , $ id ] , $ op ) ; } | Where id . |
24,619 | public function whereIds ( string $ field , array $ ids , string $ op = '' ) : self { return $ this -> where ( '?? IN (?)' , [ $ field , $ ids ] , $ op ) ; } | Where ids . |
24,620 | public function orderBy ( $ field , string $ op = null ) : self { if ( $ op == null ) { return $ this -> push ( 'orderBy' , $ this -> prepareField ( $ field ) ) ; } $ op = strtoupper ( $ op ) ; if ( $ op != self :: OP_ASC && $ op != self :: OP_DESC ) { throw new BuilderException ( 'Available ops: ASC, DESC' ) ; } return $ this -> push ( 'orderBy' , $ this -> prepareField ( $ field ) . ' ' . $ op ) ; } | Order by . |
24,621 | private function prepareField ( $ field , bool $ join = true ) { if ( $ field == '*' ) { return $ field ; } if ( $ field instanceof Builder || $ field instanceof Sql ) { return '(' . $ field -> toString ( ) . ')' ; } elseif ( $ field instanceof Identifier ) { return $ this -> agent -> escapeIdentifier ( $ field ) ; } if ( is_string ( $ field ) ) { $ field = Util :: split ( ',' , trim ( $ field ) ) ; } if ( is_array ( $ field ) ) { return $ this -> agent -> escapeIdentifier ( $ field , $ join ) ; } throw new BuilderException ( sprintf ( 'String, array or Builder type fields are accepted only,' . ' %s given' , gettype ( $ field ) ) ) ; } | Prepare field . |
24,622 | public static function sanitizeCountry ( $ locale , $ default = null ) { if ( $ locale instanceof Locale ) { return $ locale -> getCountry ( ) ; } if ( $ default ) { $ default = Locale :: sanitizeCountry ( $ default , null ) ; } $ locale = ( string ) $ locale ; $ locale = trim ( $ locale ) ; if ( ! $ locale || ! preg_match ( "/(?<country>[a-z]{2})$/ui" , $ locale , $ found ) ) { return $ default ; } return Text :: toUpper ( $ found [ 'country' ] ) ; } | Sanitize given country from locale . |
24,623 | public static function sanitizeLanguage ( $ locale , $ default = null ) { if ( $ locale instanceof Locale ) { return $ locale -> getLanguage ( ) ; } if ( $ default ) { $ default = Locale :: sanitizeLanguage ( $ default , null ) ; } $ locale = ( string ) $ locale ; $ locale = trim ( $ locale ) ; if ( ! $ locale || ! preg_match ( "/^(?<language>[a-z]{2})/ui" , $ locale , $ found ) ) { return $ default ; } return Text :: toLower ( $ found [ 'language' ] ) ; } | Sanitize given language from locale . |
24,624 | public static function sanitizeLocale ( $ locale , $ default = null ) { if ( $ locale instanceof Locale ) { return $ locale -> getLocale ( ) ; } if ( $ default ) { $ default = Locale :: sanitizeLocale ( $ default , null ) ; } $ locale = ( string ) $ locale ; $ locale = trim ( $ locale ) ; if ( ! $ locale || ! preg_match ( "/^" . Locale :: REGEX_LOCALE . "$/ui" , $ locale , $ found ) ) { return $ default ; } $ found [ 'language' ] = Text :: toLower ( $ found [ 'language' ] ) ; $ found [ 'country' ] = Text :: toUpper ( $ found [ 'country' ] ) ; return sprintf ( "%s_%s" , $ found [ 'language' ] , $ found [ 'country' ] ) ; } | Sanitize given locale . |
24,625 | public function getCountryName ( $ inLocale = null ) { $ inLocale = Locale :: sanitizeLocale ( $ inLocale , $ this -> locale ) ; return \ Locale :: getDisplayRegion ( $ this -> locale , $ inLocale ) ; } | Get country name . |
24,626 | public function getCountryNameFor ( $ locale , $ inLocale = null ) { $ locale = '_' . Locale :: sanitizeCountry ( $ locale ) ; $ inLocale = Locale :: sanitizeLanguage ( $ inLocale , $ this -> locale ) ; return \ Locale :: getDisplayRegion ( $ locale , $ inLocale ) ; } | Get country name for specified locale or country - code . |
24,627 | public function getLanguageName ( $ inLocale = null ) { $ inLocale = Locale :: sanitizeLocale ( $ inLocale , $ this -> locale ) ; return \ Locale :: getDisplayLanguage ( $ this -> locale , $ inLocale ) ; } | Get language name . |
24,628 | public function getLanguageNameFor ( $ locale , $ inLocale = null ) { $ locale = Locale :: sanitizeLanguage ( $ locale ) . '_' ; $ inLocale = Locale :: sanitizeLanguage ( $ inLocale , $ this -> locale ) ; return \ Locale :: getDisplayLanguage ( $ locale , $ inLocale ) ; } | Get language name for specified locale or language - code . |
24,629 | public function getLocaleName ( $ inLocale = null ) { $ inLocale = Locale :: sanitizeLocale ( $ inLocale , $ this -> locale ) ; return \ Locale :: getDisplayName ( $ this -> locale , $ inLocale ) ; } | Get locale name . |
24,630 | public static function toStackTrace ( $ ex ) { $ list = [ ] ; for ( $ stack = Throwable :: getThrowableStack ( $ ex ) ; $ stack !== null ; $ stack = $ stack [ 'prev' ] ) { $ list = array_merge ( $ stack [ 'trace' ] , $ list ) ; } return $ list ; } | Return Exception stack trace in array format . |
24,631 | public static function toThrowableTrace ( $ ex ) { $ list = [ ] ; for ( $ stack = Throwable :: getThrowableStack ( $ ex ) ; $ stack !== null ; $ stack = $ stack [ 'prev' ] ) { $ list [ ] = Throwable :: parseThrowableMessage ( $ stack ) ; } return array_reverse ( $ list ) ; } | Return Exception throwable trace in array format . |
24,632 | public static function toStackString ( $ ex ) { $ stack = [ ] ; $ i = 0 ; $ trace = static :: toStackTrace ( $ ex ) ; $ pad = strlen ( count ( $ trace ) ) > 2 ? : 2 ; foreach ( $ trace as $ element ) { $ stack [ ] = "\t" . str_pad ( '' . $ i , $ pad , ' ' , STR_PAD_LEFT ) . '. ' . $ element ; ++ $ i ; } return implode ( "\n" , $ stack ) ; } | Return Exception stack trace in string format . |
24,633 | public static function toThrowableString ( $ ex ) { $ stack = [ ] ; $ i = 0 ; $ trace = static :: toThrowableTrace ( $ ex ) ; $ pad = strlen ( count ( $ trace ) ) > 2 ? : 2 ; foreach ( $ trace as $ element ) { $ stack [ ] = "\t" . str_pad ( '' . $ i , $ pad , ' ' , STR_PAD_LEFT ) . '. ' . $ element ; ++ $ i ; } return implode ( "\n" , $ stack ) ; } | Return Exception throwable trace in string format . |
24,634 | private function loadRatings ( Map $ map ) { try { $ this -> mapRatingsService -> load ( $ map ) ; } catch ( PropelException $ e ) { $ this -> logger -> error ( "error loading map ratings" , [ "exception" => $ e ] ) ; } } | helper function to load mapratings for current map |
24,635 | protected function fetchDataFromRemote ( Filesystem $ fileSytem , ContainerBuilder $ container ) { $ curl = new Curl ( ) ; $ curl -> setUrl ( "https://mp-expansion.com/api/maniaplanet/toZto" ) ; $ curl -> run ( ) ; if ( $ curl -> getCurlInfo ( ) [ 'http_code' ] == 200 ) { $ fileSytem -> put ( self :: MAPPINGS_FILE , $ curl -> getResponse ( ) ) ; } else { echo "Can't fetch title mappings from expansion website!\n" ; } } | Fetch title information from eXp api . |
24,636 | private function parseFunctionArgument ( $ funcName , $ context ) { try { return $ this -> parsePrimitiveValue ( ) ; } catch ( \ Exception $ e ) { $ name = $ this -> tokenizer -> getTokenValue ( ) ; if ( $ name ) { $ this -> tokenizer -> readNextToken ( ) ; if ( $ this -> tokenizer -> is ( TokenType :: LEFT_PAREN ) ) { return $ this -> parseFunctionExpression ( $ name , $ context ) ; } return new AST \ SoqlName ( $ name ) ; } throw $ e ; } } | Parses a single function argument . Can be expression or function by itself . |
24,637 | private function parseOrderByField ( ) { $ retVal = null ; $ fieldName = $ this -> tokenizer -> getTokenValue ( ) ; $ this -> tokenizer -> expect ( TokenType :: EXPRESSION ) ; if ( $ this -> tokenizer -> is ( TokenType :: LEFT_PAREN ) ) { $ retVal = new AST \ OrderByFunction ( $ this -> parseFunctionExpression ( $ fieldName , Functions \ SoqlFunctionInterface :: CONTEXT_ORDER_BY ) ) ; } else { $ retVal = new AST \ OrderByField ( $ fieldName ) ; } if ( $ this -> tokenizer -> isKeyword ( 'asc' ) ) { $ retVal -> setDirection ( AST \ OrderByField :: DIRECTION_ASC ) ; $ this -> tokenizer -> readNextToken ( ) ; } elseif ( $ this -> tokenizer -> isKeyword ( 'desc' ) ) { $ retVal -> setDirection ( AST \ OrderByField :: DIRECTION_DESC ) ; $ this -> tokenizer -> readNextToken ( ) ; } if ( $ this -> tokenizer -> isKeyword ( 'NULLS' ) ) { $ this -> tokenizer -> readNextToken ( ) ; if ( $ this -> tokenizer -> isKeyword ( 'last' ) ) { $ retVal -> setNulls ( AST \ OrderByField :: NULLS_LAST ) ; } elseif ( $ this -> tokenizer -> isKeyword ( 'first' ) ) { $ retVal -> setNulls ( AST \ OrderByField :: NULLS_FIRST ) ; } else { throw new ParseException ( sprintf ( 'Unexpected "%s"' , $ this -> tokenizer -> getTokenValue ( ) ) , $ this -> tokenizer -> getLine ( ) , $ this -> tokenizer -> getLinePos ( ) , $ this -> tokenizer -> getInput ( ) ) ; } $ this -> tokenizer -> expect ( TokenType :: KEYWORD ) ; } return $ retVal ; } | ORDER BY fieldExpression ASC | DESC ? NULLS FIRST | LAST ? |
24,638 | protected function createLoggerInstance ( $ handler , $ target ) { $ handlerClassName = $ handler . 'Handler' ; if ( class_exists ( '\Monolog\Logger' ) && class_exists ( '\Monolog\Handler\\' . $ handlerClassName ) ) { if ( null !== $ handlerInstance = $ this -> createHandlerInstance ( $ handlerClassName , $ target ) ) { $ this -> instance = new \ Monolog \ Logger ( 'main' ) ; $ this -> instance -> pushHandler ( $ handlerInstance ) ; } $ this -> handler = $ handler ; $ this -> target = $ target ; } } | Create a Monolog \ Logger instance and attach a handler |
24,639 | protected function createHandlerInstance ( $ className , $ handlerArgs ) { if ( method_exists ( $ this , 'init' . $ className ) ) { return call_user_func ( array ( $ this , 'init' . $ className ) , explode ( ',' , $ handlerArgs ) ) ; } else { return null ; } } | Create an Monolog Handler instance |
24,640 | public function setMap ( ChildMap $ v = null ) { if ( $ v === null ) { $ this -> setTrackuid ( NULL ) ; } else { $ this -> setTrackuid ( $ v -> getMapuid ( ) ) ; } $ this -> aMap = $ v ; if ( $ v !== null ) { $ v -> addMxmap ( $ this ) ; } return $ this ; } | Declares an association between this object and a ChildMap object . |
24,641 | public function getMap ( ConnectionInterface $ con = null ) { if ( $ this -> aMap === null && ( ( $ this -> trackuid !== "" && $ this -> trackuid !== null ) ) ) { $ this -> aMap = ChildMapQuery :: create ( ) -> filterByMxmap ( $ this ) -> findOne ( $ con ) ; } return $ this -> aMap ; } | Get the associated ChildMap object |
24,642 | public function get_content_type ( ) { $ headers = wp_remote_retrieve_headers ( $ this -> response ) ; if ( ! $ headers ) { return ; } if ( ! is_object ( $ headers ) || ! method_exists ( $ headers , 'offsetGet' ) ) { return ; } return $ headers -> offsetGet ( 'content-type' ) ; } | Return content type of the page you want to blog card |
24,643 | public function get_content ( ) { $ content = wp_remote_retrieve_body ( $ this -> response ) ; if ( empty ( $ content ) ) { return ; } return $ this -> _encode ( $ content ) ; } | Return response body |
24,644 | private function executeCommand ( array $ parameters , string $ command ) { foreach ( $ parameters as $ index => $ object ) { $ parameters [ $ index ] [ 'command' ] = $ command ; } $ result = $ this -> execute ( $ parameters ) ; if ( isset ( $ index ) ) { unset ( $ index ) ; } if ( isset ( $ object ) ) { unset ( $ object ) ; } unset ( $ parameters ) ; unset ( $ command ) ; return $ result ; } | Executes single command . |
24,645 | public function validate ( $ key ) : bool { if ( ! is_string ( $ key ) || strlen ( $ key ) === 0 || $ key === '.' || $ key === '..' || strpos ( $ key , '/../' ) !== false || strpos ( $ key , '/./' ) !== false || strpos ( $ key , '/' ) === 0 || strpos ( $ key , './' ) === 0 || strpos ( $ key , '../' ) === 0 || substr ( $ key , - 2 ) === '/.' || substr ( $ key , - 3 ) === '/..' || substr ( $ key , - 1 ) === '/' ) { return false ; } return preg_match ( "/^[a-z0-9\.\/\-\_]*$/" , $ key ) === 1 ; } | Checks whether the key specified is valid . |
24,646 | private function createFileDirIfNotExists ( string $ filename ) : bool { $ pathinfo = pathinfo ( $ filename ) ; if ( isset ( $ pathinfo [ 'dirname' ] ) && $ pathinfo [ 'dirname' ] !== '.' ) { if ( is_dir ( $ pathinfo [ 'dirname' ] ) ) { return true ; } elseif ( is_file ( $ pathinfo [ 'dirname' ] ) ) { return false ; } else { return $ this -> createDirIfNotExists ( $ pathinfo [ 'dirname' ] ) ; } } return false ; } | Creates the directory of the file specified . |
24,647 | private function createDirIfNotExists ( string $ dir ) : bool { if ( ! is_dir ( $ dir ) ) { try { set_error_handler ( function ( $ errno , $ errstr , $ errfile , $ errline ) { restore_error_handler ( ) ; throw new \ IvoPetkov \ ObjectStorage \ ErrorException ( $ errstr , 0 , $ errno , $ errfile , $ errline ) ; } ) ; $ result = mkdir ( $ dir , 0777 , true ) ; restore_error_handler ( ) ; return ( bool ) $ result ; } catch ( \ IvoPetkov \ ObjectStorage \ ErrorException $ e ) { if ( $ e -> getMessage ( ) !== 'mkdir(): File exists' ) { throw $ e ; } } } return true ; } | Creates a directory if not existent . |
24,648 | private function getFiles ( string $ dir , bool $ recursive = false , $ limit = null ) : array { if ( $ limit === 0 ) { return [ ] ; } $ result = [ ] ; if ( is_dir ( $ dir ) ) { $ list = scandir ( $ dir ) ; if ( is_array ( $ list ) ) { foreach ( $ list as $ filename ) { if ( $ filename != '.' && $ filename != '..' ) { if ( is_dir ( $ dir . $ filename ) ) { if ( $ recursive === true ) { $ dirResult = $ this -> getFiles ( $ dir . $ filename . '/' , true , $ limit !== null ? ( $ limit - sizeof ( $ result ) ) : null ) ; if ( ! empty ( $ dirResult ) ) { foreach ( $ dirResult as $ index => $ value ) { $ dirResult [ $ index ] = $ filename . '/' . $ value ; } $ result = array_merge ( $ result , $ dirResult ) ; } } } else { $ result [ ] = $ filename ; if ( $ limit !== null && $ limit === sizeof ( $ result ) ) { break ; } } } } } } return $ result ; } | Returns list of files in the directory specified . |
24,649 | public function isCompatible ( Map $ map ) : bool { if ( ! $ map -> lapRace ) { return false ; } $ nbLaps = 1 ; if ( $ map -> lapRace ) { $ nbLaps = $ map -> nbLaps ; } $ scriptSettings = $ this -> gameDataStorage -> getScriptOptions ( ) ; if ( $ scriptSettings [ 'S_ForceLapsNb' ] != - 1 ) { $ nbLaps = $ scriptSettings [ 'S_ForceLapsNb' ] ; } return $ nbLaps > 1 ; } | Check if data provider is compatible with current situation . |
24,650 | public function compile ( $ string , $ filename = null ) { $ compiler = $ this -> getCompiler ( ) ; $ this -> setDebugString ( $ string ) ; $ this -> setDebugFile ( $ filename ) ; $ this -> setDebugFormatter ( $ compiler -> getFormatter ( ) ) ; return $ compiler -> compile ( $ string , $ filename ) ; } | Compile a pug template string into a PHP string . |
24,651 | public function compileFile ( $ path ) { $ compiler = $ this -> getCompiler ( ) ; $ this -> setDebugFile ( $ path ) ; $ this -> setDebugFormatter ( $ compiler -> getFormatter ( ) ) ; return $ compiler -> compileFile ( $ path ) ; } | Compile a pug template file into a PHP string . |
24,652 | public function renderAndWriteFile ( $ inputFile , $ outputFile , array $ parameters = [ ] ) { $ outputDirectory = dirname ( $ outputFile ) ; if ( ! file_exists ( $ outputDirectory ) && ! @ mkdir ( $ outputDirectory , 0777 , true ) ) { return false ; } return is_int ( $ this -> getNewSandBox ( function ( ) use ( $ outputFile , $ inputFile , $ parameters ) { return file_put_contents ( $ outputFile , $ this -> renderFile ( $ inputFile , $ parameters ) ) ; } ) -> getResult ( ) ) ; } | Render a pug file and dump it into a file . Return true if the render and the writing succeeded . |
24,653 | public function renderDirectory ( $ path , $ destination = null , $ extension = '.html' , array $ parameters = [ ] ) { if ( is_array ( $ destination ) ) { $ parameters = $ destination ; $ destination = null ; } elseif ( is_array ( $ extension ) ) { $ parameters = $ extension ; $ extension = '.html' ; } if ( ! $ destination ) { $ destination = $ path ; } $ path = realpath ( $ path ) ; $ destination = realpath ( $ destination ) ; $ success = 0 ; $ errors = 0 ; if ( $ path && $ destination ) { $ path = rtrim ( $ path , '/\\' ) ; $ destination = rtrim ( $ destination , '/\\' ) ; $ length = mb_strlen ( $ path ) ; foreach ( $ this -> scanDirectory ( $ path ) as $ file ) { $ relativeDirectory = trim ( mb_substr ( dirname ( $ file ) , $ length ) , '//\\' ) ; $ filename = pathinfo ( $ file , PATHINFO_FILENAME ) ; $ outputDirectory = $ destination . DIRECTORY_SEPARATOR . $ relativeDirectory ; $ counter = $ this -> renderAndWriteFile ( $ file , $ outputDirectory . DIRECTORY_SEPARATOR . $ filename . $ extension , $ parameters ) ? 'success' : 'errors' ; $ $ counter ++ ; } } return [ $ success , $ errors ] ; } | Render all pug template files in an input directory and output in an other or the same directory . Return an array with success count and error count . |
24,654 | private function loadCommands ( ContainerBuilder $ container , $ user ) { $ container -> setDefinition ( 'bengor.user.command.create_' . $ user . '_command' , ( new Definition ( CreateUserCommand :: class ) ) -> addTag ( 'console.command' ) ) ; $ container -> setDefinition ( 'bengor.user.command.change_' . $ user . '_password_command' , ( new Definition ( ChangePasswordCommand :: class ) ) -> addTag ( 'console.command' ) ) ; $ container -> setDefinition ( 'bengor.user.command.purge_outdated_' . $ user . '_invitation_tokens_command' , ( new Definition ( PurgeOutdatedInvitationTokensCommand :: class ) ) -> addTag ( 'console.command' ) ) ; $ container -> setDefinition ( 'bengor.user.command.purge_outdated_' . $ user . '_remember_password_tokens_command' , ( new Definition ( PurgeOutdatedRememberPasswordTokensCommand :: class ) ) -> addTag ( 'console.command' ) ) ; } | Loads commands as a service inside Symfony console . |
24,655 | protected function fetch ( $ id , $ name , $ cache_id , $ compile_id , & $ content , & $ mtime ) { $ this -> fetch -> execute ( array ( 'id' => $ id ) ) ; $ row = $ this -> fetch -> fetch ( ) ; $ this -> fetch -> closeCursor ( ) ; if ( $ row ) { $ content = $ row [ 'content' ] ; $ mtime = strtotime ( $ row [ 'modified' ] ) ; } else { $ content = null ; $ mtime = null ; } } | fetch cached content and its modification time from data source |
24,656 | protected function fetchTimestamp ( $ id , $ name , $ cache_id , $ compile_id ) { $ this -> fetchTimestamp -> execute ( array ( 'id' => $ id ) ) ; $ mtime = strtotime ( $ this -> fetchTimestamp -> fetchColumn ( ) ) ; $ this -> fetchTimestamp -> closeCursor ( ) ; return $ mtime ; } | Fetch cached content s modification timestamp from data source |
24,657 | protected function save ( $ id , $ name , $ cache_id , $ compile_id , $ exp_time , $ content ) { $ this -> save -> execute ( array ( 'id' => $ id , 'name' => $ name , 'cache_id' => $ cache_id , 'compile_id' => $ compile_id , 'content' => $ content , ) ) ; return ! ! $ this -> save -> rowCount ( ) ; } | Save content to cache |
24,658 | protected function delete ( $ name , $ cache_id , $ compile_id , $ exp_time ) { if ( $ name === null && $ cache_id === null && $ compile_id === null && $ exp_time === null ) { $ query = $ this -> db -> query ( 'TRUNCATE TABLE output_cache' ) ; return - 1 ; } $ where = array ( ) ; if ( $ name !== null ) { $ where [ ] = 'name = ' . $ this -> db -> quote ( $ name ) ; } if ( $ compile_id !== null ) { $ where [ ] = 'compile_id = ' . $ this -> db -> quote ( $ compile_id ) ; } if ( $ exp_time !== null ) { $ where [ ] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval ( $ exp_time ) . ' SECOND)' ; } if ( $ cache_id !== null ) { $ where [ ] = '(cache_id = ' . $ this -> db -> quote ( $ cache_id ) . ' OR cache_id LIKE ' . $ this -> db -> quote ( $ cache_id . '|%' ) . ')' ; } $ query = $ this -> db -> query ( 'DELETE FROM output_cache WHERE ' . join ( ' AND ' , $ where ) ) ; return $ query -> rowCount ( ) ; } | Delete content from cache |
24,659 | public function render ( $ src , $ class = '' , $ id = '' , array $ attrs = array ( ) ) { $ attrs = array_merge ( array ( 'frameborder' => 0 , 'content' => null , 'tag' => 'iframe' , 'src' => Str :: trim ( $ src ) ) , $ attrs ) ; $ attrs = $ this -> _cleanAttrs ( $ attrs ) ; $ content = $ attrs [ 'content' ] ; unset ( $ attrs [ 'content' ] ) ; return Html :: _ ( 'tag' ) -> render ( $ content , Str :: trim ( $ class ) , Str :: trim ( $ id ) , $ attrs ) ; } | Create iframe . |
24,660 | public function onLocalRecordsLoaded ( $ records , BaseRecords $ baseRecords ) { if ( ! $ this -> checkRecordPlugin ( $ baseRecords ) ) { return ; } if ( count ( $ records ) > 0 ) { $ this -> updater -> setLocalRecord ( $ records [ 0 ] -> getPlayer ( ) -> getNickname ( ) , $ records [ 0 ] -> getCheckpoints ( ) ) ; } else { $ this -> updater -> setLocalRecord ( "-" , [ ] ) ; } } | Called when local records are loaded . |
24,661 | public function formatStackOperationOptions ( array $ settings ) { $ data = [ ] ; foreach ( $ settings as $ name => $ value ) { $ data [ ] = $ name . ':' . $ value ; } return implode ( ' | ' , $ data ) ; } | Build a string representation for the StackOperation s options attribute . |
24,662 | public function outputImageInfo ( SourceImage $ sourceImage , OutputInterface $ output ) { $ output -> writeln ( [ ' Hash: <info>' . $ sourceImage -> hash . '</info>' , ' Organization: <info>' . $ sourceImage -> organization . '</info>' , ' Name: <info>' . $ sourceImage -> name . '</info>' , ' Size: <info>' . $ sourceImage -> size . '</info>' , ' Format: <info>' . $ sourceImage -> format . '</info>' , ' Created: <info>' . $ sourceImage -> created -> format ( 'Y-m-d H:i:s' ) . '</info>' , ' Dimensions: <info>' . $ sourceImage -> width . 'x' . $ sourceImage -> height . '</info>' , ] ) ; if ( $ output -> isVerbose ( ) ) { $ output -> writeln ( ' BinaryHash: <info>' . $ sourceImage -> binaryHash . '</info>' ) ; } if ( ! empty ( $ sourceImage -> dynamicMetadata ) ) { if ( ! $ output -> isVerbose ( ) ) { $ metaNames = array_keys ( $ sourceImage -> dynamicMetadata ) ; $ output -> writeln ( ' DynamicMetadatas (' . \ count ( $ metaNames ) . '): ' . implode ( ', ' , $ metaNames ) ) ; } else { $ output -> writeln ( ' DynamicMetadatas:' ) ; foreach ( $ sourceImage -> dynamicMetadata as $ name => $ meta ) { $ output -> writeln ( ' - <info>' . $ name . '</info> ' . $ this -> formatDynamicMetadata ( $ meta ) ) ; } } } } | Print information about a source image from rokka . |
24,663 | public function outputOrganizationInfo ( Organization $ org , OutputInterface $ output ) { $ output -> writeln ( [ ' ID: <info>' . $ org -> getId ( ) . '</info>' , ' Name: <info>' . $ org -> getName ( ) . '</info>' , ' Display Name: <info>' . $ org -> getDisplayName ( ) . '</info>' , ' Billing eMail: <info>' . $ org -> getBillingEmail ( ) . '</info>' , ] ) ; } | Print information about a rokka organization . |
24,664 | public function outputOrganizationMembershipInfo ( Membership $ membership , OutputInterface $ output ) { $ output -> writeln ( [ ' ID: <info>' . $ membership -> userId . '</info>' , ' Roles: <info>' . json_encode ( $ membership -> roles ) . '</info>' , ' Active: <info>' . ( $ membership -> active ? 'True' : 'False' ) . '</info>' , ' Last Access: <info>' . $ membership -> lastAccess -> format ( 'c' ) . '</info>' , ] ) ; } | Print information about an organization membership . |
24,665 | public function outputStackInfo ( Stack $ stack , OutputInterface $ output ) { $ output -> writeln ( ' Name: <info>' . $ stack -> getName ( ) . '</info>' ) ; $ output -> writeln ( ' Created: <info>' . $ stack -> getCreated ( ) -> format ( 'Y-m-d H:i:s' ) . '</info>' ) ; $ operations = $ stack -> getStackOperations ( ) ; if ( ! empty ( $ operations ) ) { $ output -> writeln ( ' Operations:' ) ; foreach ( $ stack -> getStackOperations ( ) as $ operation ) { $ output -> write ( ' ' . $ operation -> name . ': ' ) ; $ output -> writeln ( $ this -> formatStackOperationOptions ( $ operation -> options ) ) ; } } $ options = $ stack -> getStackOptions ( ) ; if ( ! empty ( $ options ) ) { $ output -> writeln ( ' Options:' ) ; foreach ( $ stack -> getStackOptions ( ) as $ name => $ value ) { $ output -> write ( ' ' . $ name . ': ' ) ; $ output -> writeln ( '<info>' . $ value . '</info>' ) ; } } } | Print information about a rokka stack . |
24,666 | public function outputUserInfo ( User $ user , OutputInterface $ output ) { $ output -> writeln ( [ ' ID: <info>' . $ user -> getId ( ) . '</info>' , ' eMail: <info>' . $ user -> getEmail ( ) . '</info>' , ' API-Key: <info>' . $ user -> getApiKey ( ) . '</info>' , ] ) ; } | Print information about a rokka user . |
24,667 | private function formatDynamicMetadata ( DynamicMetadataInterface $ metadata ) { $ info = null ; switch ( $ metadata :: getName ( ) ) { case SubjectArea :: getName ( ) : $ data = [ ] ; foreach ( [ 'x' , 'y' , 'width' , 'height' ] as $ property ) { $ data [ ] = $ property . ':' . $ metadata -> $ property ; } $ info = implode ( '|' , $ data ) ; break ; } return $ info ; } | Convert dynamic metadata information to a string . |
24,668 | private function attachAgent ( ) : void { $ this -> agentName = strtolower ( ( string ) $ this -> config [ 'agent' ] ) ; switch ( $ this -> agentName ) { case self :: AGENT_MYSQL : $ this -> agent = new Mysql ( $ this -> config ) ; break ; case self :: AGENT_PGSQL : $ this -> agent = new Pgsql ( $ this -> config ) ; break ; default : throw new LinkException ( "Sorry, but '{$this->agentName}' agent not implemented!" ) ; } } | Attach agent . |
24,669 | protected function actionCreateObject ( ) { $ blockCenter = new XmlBlockCollection ( $ this -> _myWords -> Value ( "OBJECT" ) , BlockPosition :: Center ) ; $ breakLine = new XmlnukeBreakLine ( ) ; $ firstParagraph = new XmlParagraphCollection ( ) ; $ firstParagraph -> addXmlnukeObject ( new XmlnukeText ( $ this -> _myWords -> Value ( "OBJECTTEXT1" ) ) ) ; $ firstParagraph -> addXmlnukeObject ( $ breakLine ) ; $ firstParagraph -> addXmlnukeObject ( new XmlnukeText ( $ this -> _myWords -> Value ( "OBJECTTEXT2" ) , true , true , true , true ) ) ; $ firstParagraph -> addXmlnukeObject ( $ breakLine ) ; $ firstParagraph -> addXmlnukeObject ( new XmlnukeText ( $ this -> _myWords -> Value ( "OBJECTTEXT3" ) ) ) ; $ secondParagraph = new XmlParagraphCollection ( ) ; $ secondParagraph -> addXmlnukeObject ( new XmlnukeText ( $ this -> _myWords -> Value ( "OBJECTTEXT4" ) ) ) ; $ secondParagraph -> addXmlnukeObject ( $ breakLine ) ; $ secondParagraph -> addXmlnukeObject ( $ breakLine ) ; $ xmlnukeImage = new XmlnukeImage ( "common/imgs/logo_xmlnuke.gif" ) ; $ link = new XmlAnchorCollection ( "engine:xmlnuke" , "" ) ; $ link -> addXmlnukeObject ( new XmlnukeText ( $ this -> _myWords -> Value ( "CLICK" ) . " ) ) ; $ link -> addXmlnukeObject ( $ breakLine ) ; $ link -> addXmlnukeObject ( $ xmlnukeImage ) ; $ link -> addXmlnukeObject ( $ breakLine ) ; $ link -> addXmlnukeObject ( new XmlnukeText ( " -- " . $ this -> _myWords -> Value ( "CLICK" ) ) ) ; $ secondParagraph -> addXmlnukeObject ( $ link ) ; $ secondParagraph -> addXmlnukeObject ( $ breakLine ) ; $ thirdParagraph = new XmlParagraphCollection ( ) ; $ arrayOptions = array ( ) ; $ arrayOptions [ "OPTION1" ] = $ this -> _myWords -> Value ( "OPTIONTEST1" ) ; $ arrayOptions [ "OPTION2" ] = $ this -> _myWords -> Value ( "OPTIONTEST2" ) ; $ arrayOptions [ "OPTION3" ] = $ this -> _myWords -> Value ( "OPTIONTEST3" ) ; $ arrayOptions [ "OPTION4" ] = $ this -> _myWords -> Value ( "OPTIONTEST4" ) ; $ thirdParagraph -> addXmlnukeObject ( new XmlEasyList ( EasyListType :: UNORDEREDLIST , "name" , "caption" , $ arrayOptions , "OP3" ) ) ; $ blockCenter -> addXmlnukeObject ( $ firstParagraph ) ; $ blockCenter -> addXmlnukeObject ( $ secondParagraph ) ; $ blockCenter -> addXmlnukeObject ( $ thirdParagraph ) ; $ blockLeft = new XmlBlockCollection ( $ this -> _myWords -> Value ( "BLOCKLEFT" ) , BlockPosition :: Left ) ; $ blockLeft -> addXmlnukeObject ( $ firstParagraph ) ; $ blockRight = new XmlBlockCollection ( $ this -> _myWords -> Value ( "BLOCKRIGHT" ) , BlockPosition :: Right ) ; $ blockRight -> addXmlnukeObject ( $ firstParagraph ) ; $ this -> _document -> addXmlnukeObject ( $ blockCenter ) ; $ this -> _document -> addXmlnukeObject ( $ blockLeft ) ; $ this -> _document -> addXmlnukeObject ( $ blockRight ) ; } | Show the Create Object Exemple |
24,670 | public function isOwnedBy ( Model $ owner ) { if ( ! $ this -> hasOwner ( ) ) { return false ; } return ( $ owner -> getKey ( ) === $ this -> owner -> getKey ( ) ) ; } | Checks if the given is the owner |
24,671 | public static function getCurrentRoute ( ) { $ current = null ; $ request = Request :: current ( ) ; $ routeStr = $ request -> getRouteStr ( ) ; $ method = $ request -> getMethod ( ) ; foreach ( self :: $ routes as $ route ) { if ( ! in_array ( $ method , $ route [ 'methods' ] ) ) { continue ; } if ( substr_count ( $ route [ 'route' ] , '/' ) != substr_count ( $ routeStr , '/' ) ) { continue ; } if ( ParametrizedString :: make ( $ route [ 'route' ] ) -> matches ( $ routeStr ) ) { $ current = $ route ; break ; } } return $ current ; } | Search for the route that matches the current request . If not found returns NULL . |
24,672 | public static function format ( $ phantomJsResponse ) { $ response = new Response ( $ phantomJsResponse -> getStatus ( ) , $ phantomJsResponse -> getHeaders ( ) , $ phantomJsResponse -> getContent ( ) ) ; return $ response ; } | ResponseBridge constructor . |
24,673 | public static function guess ( string $ path , string $ cmd = null ) : ? string { if ( ! \ is_file ( $ path ) ) { throw new FileNotFoundException ( $ path ) ; } if ( ! \ is_readable ( $ path ) ) { throw new AccessDeniedException ( $ path ) ; } if ( $ cmd === null ) { $ cmd = 'file -b --mime %s' ; if ( \ stripos ( \ PHP_OS , 'win' ) !== 0 ) { $ cmd .= ' 2>/dev/null' ; } } \ ob_start ( ) ; \ passthru ( \ sprintf ( $ cmd , \ escapeshellarg ( $ path ) ) , $ return ) ; if ( $ return > 0 ) { \ ob_end_clean ( ) ; return null ; } $ type = \ trim ( ( string ) \ ob_get_clean ( ) ) ; if ( \ preg_match ( '#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i' , $ type , $ match ) === false ) { return null ; } return $ match [ 1 ] ; } | Guesses the mime type with the binary file . |
24,674 | public function addVariable ( string $ name , ? string $ type , ? bool $ dynamic ) : KBEntry { $ kbe = new KBEntry ( $ name , $ type , $ dynamic ) ; $ this -> vars [ ] = $ kbe ; return $ kbe ; } | Add a variable |
24,675 | public function build ( ) { if ( $ this -> handler ) { $ handler = $ this -> handler ; } elseif ( $ this -> pdo || $ this -> dbCredentials ) { $ options = $ this -> dbCredentials ; $ options [ 'table' ] = $ this -> table ; if ( $ this -> pdo ) { $ options [ 'pdo' ] = $ this -> pdo ; } $ handler = new PdoHandler ( $ options ) ; } else { $ handler = new FileHandler ( $ this -> locking ) ; } return new Session ( $ handler , $ this -> name , $ this -> savePath , $ this -> serializer ) ; } | Create a new session with the appropriate storage handler |
24,676 | public function mergedWith ( Metadata $ additionalMetadata ) : self { $ values = array_merge ( $ this -> values , $ additionalMetadata -> values ) ; if ( $ values === $ this -> values ) { return $ this ; } return new static ( $ values ) ; } | Returns a Metadata instance containing values of this combined with the given additionalMetadata . If any entries have identical keys the values from the additionalMetadata will take precedence . |
24,677 | public function withoutKeys ( array $ keys ) : self { $ values = array_diff_key ( $ this -> values , array_flip ( $ keys ) ) ; if ( $ values === $ this -> values ) { return $ this ; } return new static ( $ values ) ; } | Returns a Metadata instance with the items with given keys removed . Keys for which there is no assigned value are ignored . |
24,678 | public static function toReadableSize ( $ bytes , $ decimals = 1 , $ system = 'metric' ) { $ mod = ( $ system === 'binary' ) ? 1024 : 1000 ; $ units = [ 'binary' => [ 'B' , 'KiB' , 'MiB' , 'GiB' , 'TiB' , 'PiB' , 'EiB' , 'ZiB' , 'YiB' , ] , 'metric' => [ 'B' , 'kB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' , ] , ] ; $ factor = floor ( ( strlen ( $ bytes ) - 1 ) / 3 ) ; return sprintf ( "%.{$decimals}f %s" , $ bytes / pow ( $ mod , $ factor ) , $ units [ $ system ] [ $ factor ] ) ; } | Convert to readable size . |
24,679 | public static function toReadableTime ( $ time , $ decimals = 3 ) { $ decimals = ( int ) $ decimals ; $ unit = 'sec' ; return sprintf ( "%.{$decimals}f %s" , $ time , $ unit ) ; } | Convert to readable time . |
24,680 | private function getIgnoredStatus ( $ login ) { try { $ ignoreList = $ this -> factory -> getConnection ( ) -> getIgnoreList ( ) ; foreach ( $ ignoreList as $ player ) { if ( $ player -> login === $ login ) { return true ; } } return false ; } catch ( \ Exception $ e ) { return false ; } } | Get ignore status for a player ; |
24,681 | public function group ( array $ fields ) { $ output = array ( ) ; foreach ( $ fields as $ name => $ data ) { if ( is_array ( $ data ) ) { list ( $ data , $ value , $ class , $ id ) = $ this -> _findMainAttr ( $ data ) ; $ output [ ] = $ this -> render ( $ name , $ value , $ class , $ id , $ data ) ; } else { $ output [ ] = $ this -> render ( $ name , $ data ) ; } } return implode ( PHP_EOL , $ output ) ; } | Create group hidden inputs . |
24,682 | private function migrateFields ( ) { if ( $ attendeeFields = AttendeeExtraField :: get ( ) ) { foreach ( $ attendeeFields as $ attendeeField ) { $ this -> findOrMakeUserFieldFor ( $ attendeeField ) ; } } } | Migrate the AttendeeExtraFields to UserFields |
24,683 | private function findOrMakeUserFieldFor ( AttendeeExtraField $ attendeeField ) { if ( ! $ field = $ this -> getUserFields ( ) -> byID ( $ attendeeField -> ID ) ) { $ class = self :: mapFieldType ( $ attendeeField -> FieldType , $ attendeeField -> FieldName ) ; $ field = $ class :: create ( ) ; } $ field -> ClassName = self :: mapFieldType ( $ attendeeField -> FieldType , $ attendeeField -> FieldName ) ; $ field -> ID = $ attendeeField -> ID ; $ field -> Name = $ attendeeField -> FieldName ; $ field -> Title = $ attendeeField -> Title ; $ field -> Default = $ attendeeField -> DefaultValue ; $ field -> ExtraClass = $ attendeeField -> ExtraClass ; $ field -> Required = $ attendeeField -> Required ; $ field -> Editable = $ attendeeField -> Editable ; $ field -> EventID = $ attendeeField -> EventID ; $ field -> Sort = $ attendeeField -> Sort ; if ( $ attendeeField -> Options ( ) -> exists ( ) && $ field -> ClassName === 'UserOptionSetField' ) { foreach ( $ attendeeField -> Options ( ) as $ option ) { $ field -> Options ( ) -> add ( $ this -> findOrMakeUserOptionFor ( $ option ) ) ; echo "[{$field->ID}] Added AttendeeExtraFieldOption as UserFieldOption\n" ; } } $ field -> write ( ) ; echo "[{$field->ID}] Migrated AttendeeExtraField to $field->ClassName\n" ; } | Make a new UserField based on the given AttendeeExtraField |
24,684 | private function findOrMakeUserOptionFor ( AttendeeExtraFieldOption $ attendeeOption ) { if ( ! $ option = $ this -> getUserFieldOption ( ) -> byID ( $ attendeeOption -> ID ) ) { $ option = UserFieldOption :: create ( ) ; } $ option -> ID = $ attendeeOption -> ID ; $ option -> Title = $ attendeeOption -> Title ; $ option -> Default = $ attendeeOption -> Default ; $ option -> Sort = $ attendeeOption -> Sort ; return $ option ; } | Find or make an option based on the given AttendeeExtraFieldOption |
24,685 | private static function mapFieldType ( $ type , $ name = null ) { $ types = array ( 'TextField' => 'UserTextField' , 'EmailField' => 'UserEmailField' , 'CheckboxField' => 'UserCheckboxField' , 'OptionsetField' => 'UserOptionSetField' ) ; $ currentDefaults = Attendee :: config ( ) -> get ( 'default_fields' ) ; if ( $ currentDefaults && key_exists ( $ name , $ currentDefaults ) ) { return $ currentDefaults [ $ name ] [ 'FieldType' ] ; } else { return $ types [ $ type ] ; } } | Map the given field type to one of the available class names Also looks into the current mapping if the field has a new type |
24,686 | public function update ( ) { if ( $ this -> currentVote ) { $ vote = $ this -> currentVote -> getCurrentVote ( ) ; $ this -> currentVote -> update ( time ( ) ) ; switch ( $ vote -> getStatus ( ) ) { case Vote :: STATUS_CANCEL : $ this -> dispatcher -> dispatch ( "votemanager.votecancelled" , [ $ vote -> getPlayer ( ) , $ vote -> getType ( ) , $ vote ] ) ; $ this -> currentVote = null ; $ this -> reset ( ) ; break ; case Vote :: STATUS_FAILED : $ this -> dispatcher -> dispatch ( "votemanager.votefailed" , [ $ vote -> getPlayer ( ) , $ vote -> getType ( ) , $ vote ] ) ; $ this -> currentVote = null ; $ this -> reset ( ) ; break ; case Vote :: STATUS_PASSED : $ this -> dispatcher -> dispatch ( "votemanager.votepassed" , [ $ vote -> getPlayer ( ) , $ vote -> getType ( ) , $ vote ] ) ; $ this -> currentVote = null ; $ this -> reset ( ) ; break ; } } } | Update the status of the vote . |
24,687 | public function startVote ( Player $ player , $ typeCode , $ params ) { if ( $ this -> getCurrentVote ( ) !== null ) { $ this -> chatNotification -> sendMessage ( "expansion_votemanager.error.in_progress" ) ; return ; } if ( isset ( $ this -> voteMapping [ $ typeCode ] ) ) { $ typeCode = $ this -> voteMapping [ $ typeCode ] ; } if ( ! isset ( $ this -> votePlugins [ $ typeCode ] ) ) { return ; } $ this -> currentVote = $ this -> votePlugins [ $ typeCode ] ; $ this -> currentVote -> start ( $ player , $ params ) ; $ this -> factory -> getConnection ( ) -> cancelVote ( ) ; $ this -> dispatcher -> dispatch ( "votemanager.votenew" , [ $ player , $ this -> currentVote -> getCode ( ) , $ this -> currentVote -> getCurrentVote ( ) ] ) ; } | Start a vote . |
24,688 | public function byAccountIds ( $ ids , $ databaseConnectionName = null ) { if ( empty ( $ databaseConnectionName ) ) { $ databaseConnectionName = $ this -> databaseConnectionName ; } return $ this -> JournalEntry -> setConnection ( $ databaseConnectionName ) -> whereIn ( 'account_id' , $ ids ) -> get ( ) ; } | Get journal entries by account ids |
24,689 | public function getJournalEntriesGroupedByPlBsCategoryByOrganizationAndByFiscalYear ( $ plBsCategory , $ organizationId , $ fiscalYearId , $ databaseConnectionName = null ) { if ( empty ( $ databaseConnectionName ) ) { $ databaseConnectionName = $ this -> databaseConnectionName ; } return $ this -> DB -> connection ( $ databaseConnectionName ) -> table ( 'ACCT_Journal_Entry AS je' ) -> join ( 'ACCT_Journal_Voucher AS jv' , 'jv.id' , '=' , 'je.journal_voucher_id' ) -> join ( 'ACCT_Account AS c' , 'c.id' , '=' , 'je.account_id' ) -> join ( 'ACCT_Period AS p' , 'p.id' , '=' , 'jv.period_id' ) -> join ( 'ACCT_Account_Type AS at' , 'at.id' , '=' , 'c.account_type_id' ) -> where ( 'jv.organization_id' , '=' , $ organizationId ) -> where ( 'p.fiscal_year_id' , '=' , $ fiscalYearId ) -> where ( 'jv.status' , '=' , 'B' ) -> whereIn ( 'at.pl_bs_category' , $ plBsCategory ) -> whereNull ( 'je.deleted_at' ) -> whereNull ( 'jv.deleted_at' ) -> groupBy ( 'je.cost_center_id' , 'je.account_id' , 'c.balance_type' ) -> select ( array ( $ this -> DB -> raw ( 'SUM(je.debit) as debit' ) , $ this -> DB -> raw ( 'SUM(je.credit) as credit' ) , 'je.cost_center_id' , 'je.account_id' , 'c.balance_type' ) ) -> get ( ) ; } | Get the credit sum of all entries of a journal voucher |
24,690 | protected function _getBtnClasses ( array $ attrs = array ( ) ) { if ( Arr :: key ( 'button' , $ attrs ) ) { $ classes = array ( $ this -> _btm ) ; foreach ( ( array ) $ attrs [ 'button' ] as $ btn ) { $ classes [ ] = $ this -> _btm . '-' . $ btn ; } $ attrs = $ this -> _mergeAttr ( $ attrs , implode ( ' ' , $ classes ) ) ; unset ( $ attrs [ 'button' ] ) ; } return $ attrs ; } | Create button classes . |
24,691 | public static function get ( $ key = null ) { $ path = apply_filters ( 'inc2734_view_controller_config_path' , untrailingslashit ( __DIR__ ) . '/../config/config.php' ) ; if ( ! file_exists ( $ path ) ) { return ; } $ config = include ( $ path ) ; if ( is_null ( $ key ) ) { return $ config ; } if ( ! isset ( $ config [ $ key ] ) ) { return ; } return $ config [ $ key ] ; } | Getting config value |
24,692 | public function startMap ( $ map , $ nbLaps ) { $ this -> recordsHandler -> loadForMap ( $ map -> uId , $ nbLaps ) ; $ this -> recordsHandler -> loadForPlayers ( $ map -> uId , $ nbLaps , $ this -> allPlayersGroup -> getLogins ( ) ) ; $ this -> dispatchEvent ( [ 'event' => 'loaded' , 'records' => $ this -> recordsHandler -> getRecords ( ) ] ) ; } | Start plugin for a certain map . |
24,693 | public function dispatchEvent ( $ eventData ) { $ event = $ this -> eventPrefix . '.' . $ eventData [ 'event' ] ; unset ( $ eventData [ 'event' ] ) ; $ eventData [ RecordHandler :: COL_PLUGIN ] = $ this ; $ this -> dispatcher -> dispatch ( $ event , [ $ eventData ] ) ; } | Dispatch a record event . |
24,694 | protected function registerEvent ( $ payload , $ metadata = null ) { if ( $ payload instanceof AbstractDomainEvent && null === $ payload -> aggregateId ) { $ payload -> setAggregateId ( $ this -> getId ( ) ) ; } return $ this -> getEventContainer ( ) -> addEvent ( $ payload , $ metadata ) ; } | Registers an event to be published when the aggregate is saved containing the given payload and optional metadata . |
24,695 | public function registerAssetFiles ( $ view ) { if ( YII_ENV_PROD ) { if ( ! empty ( $ this -> productionJs ) ) { $ this -> js = $ this -> productionJs ; } if ( ! empty ( $ this -> productionCss ) ) { $ this -> css = $ this -> productionCss ; } } parent :: registerAssetFiles ( $ view ) ; } | Registers the CSS and JS files with the given view . In production environments make use of the production asset files if they are provided |
24,696 | public function login ( string $ user , string $ password , $ attempts = 1 , $ sleepBetweenAttempts = 5 ) { if ( ! @ ftp_login ( $ this -> ftp , $ user , $ password ) ) { if ( -- $ attempts > 0 ) { sleep ( $ sleepBetweenAttempts ) ; return $ this -> login ( $ user , $ password , $ attempts , $ sleepBetweenAttempts ) ; } throw new Exception ( sprintf ( "Cannot login to host %s" , $ this -> host ) ) ; } return $ this ; } | Login to server . |
24,697 | public function listFilesRaw ( string $ dir = "." , int $ attempts = 5 , int $ sleepBetweenAttempts = 5 ) { $ total = @ ftp_rawlist ( $ this -> ftp , $ dir ) ; if ( $ total === false ) { if ( -- $ attempts > 0 ) { sleep ( $ sleepBetweenAttempts ) ; return $ this -> listFilesRaw ( $ dir , $ attempts , $ sleepBetweenAttempts ) ; } throw new Exception ( sprintf ( "Cannot list files in %s" , $ dir ) ) ; } $ columnMap = [ "permissions" , "number" , "owner" , "group" , "size" , "month" , "day" , "year" , "name" , ] ; $ monthMap = [ 'Jan' => '01' , 'Feb' => '02' , 'Mar' => '03' , 'Apr' => '04' , 'May' => '05' , 'Jun' => '06' , 'Jul' => '07' , 'Aug' => '08' , 'Sep' => '09' , 'Sept' => '09' , 'Oct' => '10' , 'Nov' => '11' , 'Dec' => '12' , ] ; $ files = [ ] ; foreach ( $ total as $ rawString ) { $ data = [ ] ; $ rawList = preg_split ( "/\s*/" , $ rawString , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ rawList as $ col => $ value ) { if ( $ col > 8 ) { $ data [ $ columnMap [ 8 ] ] .= " " . $ value ; continue ; } $ data [ $ columnMap [ $ col ] ] = $ value ; } $ data [ 'month' ] = $ monthMap [ $ data [ 'month' ] ] ; $ data [ 'time' ] = "00:00" ; if ( strpos ( $ data [ 'year' ] , ':' ) !== false ) { $ data [ 'time' ] = $ data [ 'year' ] ; if ( ( int ) $ data [ 'month' ] > ( int ) date ( 'm' ) ) { $ data [ 'year' ] = date ( 'Y' , time ( ) - 60 * 60 * 24 * 365 ) ; } else { $ data [ 'year' ] = date ( 'Y' ) ; } } $ files [ ] = $ data ; } return $ files ; } | Get raw data of files in directory on ftp - server . |
24,698 | public function get ( string $ remoteFile , string $ localFile = null , int $ mode = FTP_BINARY , int $ attempts = 1 , int $ sleepBetweenAttempts = 5 ) { if ( ! $ localFile ) { $ localFile = $ remoteFile ; } if ( ! @ ftp_get ( $ this -> ftp , $ localFile , $ remoteFile , $ mode ) ) { if ( -- $ attempts > 0 ) { sleep ( $ sleepBetweenAttempts ) ; return $ this -> get ( $ remoteFile , $ localFile , $ mode , $ attempts , $ sleepBetweenAttempts ) ; } throw new Exception ( sprintf ( "Cannot copy file from %s to %s" , $ remoteFile , $ localFile ) ) ; } return $ this ; } | Get a file from ftp - server . |
24,699 | public function fget ( string $ remoteFile , $ handle , int $ resumePos = 0 ) { if ( ! @ ftp_fget ( $ this -> ftp , $ handle , $ remoteFile , FTP_BINARY , $ resumePos ) ) { throw new Exception ( "Cannot write in file handle" ) ; } return $ this ; } | Get a file from ftp - server and write it directly into file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.