idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
24,500
protected function findProviderForUrl ( $ url ) { foreach ( $ this -> providers as $ provider ) { if ( $ provider -> match ( $ url ) ) { return $ provider ; } } return null ; }
Find an oEmbed provider matching the supplied URL .
24,501
protected function _checkSelected ( array $ options , $ selectedVal ) { if ( ! empty ( $ selectedVal ) && ! Arr :: key ( $ selectedVal , $ options ) ) { $ selectedVal = self :: KEY_NO_EXITS_VAL ; $ options = array_merge ( array ( self :: KEY_NO_EXITS_VAL => $ this -> _translate ( 'No exits' ) ) , $ options ) ; } return array ( $ options , $ selectedVal ) ; }
Check selected option in list .
24,502
public function getNewSandBox ( callable $ action ) { $ errorHandler = $ this -> getOption ( 'error_reporting' ) ; if ( $ errorHandler !== null && ! is_callable ( $ errorHandler ) ) { $ errorReporting = $ errorHandler ; $ errorHandler = function ( $ number , $ message , $ file , $ line ) use ( $ errorReporting ) { if ( $ errorReporting & $ number ) { throw new ErrorException ( $ message , 0 , $ number , $ file , $ line ) ; } return true ; } ; } return new SandBox ( $ action , $ errorHandler ) ; }
Return a sandbox with renderer settings for a given callable action .
24,503
private function getSandboxCall ( & $ source , $ method , $ path , $ input , callable $ getSource , array $ parameters ) { return $ this -> getNewSandBox ( function ( ) use ( & $ source , $ method , $ path , $ input , $ getSource , $ parameters ) { $ adapter = $ this -> getAdapter ( ) ; $ cacheEnabled = ( $ adapter -> hasOption ( 'cache_dir' ) && $ adapter -> getOption ( 'cache_dir' ) || $ this -> hasOption ( 'cache_dir' ) && $ this -> getOption ( 'cache_dir' ) ) ; if ( $ cacheEnabled ) { $ this -> expectCacheAdapter ( ) ; $ adapter = $ this -> getAdapter ( ) ; $ display = function ( ) use ( $ adapter , $ path , $ input , $ getSource , $ parameters ) { $ adapter -> displayCached ( $ path , $ input , $ getSource , $ parameters ) ; } ; return in_array ( $ method , [ 'display' , 'displayFile' ] ) ? $ display ( ) : $ adapter -> captureBuffer ( $ display ) ; } $ source = $ getSource ( $ path , $ input ) ; return $ adapter -> $ method ( $ source , $ parameters ) ; } ) ; }
Call an adapter method inside a sandbox and return the SandBox result .
24,504
private function send ( string $ method , string $ command , array $ options = [ ] ) : array { $ result = $ this -> client -> da_request ( $ method , self :: CMD_PREFIX . $ command , $ options ) ; return $ result ; }
Send command .
24,505
protected function _checkNoSelected ( array $ options , array $ selected , $ isMultiply = false ) { if ( $ isMultiply === 'multiple' ) { return array ( $ options , $ selected ) ; } $ _selected = array_pop ( $ selected ) ; if ( ! Arr :: key ( $ _selected , $ options ) && ! empty ( $ selected ) ) { $ options = array_merge ( array ( $ _selected => $ this -> _translate ( '--No selected--' ) ) , $ options ) ; } return array ( $ options , array ( $ _selected ) ) ; }
Check on no selected and add new select option .
24,506
protected function _createGroup ( $ key , array $ gOptions , array $ selected , array $ options ) { $ label = ( is_int ( $ key ) ) ? sprintf ( $ this -> _translate ( 'Select group %s' ) , $ key ) : $ key ; $ output = array ( '<optgroup label="' . $ this -> _translate ( $ label ) . '">' ) ; foreach ( $ gOptions as $ value => $ label ) { if ( Arr :: key ( $ value , $ options ) ) { continue ; } $ classes = implode ( ' ' , array ( $ this -> _jbSrt ( 'option' ) , $ this -> _jbSrt ( 'option-' . Str :: slug ( $ label ) ) , ) ) ; $ isSelected = $ this -> _isSelected ( $ value , $ selected ) ; $ output [ ] = $ this -> _option ( $ value , $ isSelected , $ classes , $ label ) ; } $ output [ ] = '</optgroup>' ; return implode ( PHP_EOL , $ output ) ; }
Create options group .
24,507
protected function _getOptions ( array $ options , array $ selected = array ( ) , $ isMultiple = false ) { $ output = array ( ) ; list ( $ options , $ _selected ) = $ this -> _checkNoSelected ( $ options , $ selected , $ isMultiple ) ; foreach ( $ options as $ key => $ data ) { $ label = $ data ; $ value = $ key ; $ classes = implode ( ' ' , array ( $ this -> _jbSrt ( 'option' ) , $ this -> _jbSrt ( 'option-' . Str :: slug ( $ value , true ) ) , ) ) ; $ isSelected = $ this -> _isSelected ( $ value , $ _selected ) ; if ( is_array ( $ data ) ) { $ output [ ] = $ this -> _createGroup ( $ key , $ data , $ _selected , $ options ) ; } else { $ output [ ] = $ this -> _option ( $ value , $ isSelected , $ classes , $ label ) ; } } return implode ( PHP_EOL , $ output ) ; }
Get select options .
24,508
protected function _option ( $ value , $ selected = false , $ class = '' , $ label = '' ) { if ( $ selected === true ) { $ selected = ' selected="selected"' ; } $ option = '<option value="' . $ value . '" class="' . $ class . '"' . $ selected . '>' . $ this -> _translate ( $ label ) . '</option>' ; return $ option ; }
Create option .
24,509
public function cache ( $ path , $ input , callable $ rendered , & $ success = null ) { $ cacheFolder = $ this -> getCacheDirectory ( ) ; $ destination = $ path ; if ( ! $ this -> isCacheUpToDate ( $ destination , $ input ) ) { if ( ! is_writable ( $ cacheFolder ) ) { throw new RuntimeException ( sprintf ( 'Cache directory must be writable. "%s" is not.' , $ cacheFolder ) , 6 ) ; } $ compiler = $ this -> getRenderer ( ) -> getCompiler ( ) ; $ fullPath = $ compiler -> locate ( $ path ) ? : $ path ; $ output = $ rendered ( $ fullPath , $ input ) ; $ importsPaths = $ compiler -> getImportPaths ( $ fullPath ) ; $ success = $ this -> cacheFileContents ( $ destination , $ output , $ importsPaths ) ; } return $ destination ; }
Return the cached file path after cache optional process .
24,510
public function displayCached ( $ path , $ input , callable $ rendered , array $ variables , & $ success = null ) { $ __pug_parameters = $ variables ; $ __pug_path = $ this -> cache ( $ path , $ input , $ rendered , $ success ) ; call_user_func ( function ( ) use ( $ __pug_path , $ __pug_parameters ) { extract ( $ __pug_parameters ) ; include $ __pug_path ; } ) ; }
Display rendered template after optional cache process .
24,511
public function cacheFileIfChanged ( $ path ) { $ outputFile = $ path ; if ( ! $ this -> isCacheUpToDate ( $ outputFile ) ) { $ compiler = $ this -> getRenderer ( ) -> getCompiler ( ) ; return $ this -> cacheFileContents ( $ outputFile , $ compiler -> compileFile ( $ path ) , $ compiler -> getCurrentImportPaths ( ) ) ; } return true ; }
Cache a template file in the cache directory if the cache is obsolete . Returns true if the cache is up to date and cache not change else returns the number of bytes written in the cache file or false if a failure occurred .
24,512
public function cacheDirectory ( $ directory ) { $ success = 0 ; $ errors = 0 ; $ errorDetails = [ ] ; $ renderer = $ this -> getRenderer ( ) ; $ events = $ renderer -> getCompiler ( ) -> getEventListeners ( ) ; foreach ( $ renderer -> scanDirectory ( $ directory ) as $ inputFile ) { $ renderer -> initCompiler ( ) ; $ compiler = $ renderer -> getCompiler ( ) ; $ compiler -> mergeEventListeners ( $ events ) ; $ path = $ inputFile ; $ this -> isCacheUpToDate ( $ path ) ; $ sandBox = $ this -> getRenderer ( ) -> getNewSandBox ( function ( ) use ( & $ success , $ compiler , $ path , $ inputFile ) { $ this -> cacheFileContents ( $ path , $ compiler -> compileFile ( $ inputFile ) , $ compiler -> getCurrentImportPaths ( ) ) ; $ success ++ ; } ) ; $ error = $ sandBox -> getThrowable ( ) ; if ( $ error ) { $ errors ++ ; $ errorDetails [ ] = compact ( [ 'directory' , 'inputFile' , 'path' , 'error' ] ) ; } } return [ $ success , $ errors , $ errorDetails ] ; }
Scan a directory recursively compile them and save them into the cache directory .
24,513
private function isCacheUpToDate ( & $ path , $ input = null ) { if ( ! $ input ) { $ compiler = $ this -> getRenderer ( ) -> getCompiler ( ) ; $ input = $ compiler -> resolve ( $ path ) ; $ path = $ this -> getCachePath ( ( $ this -> getOption ( 'keep_base_name' ) ? basename ( $ path ) : '' ) . $ this -> hashPrint ( $ input ) ) ; if ( ! $ this -> getOption ( 'up_to_date_check' ) ) { return true ; } if ( ! file_exists ( $ path ) ) { return false ; } return ! $ this -> hasExpiredImport ( $ input , $ path ) ; } $ path = $ this -> getCachePath ( $ this -> hashPrint ( $ input ) ) ; return file_exists ( $ path ) ; }
Return true if the file or content is up to date in the cache folder false else .
24,514
protected function getPollConfig ( ) { $ pollfile = new AnydatasetFilenameProcessor ( "_poll" ) ; $ anyconfig = new AnyDataset ( $ pollfile -> FullQualifiedNameAndPath ( ) ) ; $ it = $ anyconfig -> getIterator ( ) ; if ( $ it -> hasNext ( ) ) { $ sr = $ it -> moveNext ( ) ; $ this -> _isdb = $ sr -> getField ( "dbname" ) != "-anydata-" ; $ this -> _connection = $ sr -> getField ( "dbname" ) ; $ this -> _tblanswer = $ sr -> getField ( "tbl_answer" ) ; $ this -> _tblpoll = $ sr -> getField ( "tbl_poll" ) ; $ this -> _tbllastip = $ sr -> getField ( "tbl_lastip" ) ; } else { $ this -> _error = true ; } }
Get informations about WHERE I need to store poll data
24,515
protected function getAnyData ( ) { $ filepoll = new AnydatasetFilenameProcessor ( "poll_list" ) ; $ this -> _anyPoll = new AnyDataset ( $ filepoll -> FullQualifiedNameAndPath ( ) ) ; $ fileanswer = new AnydatasetFilenameProcessor ( "poll_" . $ this -> _poll . "_" . $ this -> _lang ) ; $ this -> _anyAnswer = new AnyDataset ( $ fileanswer -> FullQualifiedNameAndPath ( ) ) ; }
Get AnydataSet Poll information
24,516
public function steps ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = $ this -> ConfigTheme -> getStepsConfigTourApp ( ) ; $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action steps . Is used to get data of tour steps
24,517
protected function write ( array $ record ) { if ( ! self :: $ sendHeaders ) { return ; } if ( ! self :: $ initialized ) { self :: $ initialized = true ; self :: $ sendHeaders = $ this -> headersAccepted ( ) ; if ( ! self :: $ sendHeaders ) { return ; } foreach ( $ this -> getInitHeaders ( ) as $ header => $ content ) { $ this -> sendHeader ( $ header , $ content ) ; } } $ header = $ this -> createRecordHeader ( $ record ) ; if ( trim ( current ( $ header ) ) !== '' ) { $ this -> sendHeader ( key ( $ header ) , current ( $ header ) ) ; } }
Creates & sends header for a record ensuring init headers have been sent prior
24,518
protected function displayManialinks ( ) { $ size = 0 ; foreach ( $ this -> getManialinksToDisplay ( ) as $ mlData ) { $ currentSize = $ size ; $ size += strlen ( $ mlData [ 'ml' ] ) ; if ( $ currentSize != 0 && $ size > $ this -> charLimit ) { $ this -> executeMultiCall ( ) ; $ size = strlen ( $ mlData [ 'ml' ] ) ; } $ logins = array_filter ( $ mlData [ 'logins' ] , function ( $ value ) { return $ value != '' ; } ) ; if ( ! empty ( $ logins ) ) { $ this -> factory -> getConnection ( ) -> sendDisplayManialinkPage ( $ mlData [ 'logins' ] , $ mlData [ 'ml' ] , $ mlData [ 'timeout' ] , false , true ) ; } } if ( $ size > 0 ) { $ this -> executeMultiCall ( ) ; } $ this -> displayQueu = [ ] ; $ this -> individualQueu = [ ] ; $ this -> hideQueu = [ ] ; $ this -> hideIndividualQueu = [ ] ; $ this -> disconnectedLogins = [ ] ; }
Display & hide all manialinks .
24,519
protected function executeMultiCall ( ) { try { $ this -> factory -> getConnection ( ) -> executeMulticall ( ) ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( "Couldn't deliver all manialinks : " . $ e -> getMessage ( ) , [ 'exception' => $ e ] ) ; $ this -> console -> writeln ( '$F00ERROR - Couldn\'t deliver all manialinks : ' . $ e -> getMessage ( ) ) ; } }
Execute multi call & handle error .
24,520
protected function getManialinksToDisplay ( ) { foreach ( $ this -> displayQueu as $ groupName => $ manialinks ) { foreach ( $ manialinks as $ factoryId => $ manialink ) { $ logins = $ manialink -> getUserGroup ( ) -> getLogins ( ) ; $ this -> displayeds [ $ groupName ] [ $ factoryId ] = $ manialink ; if ( ! empty ( $ logins ) ) { yield [ 'logins' => $ logins , 'ml' => $ manialink -> getXml ( ) , "timeout" => $ manialink -> getTimeout ( ) ] ; } } } foreach ( $ this -> individualQueu as $ manialinks ) { $ logins = [ ] ; $ lastManialink = null ; foreach ( $ manialinks as $ login => $ manialink ) { $ logins [ ] = $ login ; $ lastManialink = $ manialink ; } if ( $ lastManialink ) { $ xml = $ manialink -> getXml ( ) ; yield [ 'logins' => $ logins , 'ml' => $ xml , "timeout" => $ manialink -> getTimeout ( ) ] ; } } foreach ( $ this -> hideQueu as $ manialinks ) { foreach ( $ manialinks as $ manialink ) { $ id = $ manialink -> getId ( ) ; $ manialink -> destroy ( ) ; $ logins = $ manialink -> getUserGroup ( ) -> getLogins ( ) ; $ logins = array_diff ( $ logins , $ this -> disconnectedLogins ) ; if ( ! empty ( $ logins ) ) { yield [ 'logins' => $ logins , 'ml' => '<manialink id="' . $ id . '" />' , "timeout" => 0 ] ; } } } foreach ( $ this -> hideIndividualQueu as $ id => $ manialinks ) { $ logins = [ ] ; $ lastManialink = null ; foreach ( $ manialinks as $ login => $ manialink ) { if ( ! in_array ( $ login , $ this -> disconnectedLogins ) ) { $ logins [ ] = $ login ; $ lastManialink = $ manialink ; } } if ( $ lastManialink ) { yield [ 'logins' => $ logins , 'ml' => '<manialink id="' . $ lastManialink -> getId ( ) . '" />' , "timeout" => 0 ] ; } } }
Get list of all manialinks that needs to be displayed
24,521
public function render ( $ name = '' , $ content = '' , array $ attrs = array ( ) , $ type = 'submit' ) { $ attrs = array_merge ( array ( 'text' => null , 'name' => $ name ) , $ attrs ) ; $ attrs = $ this -> _getBtnClasses ( $ attrs ) ; $ attrs [ 'type' ] = $ type ; if ( Arr :: key ( 'icon' , $ attrs ) ) { $ content = '<i class="' . $ this -> _icon . '-' . $ attrs [ 'icon' ] . '"></i> ' . $ this -> _translate ( $ content ) ; unset ( $ attrs [ 'icon' ] ) ; } return '<button ' . $ this -> buildAttrs ( $ attrs ) . '>' . $ content . '</button>' ; }
Crete button .
24,522
public function CreatePage ( ) { $ myWords = $ this -> WordCollection ( ) ; $ this -> _titlePage = $ myWords -> Value ( "TITLE" , $ this -> _context -> get ( "SERVER_NAME" ) ) ; $ this -> _abstractPage = $ myWords -> Value ( "ABSTRACT" , $ this -> _context -> get ( "SERVER_NAME" ) ) ; $ this -> _document = new XmlnukeDocument ( $ this -> _titlePage , $ this -> _abstractPage ) ; $ this -> txtSearch = $ this -> _context -> get ( "txtSearch" ) ; if ( $ this -> txtSearch != "" ) { $ this -> Form ( ) ; $ doc = $ this -> Find ( ) ; } else { $ this -> Form ( ) ; } return $ this -> _document -> generatePage ( ) ; }
Logic of your module
24,523
protected function updateMapList ( ) { $ start = 0 ; do { try { $ maps = $ this -> factory -> getConnection ( ) -> getMapList ( self :: BATCH_SIZE , $ start ) ; } catch ( IndexOutOfBoundException $ e ) { return ; } catch ( NextMapException $ ex ) { return ; } if ( ! empty ( $ maps ) ) { foreach ( $ maps as $ map ) { $ this -> mapStorage -> addMap ( $ map ) ; } } $ start += self :: BATCH_SIZE ; } while ( count ( $ maps ) == self :: BATCH_SIZE ) ; }
Update the list of maps in the storage .
24,524
public function onMapListModified ( $ curMapIndex , $ nextMapIndex , $ isListModified ) { if ( $ isListModified ) { $ oldMaps = $ this -> mapStorage -> getMaps ( ) ; $ this -> mapStorage -> resetMapData ( ) ; $ this -> updateMapList ( ) ; $ this -> dispatch ( __FUNCTION__ , [ $ oldMaps , $ curMapIndex , $ nextMapIndex , $ isListModified ] ) ; } try { $ currentMap = $ this -> factory -> getConnection ( ) -> getCurrentMapInfo ( ) ; } catch ( \ Exception $ e ) { $ currentMap = $ this -> mapStorage -> getMapByIndex ( $ curMapIndex ) ; } if ( $ currentMap ) { if ( $ this -> mapStorage -> getCurrentMap ( ) -> uId != $ currentMap -> uId ) { $ previousMap = $ this -> mapStorage -> getCurrentMap ( ) ; $ this -> mapStorage -> setCurrentMap ( $ currentMap ) ; $ this -> dispatch ( 'onExpansionMapChange' , [ $ currentMap , $ previousMap ] ) ; } } try { $ nextMap = $ this -> factory -> getConnection ( ) -> getNextMapInfo ( ) ; } catch ( \ Exception $ e ) { $ nextMap = $ this -> mapStorage -> getMapByIndex ( $ nextMapIndex ) ; } if ( $ nextMap ) { if ( $ this -> mapStorage -> getNextMap ( ) -> uId != $ nextMap -> uId ) { $ previousNextMap = $ this -> mapStorage -> getNextMap ( ) ; $ this -> mapStorage -> setNextMap ( $ nextMap ) ; $ this -> dispatch ( 'onExpansionNextMapChange' , [ $ nextMap , $ previousNextMap ] ) ; } } }
Called when map list is modified .
24,525
protected function rebuildTitles ( ) { foreach ( TimeZoneData :: get ( ) as $ tz ) { $ newTitle = $ tz -> prepareTitle ( ) ; if ( $ newTitle != $ tz -> Title ) { $ tz -> Title = $ newTitle ; $ tz -> write ( ) ; } } }
Rebuilds the title in the dataobjects
24,526
protected function message ( $ text ) { if ( Controller :: curr ( ) instanceof DatabaseAdmin ) { DB :: alteration_message ( $ text , 'obsolete' ) ; } else { Debug :: message ( $ text ) ; } }
prints a message during the run of the task
24,527
public function ssecfg ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = $ this -> ConfigTheme -> getSseConfig ( ) ; $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action ssecfg . Is used to get configuration for SSE object
24,528
public function tasks ( ) { $ this -> response -> disableCache ( ) ; Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) || ! $ this -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ 'result' => false , 'tasks' => [ ] ] ; $ delete = ( bool ) $ this -> request -> data ( 'delete' ) ; if ( $ delete ) { $ tasks = $ this -> request -> data ( 'tasks' ) ; $ data [ 'result' ] = $ this -> SseTask -> deleteQueuedTask ( $ tasks ) ; } else { $ tasks = $ this -> SseTask -> getListQueuedTask ( ) ; $ data [ 'tasks' ] = $ tasks ; $ data [ 'result' ] = ! empty ( $ tasks ) ; } $ this -> set ( compact ( 'data' ) ) ; $ this -> set ( '_serialize' , 'data' ) ; }
Action tasks . Is used to get list of queued tasks
24,529
public function queue ( $ type = null , $ retry = 3000 ) { $ this -> response -> disableCache ( ) ; Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> request -> is ( 'sse' ) ) { throw new BadRequestException ( ) ; } $ type = ( string ) $ type ; $ result = [ 'type' => '' , 'progress' => 0 , 'msg' => '' , 'result' => null ] ; $ event = 'progressBar' ; $ retry = ( int ) $ retry ; if ( empty ( $ type ) ) { $ data = json_encode ( $ result ) ; $ this -> set ( compact ( 'retry' , 'data' , 'event' ) ) ; return ; } $ timestamp = null ; $ workermaxruntime = ( int ) Configure :: read ( 'Queue.workermaxruntime' ) ; if ( $ workermaxruntime > 0 ) { $ timestamp = time ( ) - $ workermaxruntime ; } $ jobInfo = $ this -> ExtendQueuedTask -> getPendingJob ( $ type , true , $ timestamp ) ; if ( empty ( $ jobInfo ) ) { $ result [ 'type' ] = $ type ; $ result [ 'result' ] = false ; $ data = json_encode ( $ result ) ; $ this -> set ( compact ( 'retry' , 'data' , 'event' ) ) ; return ; } switch ( $ jobInfo [ 'ExtendQueuedTask' ] [ 'status' ] ) { case 'COMPLETED' : $ resultFlag = true ; break ; case 'NOT_READY' : case 'NOT_STARTED' : case 'FAILED' : case 'UNKNOWN' : $ resultFlag = false ; break ; case 'IN_PROGRESS' : default : $ resultFlag = null ; } $ result [ 'type' ] = $ type ; $ result [ 'progress' ] = ( float ) $ jobInfo [ 'ExtendQueuedTask' ] [ 'progress' ] ; $ result [ 'msg' ] = ( string ) $ jobInfo [ 'ExtendQueuedTask' ] [ 'failure_message' ] ; $ result [ 'result' ] = $ resultFlag ; $ data = json_encode ( $ result ) ; $ this -> set ( compact ( 'retry' , 'data' , 'event' ) ) ; }
Action queue . Is used to Server - Sent Events .
24,530
public function validate ( $ ticketCode = null ) { if ( filter_var ( $ ticketCode , FILTER_VALIDATE_URL ) ) { $ asURL = explode ( '/' , parse_url ( $ ticketCode , PHP_URL_PATH ) ) ; $ ticketCode = end ( $ asURL ) ; } if ( ! isset ( $ ticketCode ) ) { return $ result = array ( 'Code' => self :: MESSAGE_NO_CODE , 'Message' => self :: message ( self :: MESSAGE_NO_CODE , $ ticketCode ) , 'Type' => self :: MESSAGE_TYPE_BAD , 'Ticket' => $ ticketCode , 'Attendee' => null ) ; } if ( ! $ this -> attendee = Attendee :: get ( ) -> find ( 'TicketCode' , $ ticketCode ) ) { return $ result = array ( 'Code' => self :: MESSAGE_CODE_NOT_FOUND , 'Message' => self :: message ( self :: MESSAGE_CODE_NOT_FOUND , $ ticketCode ) , 'Type' => self :: MESSAGE_TYPE_BAD , 'Ticket' => $ ticketCode , 'Attendee' => null ) ; } else { $ name = $ this -> attendee -> getName ( ) ; } if ( ! ( bool ) $ this -> attendee -> Event ( ) -> getGuestList ( ) -> find ( 'ID' , $ this -> attendee -> ID ) ) { return $ result = array ( 'Code' => self :: MESSAGE_TICKET_CANCELLED , 'Message' => self :: message ( self :: MESSAGE_TICKET_CANCELLED , $ name ) , 'Type' => self :: MESSAGE_TYPE_BAD , 'Ticket' => $ ticketCode , 'Attendee' => $ this -> attendee ) ; } elseif ( ( bool ) $ this -> attendee -> CheckedIn && ! ( bool ) self :: config ( ) -> get ( 'allow_checkout' ) ) { return $ result = array ( 'Code' => self :: MESSAGE_ALREADY_CHECKED_IN , 'Message' => self :: message ( self :: MESSAGE_ALREADY_CHECKED_IN , $ name ) , 'Type' => self :: MESSAGE_TYPE_BAD , 'Ticket' => $ ticketCode , 'Attendee' => $ this -> attendee ) ; } elseif ( ( bool ) $ this -> attendee -> CheckedIn && ( bool ) self :: config ( ) -> get ( 'allow_checkout' ) ) { return $ result = array ( 'Code' => self :: MESSAGE_CHECK_OUT_SUCCESS , 'Message' => self :: message ( self :: MESSAGE_CHECK_OUT_SUCCESS , $ name ) , 'Type' => self :: MESSAGE_TYPE_WARNING , 'Ticket' => $ ticketCode , 'Attendee' => $ this -> attendee ) ; } else { return $ result = array ( 'Code' => self :: MESSAGE_CHECK_IN_SUCCESS , 'Message' => self :: message ( self :: MESSAGE_CHECK_IN_SUCCESS , $ name ) , 'Type' => self :: MESSAGE_TYPE_GOOD , 'Ticket' => $ ticketCode , 'Attendee' => $ this -> attendee ) ; } }
Validate the given ticket code
24,531
public function offsetSet ( $ index , $ newval ) { if ( $ newval instanceof $ this -> type ) { parent :: offsetSet ( $ index , $ newval ) ; return ; } if ( $ this -> allowedTypes [ $ this -> type ] ( $ newval ) ) { parent :: offsetSet ( $ index , $ newval ) ; return ; } throw new InvalidArgumentException ( __CLASS__ . ': Elements passed to ' . __CLASS__ . ' must be of the type ' . $ this -> type . '.' ) ; }
Array style value assignment .
24,532
protected function buildSearchParameter ( array $ searchFilters ) { $ search = [ ] ; foreach ( $ searchFilters as $ filter ) { $ parts = explode ( ' ' , trim ( $ filter ) , 2 ) ; if ( empty ( $ parts ) || 2 !== \ count ( $ parts ) ) { continue ; } $ search [ $ parts [ 0 ] ] = $ parts [ 1 ] ; } return $ search ; }
Builds the search parameter as required bu the Rokka client .
24,533
protected function buildSortParameter ( array $ sorts ) { $ sorting = [ ] ; foreach ( $ sorts as $ sort ) { $ parts = explode ( ' ' , trim ( $ sort ) , 2 ) ; if ( empty ( $ parts ) ) { continue ; } if ( 1 === \ count ( $ parts ) ) { $ sorting [ $ parts [ 0 ] ] = true ; } else { $ sorting [ $ parts [ 0 ] ] = $ parts [ 1 ] ; } } return $ sorting ; }
Builds the sort parameter as required bu the Rokka client .
24,534
public final function getAll ( string $ query , array $ queryParams = null , string $ fetchClass = null ) : array { return $ this -> query ( $ query , $ queryParams , null , $ fetchClass ) -> getData ( ) ; }
Get all .
24,535
public static function hasLogger ( $ logger ) { if ( $ logger instanceof Logger ) { $ index = array_search ( $ logger , self :: $ loggers , true ) ; return false !== $ index ; } else { return isset ( self :: $ loggers [ $ logger ] ) ; } }
Checks if such logging channel exists by name or instance
24,536
public static function removeLogger ( $ logger ) { if ( $ logger instanceof Logger ) { if ( false !== ( $ idx = array_search ( $ logger , self :: $ loggers , true ) ) ) { unset ( self :: $ loggers [ $ idx ] ) ; } } else { unset ( self :: $ loggers [ $ logger ] ) ; } }
Removes instance from registry by name or instance
24,537
public static function getInstance ( $ name ) { if ( ! isset ( self :: $ loggers [ $ name ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Requested "%s" logger instance is not in the registry' , $ name ) ) ; } return self :: $ loggers [ $ name ] ; }
Gets Logger instance from the registry
24,538
protected function unblock ( ) { if ( ! $ this -> blocked ) { return ; } foreach ( $ this -> pipes as $ pipe ) { stream_set_blocking ( $ pipe , 0 ) ; } if ( is_resource ( $ this -> input ) ) { stream_set_blocking ( $ this -> input , 0 ) ; } $ this -> blocked = false ; }
Unblocks streams .
24,539
public function getEndpointForUrl ( $ url ) { $ cacheKey = sha1 ( $ url . $ this -> preferredFormat . json_encode ( $ this -> supportedFormats ) ) ; if ( ! isset ( $ this -> cachedEndpoints [ $ url ] ) ) { $ this -> cachedEndpoints [ $ url ] = $ this -> fetchEndpointForUrl ( $ url ) ; if ( trim ( $ this -> cachedEndpoints [ $ url ] ) === '' ) { throw new Exception ( 'Empty url endpoints' , 1360175845 ) ; } $ this -> endPointCache -> set ( $ cacheKey , $ this -> cachedEndpoints [ $ url ] ) ; } elseif ( $ this -> endPointCache -> has ( $ cacheKey ) === true ) { $ this -> cachedEndpoints [ $ url ] = $ this -> endPointCache -> get ( $ cacheKey ) ; } return $ this -> cachedEndpoints [ $ url ] ; }
Get the provider s endpoint URL for the supplied resource .
24,540
protected function fetchEndpointForUrl ( $ url ) { $ endPoint = null ; try { $ content = $ this -> browser -> getContent ( $ url ) ; } catch ( Exception $ exception ) { throw new Exception ( 'Unable to fetch the page body for "' . $ url . '": ' . $ exception -> getMessage ( ) , Exception :: PAGE_BODY_FETCH_FAILED ) ; } preg_match_all ( "/<link rel=\"alternate\"[^>]+>/i" , $ content , $ out ) ; if ( $ out [ 0 ] ) { foreach ( $ out [ 0 ] as $ link ) { if ( strpos ( $ link , trim ( $ this -> preferredFormat . '+oembed' ) ) !== false ) { $ endPoint = $ this -> extractEndpointFromAttributes ( $ link ) ; break ; } } } else { throw new Exception ( 'No valid oEmbed links found on the document at "' . $ url . '".' , Exception :: NO_OEMBED_LINKS_FOUND ) ; } return $ endPoint ; }
Fetch the provider s endpoint URL for the supplied resource .
24,541
public function all ( ) { return array_merge ( $ this -> messages [ self :: DURABLE ] , $ this -> messages [ self :: NOW ] ) ; }
Get all messages .
24,542
protected function load ( ) { $ this -> reset ( ) ; $ messages = $ this -> cookie -> get ( $ this -> cookieKey ) ; if ( $ messages ) { $ messages = json_decode ( $ messages , true ) ; if ( ! empty ( $ messages [ self :: DURABLE ] ) ) { $ this -> messages [ self :: DURABLE ] = $ messages [ self :: DURABLE ] ; } if ( ! empty ( $ messages [ self :: NEXT ] ) ) { $ this -> messages [ self :: NOW ] = $ messages [ self :: NEXT ] ; } $ this -> save ( ) ; } return $ this ; }
Load messages from cookie .
24,543
public function reset ( ) { $ this -> messages = [ ] ; foreach ( self :: $ when as $ when ) { $ this -> messages [ $ when ] = [ ] ; } return $ this ; }
Reset messages and build array structure .
24,544
protected function save ( ) { $ messages = [ ] ; foreach ( [ self :: DURABLE , self :: NEXT ] as $ when ) { if ( ! empty ( $ this -> messages [ $ when ] ) ) { $ messages [ $ when ] = $ this -> messages [ $ when ] ; } } if ( $ messages ) { $ messages = json_encode ( $ messages ) ; $ this -> cookie -> set ( $ this -> cookieKey , $ messages ) ; } else { $ this -> cookie -> remove ( $ this -> cookieKey ) ; } return $ this ; }
Save messages to cookie .
24,545
public function setTimeout ( $ timeout ) { if ( null === $ timeout ) { $ this -> timeout = null ; return $ this ; } $ timeout = ( float ) $ timeout ; if ( $ timeout < 0 ) { throw new InvalidArgumentException ( 'The timeout value must be a valid positive integer or float number.' ) ; } $ this -> timeout = $ timeout ; return $ this ; }
Sets the process timeout .
24,546
public function setupLogging ( LoggerInterface $ logger , array $ incrementalAttributesToLog = [ 'dn' ] ) { if ( empty ( $ incrementalAttributesToLog ) ) { throw new InvalidArgumentException ( 'List of entry attributes to be logged during incremental sync cannot be empty' ) ; } $ this -> logger = $ logger ; $ this -> incrementalAttributesToLog = $ incrementalAttributesToLog ; }
Enables and adjusts logging
24,547
public function poll ( $ forceFullSync = false ) { $ pollTaskRepository = $ this -> entityManager -> getRepository ( PollTask :: class ) ; $ lastSuccessfulPollTask = $ pollTaskRepository -> findLastSuccessfulForPoller ( $ this -> getName ( ) ) ; $ rootDseDnsHostName = $ this -> fetcher -> getRootDseDnsHostName ( ) ; $ invocationId = $ this -> fetcher -> getInvocationId ( ) ; $ isFullSyncRequired = $ this -> isFullSyncRequired ( $ forceFullSync , $ lastSuccessfulPollTask , $ rootDseDnsHostName , $ invocationId ) ; $ highestCommitedUSN = $ this -> fetcher -> getHighestCommittedUSN ( ) ; $ currentTask = $ this -> createCurrentPollTask ( $ invocationId , $ highestCommitedUSN , $ rootDseDnsHostName , $ lastSuccessfulPollTask , $ isFullSyncRequired ) ; $ this -> entityManager -> persist ( $ currentTask ) ; $ this -> entityManager -> flush ( ) ; try { if ( $ isFullSyncRequired ) { $ fetchedEntriesCount = $ this -> fullSync ( $ currentTask , $ highestCommitedUSN ) ; } else { $ usnChangedStartFrom = $ lastSuccessfulPollTask -> getMaxUSNChangedValue ( ) + 1 ; $ fetchedEntriesCount = $ this -> incrementalSync ( $ currentTask , $ usnChangedStartFrom , $ highestCommitedUSN ) ; } $ currentTask -> succeed ( $ fetchedEntriesCount ) ; return $ fetchedEntriesCount ; } catch ( Exception $ e ) { $ currentTask -> fail ( $ e -> getMessage ( ) ) ; throw $ e ; } finally { $ this -> entityManager -> flush ( ) ; } }
Make a poll request to Active Directory and return amount of processed entries
24,548
protected function createCurrentPollTask ( $ invocationId , $ highestCommitedUSN , $ rootDseDnsHostName , $ lastSuccessfulPollTask , $ isFullSync ) { $ currentTask = new PollTask ( $ this -> name , $ invocationId , $ highestCommitedUSN , $ rootDseDnsHostName , $ lastSuccessfulPollTask , $ isFullSync ) ; return $ currentTask ; }
Creates poll task entity for current sync
24,549
private function isFullSyncRequired ( $ forceFullSync , PollTask $ lastSuccessfulSyncTask = null , $ currentRootDseDnsHostName , $ currentInvocationId ) { if ( $ forceFullSync ) { return true ; } if ( ! $ lastSuccessfulSyncTask ) { return true ; } if ( $ lastSuccessfulSyncTask -> getRootDseDnsHostName ( ) != $ currentRootDseDnsHostName ) { return true ; } if ( $ lastSuccessfulSyncTask -> getInvocationId ( ) != $ currentInvocationId ) { return true ; } return false ; }
Returns true is full AD sync required and false otherwise
24,550
private function fullSync ( PollTask $ currentTask , $ highestCommitedUSN ) { $ entries = $ this -> fetcher -> fullFetch ( $ highestCommitedUSN ) ; $ this -> synchronizer -> fullSync ( $ this -> name , $ currentTask -> getId ( ) , $ entries ) ; $ this -> logFullSync ( $ entries ) ; return count ( $ entries ) ; }
Performs full sync
24,551
private function incrementalSync ( PollTask $ currentTask , $ usnChangedStartFrom , $ highestCommitedUSN ) { list ( $ changed , $ deleted ) = $ this -> fetcher -> incrementalFetch ( $ usnChangedStartFrom , $ highestCommitedUSN , $ this -> detectDeleted ) ; $ this -> synchronizer -> incrementalSync ( $ this -> name , $ currentTask -> getId ( ) , $ changed , $ deleted ) ; $ this -> logIncrementalSync ( $ changed , $ deleted ) ; return count ( $ changed ) + count ( $ deleted ) ; }
Performs incremental sync
24,552
private function logFullSync ( $ entries ) { if ( $ this -> logger ) { $ this -> logger -> info ( sprintf ( "Full sync processed. Entries count: %d." , count ( $ entries ) ) ) ; } }
Logs full sync if needed
24,553
private function logIncrementalSync ( $ changed , $ deleted ) { if ( $ this -> logger ) { $ entriesLogReducer = function ( $ entry ) { return array_intersect_key ( $ entry , array_flip ( $ this -> incrementalAttributesToLog ) ) ; } ; $ changedToLog = array_map ( $ entriesLogReducer , $ changed ) ; $ deletedToLog = array_map ( $ entriesLogReducer , $ deleted ) ; $ this -> logger -> info ( sprintf ( "Incremental changeset processed. Changed: %d, Deleted: %d." , count ( $ changed ) , count ( $ deleted ) ) , [ 'changed' => $ changedToLog , 'deleted' => $ deletedToLog ] ) ; } }
Logs incremental sync if needed
24,554
public function filter ( \ Closure $ closure ) { $ newInstance = new self ( ) ; $ newInstance -> setArray ( array_filter ( $ this -> array , $ closure ) ) ; return $ newInstance ; }
returns a clone of this ArrayList filtered by the given closure function
24,555
public function filterByKeys ( array $ keys ) { $ newInstance = new self ( ) ; $ newInstance -> setArray ( array_filter ( $ this -> array , function ( $ key ) use ( $ keys ) { return array_search ( $ key , $ keys ) !== false ; } , ARRAY_FILTER_USE_KEY ) ) ; return $ newInstance ; }
returns a clone of this ArrayList filtered by the given array keys
24,556
public function map ( \ closure $ mapFunction ) { $ newInstance = new self ( ) ; $ newInstance -> setArray ( array_map ( $ mapFunction , $ this -> array ) ) ; return $ newInstance ; }
returns a new ArrayList containing all the elements of this ArrayList after applying the callback function to each one .
24,557
public function flatten ( ) { $ flattenedArray = [ ] ; array_walk_recursive ( $ this -> array , function ( $ item ) use ( & $ flattenedArray ) { $ flattenedArray [ ] = $ item ; } ) ; $ newInstance = new self ( ) ; $ newInstance -> setArray ( $ flattenedArray ) ; return $ newInstance ; }
Returns a new ArrayList containing an one - dimensional array of all elements of this ArrayList . Keys are going lost .
24,558
public function TicketForm ( ) { if ( $ this -> owner -> Tickets ( ) -> count ( ) && $ this -> owner -> getTicketsAvailable ( ) ) { $ ticketForm = new TicketForm ( $ this -> owner , 'TicketForm' , $ this -> owner -> Tickets ( ) , $ this -> owner -> dataRecord ) ; $ ticketForm -> setNextStep ( CheckoutSteps :: start ( ) ) ; return $ ticketForm ; } else { return null ; } }
Get the ticket form with available tickets
24,559
public function WaitingListRegistrationForm ( ) { if ( $ this -> owner -> Tickets ( ) -> count ( ) && $ this -> owner -> getTicketsSoldOut ( ) && ! $ this -> owner -> getEventExpired ( ) ) { return new WaitingListRegistrationForm ( $ this -> owner , 'WaitingListRegistrationForm' ) ; } else { return null ; } }
show the waiting list form when the event is sold out
24,560
protected function getAlertColor ( $ level ) { switch ( true ) { case $ level >= Logger :: ERROR : return 'red' ; case $ level >= Logger :: WARNING : return 'yellow' ; case $ level >= Logger :: INFO : return 'green' ; case $ level == Logger :: DEBUG : return 'gray' ; default : return 'yellow' ; } }
Assigns a color to each level of log records .
24,561
private function setConfig ( \ Phalcon \ Config $ config ) { if ( defined ( CURRENT_TASK ) === true ) { $ this -> taskName = CURRENT_TASK ; } $ this -> config = $ config -> cli -> { $ this -> taskName } ; return $ this ; }
Setup current task configurations
24,562
private function setLogger ( ) { $ config = $ this -> getConfig ( ) ; if ( $ config -> offsetExists ( 'errors' ) === true && $ config -> errors === true ) { $ this -> logger = new FileAdapter ( $ this -> getConfig ( ) -> errorLog ) ; } return $ this ; }
Setup file logger
24,563
public function setSilentErrorHandler ( ) { set_error_handler ( function ( $ errno , $ errstr , $ errfile , $ errline , array $ errcontext ) { if ( 0 === error_reporting ( ) ) { return false ; } if ( $ this -> logger != null ) { $ this -> getLogger ( ) -> log ( $ errstr , Logger :: CRITICAL ) ; } } ) ; }
Silent error handler catching WARNINGS & NOTICIES
24,564
private function checkFile ( string & $ file ) : bool { $ file = "{$this->directory}/{$file}" ; return file_exists ( $ file ) || ( touch ( $ file ) && chmod ( $ file , 0600 ) ) ; }
Check file .
24,565
public function getKey ( $ item , $ return_all = false ) { if ( $ return_all === true ) { return $ this -> getKeys ( ) ; } if ( $ this -> hasKey ( $ item -> getIdentifier ( ) ) ) { return $ item -> getIdentifier ( ) ; } return false ; }
Return the key for the given item .
24,566
public function getPlayerPosition ( $ login ) { return isset ( $ this -> positionPerPlayer [ $ login ] ) ? $ this -> positionPerPlayer [ $ login ] : null ; }
Get the position of a player
24,567
public function getPlayerRecord ( $ login ) { return isset ( $ this -> recordsPerPlayer [ $ login ] ) ? $ this -> recordsPerPlayer [ $ login ] : null ; }
Get a players record information .
24,568
public function loadForMap ( $ mapUid , $ nbLaps ) { foreach ( $ this -> records as $ record ) { $ record -> clearAllReferences ( false ) ; unset ( $ record ) ; } foreach ( $ this -> recordsPerPlayer as $ record ) { $ record -> clearAllReferences ( false ) ; unset ( $ record ) ; } RecordTableMap :: clearInstancePool ( ) ; $ this -> recordsPerPlayer = [ ] ; $ this -> positionPerPlayer = [ ] ; $ this -> currentMapUid = $ mapUid ; $ this -> currentNbLaps = $ nbLaps ; $ this -> records = $ this -> recordQueryBuilder -> getMapRecords ( $ mapUid , $ nbLaps , $ this -> getScoreOrdering ( ) , $ this -> nbRecords -> get ( ) ) ; $ position = 1 ; foreach ( $ this -> records as $ record ) { $ this -> recordsPerPlayer [ $ record -> getPlayer ( ) -> getLogin ( ) ] = $ record ; $ this -> positionPerPlayer [ $ record -> getPlayer ( ) -> getLogin ( ) ] = $ position ++ ; } }
Load records for a certain map .
24,569
public function loadForPlayers ( $ mapUid , $ nbLaps , $ logins ) { $ logins = array_diff ( $ logins , array_keys ( $ this -> recordsPerPlayer ) ) ; if ( ! empty ( $ logins ) ) { $ records = $ this -> recordQueryBuilder -> getPlayerMapRecords ( $ mapUid , $ nbLaps , $ logins ) ; foreach ( $ records as $ record ) { $ this -> recordsPerPlayer [ $ record -> getPlayer ( ) -> getLogin ( ) ] = $ record ; } } }
Load records for certain players only .
24,570
public function save ( ) { $ con = Propel :: getWriteConnection ( RecordTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; foreach ( $ this -> recordsPerPlayer as $ record ) { $ record -> save ( ) ; } $ con -> commit ( ) ; RecordTableMap :: clearInstancePool ( ) ; }
Save all new records .
24,571
protected function getNewRecord ( $ login ) { $ record = new Record ( ) ; $ record -> setPlayer ( $ this -> playerDb -> get ( $ login ) ) ; $ record -> setNbLaps ( $ this -> currentNbLaps ) ; $ record -> setNbFinish ( 0 ) ; $ record -> setMapUid ( $ this -> currentMapUid ) ; return $ record ; }
Get a new record instance .
24,572
protected function updateRecordStats ( Record $ record , $ score ) { $ record -> setAvgScore ( ( ( $ record -> getAvgScore ( ) * $ record -> getNbFinish ( ) ) + $ score ) / ( $ record -> getNbFinish ( ) + 1 ) ) ; $ record -> setNbFinish ( $ record -> getNbFinish ( ) + 1 ) ; }
Update Records statistics .
24,573
public function location ( $ param ) { try { $ result = $ this -> geocoder -> geocode ( $ param ) ; return ( new Geo ( $ result ) ) -> toArray ( ) ; } catch ( \ Exception $ e ) { throw new GeoServiceException ( $ e -> getMessage ( ) ) ; } }
Get address from requested param
24,574
public function getExtraFunctionCalls ( $ dataArrayJs , $ optionsJs ) { $ extraFunctionCalls = array ( ) ; if ( $ this -> zooming ) { $ extraFunctionCalls [ ] = sprintf ( self :: ZOOMING_FUNCTION , $ dataArrayJs , $ optionsJs , $ dataArrayJs , $ optionsJs ) ; } if ( $ this -> useLabels ) { $ seriesLabels = json_encode ( $ this -> pointLabels ) ; $ top = '' ; $ left = '' ; $ pixelCount = '15' ; for ( $ i = 0 ; $ i < strlen ( $ this -> labelSettings [ 'location' ] ) ; $ i ++ ) { switch ( $ this -> labelSettings [ 'location' ] [ $ i ] ) { case 'n' : $ top = '-' . $ pixelCount ; break ; case 'e' : $ left = '+' . $ pixelCount ; break ; case 's' : $ top = '+' . $ pixelCount ; break ; case 'w' : $ left = '-' . $ pixelCount ; } } $ paddingx = '-' . ( isset ( $ this -> labelSettings [ 'xpadding' ] ) ? $ this -> labelSettings [ 'xpadding' ] : '0' ) ; $ paddingy = '-' . ( isset ( $ this -> labelSettings [ 'ypadding' ] ) ? $ this -> labelSettings [ 'ypadding' ] : '0' ) ; $ extraFunctionCalls [ ] = sprintf ( self :: LABELS_FUNCTION , $ seriesLabels , $ left , $ paddingx , $ top , $ paddingy ) ; } if ( $ this -> highlighting ) { $ formatPoints = "x + ',' + y" ; foreach ( $ this -> dateAxes as $ axis => $ flag ) { if ( $ flag ) { $ formatPoints = str_replace ( $ axis , "(new Date(parseInt({$axis}))).toLocaleDateString()" , $ formatPoints ) ; } } $ extraFunctionCalls [ ] = sprintf ( self :: HIGHLIGHTING_FUNCTION , $ formatPoints ) ; } return $ extraFunctionCalls ; }
Populates script output with hacks required to give Flot featural parity with jqPlot
24,575
public function setAxisOptions ( $ axis , $ name , $ value ) { if ( strtolower ( $ axis ) === 'x' || strtolower ( $ axis ) === 'y' ) { $ axis = strtolower ( $ axis ) . 'axis' ; if ( array_key_exists ( $ name , $ this -> nativeOpts [ $ axis ] ) ) { $ this -> setNestedOptVal ( $ this -> options , $ axis , $ name , $ value ) ; } else { $ key = 'axes.' . $ axis . '.' . $ name ; if ( isset ( $ this -> optsMapper [ $ key ] ) ) { $ this -> setOpt ( $ this -> options , $ this -> optsMapper [ $ key ] , $ value ) ; } if ( $ name == 'formatString' ) { $ this -> options [ $ axis ] [ 'tickFormatter' ] = $ this -> getCallbackPlaceholder ( 'function(val, axis){return "' . $ value . '".replace(/%d/, val);}' ) ; } } } return $ this ; }
Sets an option for a given axis
24,576
public function initializeSeries ( $ series ) { parent :: initializeSeries ( $ series ) ; $ title = $ this -> getSeriesTitle ( $ series ) ; $ this -> options [ 'seriesStorage' ] [ $ title ] [ 'label' ] = $ title ; return $ this ; }
Registers a series performing some additional logic
24,577
protected function getOptionsJS ( ) { foreach ( $ this -> optsMapper as $ opt => $ mapped ) { if ( ( $ currOpt = $ this -> getOptVal ( $ this -> options , $ opt ) ) && ( $ currOpt !== null ) ) { $ this -> setOpt ( $ this -> options , $ mapped , $ currOpt ) ; $ this -> unsetOpt ( $ this -> options , $ opt ) ; } } $ opts = $ this -> options ; if ( $ this -> getOptVal ( $ opts , 'seriesStorage' , 'pie' , 'show' ) === null ) { $ this -> setNestedOptVal ( $ opts , 'seriesStorage' , 'pie' , 'show' , false ) ; } $ this -> unsetOpt ( $ opts , 'seriesStorage' ) ; $ this -> unsetOpt ( $ opts , 'seriesDefault' ) ; return $ this -> makeJSArray ( $ opts ) ; }
Mutates the option array to the format required for flot
24,578
protected function getOptVal ( array $ opts , $ option ) { $ ploded = explode ( '.' , $ option ) ; $ arr = $ opts ; $ val = null ; while ( $ curr = array_shift ( $ ploded ) ) { if ( isset ( $ arr [ $ curr ] ) ) { if ( is_array ( $ arr [ $ curr ] ) ) { $ arr = $ arr [ $ curr ] ; } else { return $ arr [ $ curr ] ; } } else { return null ; } } }
Retrieves a nested value or null
24,579
protected function setOpt ( array & $ opts , $ mapperString , $ val ) { $ args = explode ( '.' , $ mapperString ) ; array_push ( $ args , $ val ) ; $ this -> setNestedOptVal ( $ opts , $ args ) ; }
Sets a value in a nested array based on a dot - concatenated string Used primarily for mapping
24,580
protected function unsetOpt ( array & $ opts , $ mapperString ) { $ ploded = explode ( '.' , $ mapperString ) ; $ arr = & $ opts ; while ( $ curr = array_shift ( $ ploded ) ) { if ( isset ( $ arr [ $ curr ] ) ) { if ( is_array ( $ arr [ $ curr ] ) ) { $ arr = & $ arr [ $ curr ] ; } else { unset ( $ arr [ $ curr ] ) ; } } } }
Handles nested mappings
24,581
public function setSeriesLineWidth ( $ series , $ value ) { return $ this -> setNestedOptVal ( $ this -> options , 'seriesStorage' , $ this -> getSeriesTitle ( $ series ) , 'lines' , 'linewidth' , $ value ) ; }
Determines the width of the line we will show if we re showing it
24,582
public function setSeriesShowLine ( $ series , $ bool ) { return $ this -> setNestedOptVal ( $ this -> options , 'seriesStorage' , $ this -> getSeriesTitle ( $ series ) , 'lines' , 'show' , $ bool ) ; }
Determines whether we show the line for a series
24,583
public function setSeriesShowMarker ( $ series , $ bool ) { return $ this -> setNestedOptVal ( $ this -> options , 'seriesStorage' , $ this -> getSeriesTitle ( $ series ) , 'points' , 'show' , $ bool ) ; }
Determines whether we show the marker for a series
24,584
public function setAxisTicks ( $ axis , array $ ticks = array ( ) ) { if ( in_array ( $ axis , array ( 'x' , 'y' ) ) ) { $ isString = false ; $ alternateTicks = array ( ) ; $ cnt = 1 ; foreach ( $ ticks as $ tick ) { if ( ! ( ctype_digit ( $ tick ) || is_int ( $ tick ) ) ) { $ isString = true ; foreach ( $ ticks as $ tick ) { $ alternateTicks [ ] = array ( $ cnt ++ , $ tick ) ; } break ; } } $ this -> setNestedOptVal ( $ this -> options , $ axis . 'axis' , 'ticks' , $ isString ? $ alternateTicks : $ ticks ) ; } return $ this ; }
Responsible for setting the tick labels on a given axis
24,585
protected function execute ( $ value , EntityInterface $ parent_entity = null ) { $ success = true ; $ list = null ; if ( $ value instanceof EntityList ) { $ list = $ value ; } elseif ( null === $ value ) { $ list = new EntityList ( ) ; } elseif ( $ value instanceof EntityInterface ) { $ list = new EntityList ( ) ; $ list -> push ( $ value ) ; } elseif ( is_array ( $ value ) ) { $ list = new EntityList ( ) ; $ success = $ this -> createEntityList ( $ value , $ list , $ parent_entity ) ; } else { $ this -> throwError ( 'invalid_value_type' ) ; return false ; } $ count = count ( $ list ) ; if ( $ this -> hasOption ( self :: OPTION_MIN_COUNT ) ) { $ min_count = $ this -> getOption ( self :: OPTION_MIN_COUNT , 0 ) ; if ( $ count < ( int ) $ min_count ) { $ this -> throwError ( 'min_count' , [ 'count' => $ count , 'min_count' => $ min_count ] ) ; $ success = false ; } } if ( $ this -> hasOption ( self :: OPTION_MAX_COUNT ) ) { $ max_count = $ this -> getOption ( self :: OPTION_MAX_COUNT , 0 ) ; if ( $ count > ( int ) $ max_count ) { $ this -> throwError ( 'max_count' , [ 'count' => $ count , 'max_count' => $ max_count ] ) ; $ success = false ; } } if ( $ success ) { $ this -> setSanitizedValue ( $ list ) ; return true ; } return false ; }
Validates and sanitizes a given value respective to the valueholder s expectations .
24,586
public function onPodiumStart ( $ time ) { $ jbMap = $ this -> jukeboxService -> getFirst ( ) ; if ( $ jbMap ) { $ length = count ( $ this -> jukeboxService -> getMapQueue ( ) ) ; $ this -> chatNotification -> sendMessage ( 'expansion_jukebox.chat.nextjbmap' , null , [ "%mapname%" => $ jbMap -> getMap ( ) -> name , "%mapauthor%" => $ jbMap -> getMap ( ) -> author , "%nickname%" => $ jbMap -> getPlayer ( ) -> getNickName ( ) , "%length%" => $ length , ] ) ; } else { $ map = $ this -> mapStorage -> getNextMap ( ) ; $ this -> chatNotification -> sendMessage ( 'expansion_jukebox.chat.nextmap' , null , [ "%name%" => $ map -> name , "%author%" => $ map -> author , ] ) ; } }
Callback sent when the onPodiumStart section start .
24,587
public function draw ( string $ file , array $ data ) : string { $ this -> file = $ file ; $ this -> data = $ data ; return $ this -> getOutputs ( ) ; }
Proccess and render a template .
24,588
private function getOutputs ( ) : string { ob_start ( ) ; extract ( $ this -> data ) ; require $ this -> file ; $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ contents ; }
Handle template file .
24,589
public function update ( array $ data , $ Setting = null ) { if ( empty ( $ Setting ) ) { $ Setting = $ this -> byId ( $ data [ 'id' ] ) ; } foreach ( $ data as $ key => $ value ) { $ Setting -> $ key = $ value ; } $ Setting -> save ( ) ; return $ Setting ; }
Update an existing set of settings
24,590
public static function maxCharWidth ( $ string ) { $ chars = preg_split ( '//u' , $ string , null , PREG_SPLIT_NO_EMPTY ) ; if ( ! $ chars ) { return 0 ; } $ sizes = array_map ( 'strlen' , $ chars ) ; return max ( $ sizes ) ; }
Get max bytes needed per char .
24,591
public static function stripLinks ( $ text , $ replaceWith = '' ) { $ text = preg_replace ( '/(?:(?:[^\s\:>]+:)?\/\/|www\.)[^\s\.]+\.\w+[^\s<]+/u' , $ replaceWith , $ text ) ; $ text = preg_replace ( '/[^\s\.>]+\.[a-z]{2,}\/[^\s<]+/u' , $ replaceWith , $ text ) ; return $ text ; }
Remove links in text .
24,592
public static function stripSocials ( $ text , $ replaceWith = '' ) { $ text = preg_replace ( '/(?<=\s|^|>)@[^\s<]+/u' , $ replaceWith , $ text ) ; $ text = preg_replace ( '/(?:[^\s>]+\.)?facebook.com\/[^\s<]+/u' , $ replaceWith , $ text ) ; return $ text ; }
Remove social hints in text .
24,593
public static function toBool ( $ string ) { if ( is_null ( $ string ) ) { return false ; } if ( ! is_scalar ( $ string ) ) { throw new InvalidArgumentException ( "Value must be scalar" ) ; } if ( ! is_string ( $ string ) ) { return ( bool ) $ string ; } return ! in_array ( strtolower ( $ string ) , [ 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ] ) ; }
Convert string into bool value .
24,594
public static function toCase ( $ string , $ case ) { switch ( $ case ) { case self :: UPPER : $ string = mb_strtoupper ( $ string ) ; break ; case self :: LOWER : $ string = mb_strtolower ( $ string ) ; break ; case self :: UPPER_FIRST : $ string = mb_strtoupper ( mb_substr ( $ string , 0 , 1 ) ) . mb_substr ( $ string , 1 ) ; break ; case self :: UPPER_WORDS : $ string = mb_convert_case ( $ string , MB_CASE_TITLE ) ; break ; case self :: NONE : break ; default : throw new InvalidArgumentException ( "Cannot set case {$case}" ) ; } return $ string ; }
Convert case of a string .
24,595
public static function toSingleWhitespace ( $ string , $ trim = true ) { $ string = preg_replace ( "/\r|\n|\t/" , " " , $ string ) ; $ string = preg_replace ( "/ {2,}/" , " " , $ string ) ; if ( $ trim ) { $ string = self :: trim ( $ string ) ; } return $ string ; }
Convert to single line string without multiple whitespaces .
24,596
public function majRankPointGame ( ) { $ players = $ this -> findBy ( array ( ) , array ( 'pointGame' => 'DESC' ) ) ; Ranking :: addObjectRank ( $ players , 'rankPointGame' , array ( 'pointGame' ) ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Update column rankPointGame
24,597
public function majRankMedal ( ) { $ players = $ this -> findBy ( array ( ) , array ( 'chartRank0' => 'DESC' , 'chartRank1' => 'DESC' , 'chartRank2' => 'DESC' , 'chartRank3' => 'DESC' ) ) ; Ranking :: addObjectRank ( $ players , 'rankMedal' , array ( 'chartRank0' , 'chartRank1' , 'chartRank2' , 'chartRank3' ) ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Update column rankMedal
24,598
public function majRankProof ( ) { $ players = $ this -> findBy ( array ( ) , array ( 'nbChartProven' => 'DESC' ) ) ; Ranking :: addObjectRank ( $ players , 'rankProof' , array ( 'nbChartProven' ) ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Update column rankProof
24,599
public static function getDirectories ( ) { Logger :: info ( "Resolving dependencies for project" ) ; $ packages = array ( ) ; $ root = dirname ( dirname ( dirname ( dirname ( dirname ( dirname ( dirname ( __FILE__ ) ) ) ) ) ) ) ; $ composer = file_get_contents ( $ root . DIRECTORY_SEPARATOR . 'composer.json' ) ; $ composer = json_decode ( $ composer , true ) ; if ( array_key_exists ( 'require' , $ composer ) && ! empty ( $ composer [ 'require' ] ) ) { foreach ( $ composer [ 'require' ] as $ requirement => $ version ) { $ packages = array_merge ( self :: readFile ( $ requirement ) , $ packages ) ; } } else { Logger :: trace ( "Project has no dependencies" ) ; } foreach ( $ packages as $ package ) { Logger :: debug ( "Project references package %s" , $ package ) ; } Logger :: info ( "%d dependencies found" , count ( $ packages ) ) ; return $ packages ; }
Returns the list of packages and all the other referenced packages from the composer file .