idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
25,100
public function byYearAndByOrganization ( $ year , $ organiztionId ) { return $ this -> FiscalYear -> where ( 'year' , '=' , $ year ) -> where ( 'organization_id' , '=' , $ organiztionId ) -> get ( ) -> first ( ) ; }
Retrieve fiscal year by year and by organization
25,101
public function update ( array $ data , $ FiscalYear = null ) { if ( empty ( $ FiscalYear ) ) { $ FiscalYear = $ this -> byId ( $ data [ 'id' ] ) ; } foreach ( $ data as $ key => $ value ) { $ FiscalYear -> $ key = $ value ; } return $ FiscalYear -> save ( ) ; }
Update an existing fiscal year
25,102
public function isDiff ( $ first , $ second ) { if ( ! file_exists ( $ first ) ) throw new NoSuchFileException ( $ first ) ; $ second = $ this -> oFileNameResolver -> resolve ( $ first , $ second ) ; if ( ! file_exists ( $ second ) ) return true ; if ( filesize ( $ first ) !== filesize ( $ second ) ) return true ; if ( ! ( $ fh1 = fopen ( $ first , 'rb' ) ) ) throw new FileOpenException ( $ first ) ; if ( ! ( $ fh2 = fopen ( $ second , 'rb' ) ) ) throw new FileOpenException ( $ second ) ; while ( ! feof ( $ fh1 ) && ! feof ( $ fh2 ) ) { $ data1 = fread ( $ fh1 , static :: READ_SIZE ) ; if ( false === $ data1 ) throw new FileReadException ( $ first ) ; $ data2 = fread ( $ fh2 , static :: READ_SIZE ) ; if ( false === $ data2 ) throw new FileReadException ( $ second ) ; if ( $ data1 !== $ data2 ) return true ; } return false ; }
Are these two files different?
25,103
public function moveItem ( $ direct = null , $ id = null , $ delta = 1 ) { $ isJson = $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ; if ( $ isJson ) { Configure :: write ( 'debug' , 0 ) ; } $ result = $ this -> _model -> moveItem ( $ direct , $ id , $ delta ) ; if ( ! $ isJson ) { if ( ! $ result ) { $ this -> _controller -> Flash -> error ( __d ( 'view_extension' , 'Error move record %d %s' , $ id , __d ( 'view_extension_direct' , $ direct ) ) ) ; } return $ this -> _controller -> redirect ( $ this -> _controller -> request -> referer ( true ) ) ; } else { $ data = compact ( 'result' , 'direct' , 'delta' ) ; $ this -> _controller -> set ( compact ( 'data' ) ) ; $ this -> _controller -> set ( '_serialize' , 'data' ) ; } }
Action moveItem . Used to move item to new position .
25,104
public function dropItem ( ) { Configure :: write ( 'debug' , 0 ) ; if ( ! $ this -> _controller -> request -> is ( 'ajax' ) || ! $ this -> _controller -> request -> is ( 'post' ) || ! $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ id = $ this -> _controller -> request -> data ( 'target' ) ; $ newParentId = $ this -> _controller -> request -> data ( 'parent' ) ; $ oldParentId = $ this -> _controller -> request -> data ( 'parentStart' ) ; $ dropData = $ this -> _controller -> request -> data ( 'tree' ) ; $ dropData = json_decode ( $ dropData , true ) ; $ result = $ this -> _model -> moveDrop ( $ id , $ newParentId , $ oldParentId , $ dropData ) ; $ data = compact ( 'result' ) ; $ this -> _controller -> set ( compact ( 'data' ) ) ; $ this -> _controller -> set ( '_serialize' , 'data' ) ; }
Action dropItem . Used to drag and drop item .
25,105
public function organizationExists ( User $ client , $ organizationName ) { try { $ org = $ client -> getOrganization ( $ organizationName ) ; return $ org -> getName ( ) == $ organizationName ; } catch ( ClientException $ e ) { if ( 404 === $ e -> getCode ( ) ) { return false ; } throw $ e ; } }
Checks if the specified organization is visible to the current user .
25,106
public function stackExists ( Image $ client , $ stackName , $ organizationName = '' ) { try { $ stack = $ client -> getStack ( $ stackName , $ organizationName ) ; return $ stack -> getName ( ) == $ stackName ; } catch ( ClientException $ e ) { if ( 404 === $ e -> getCode ( ) ) { return false ; } throw $ e ; } }
Checks if the specified stack exists in the organization .
25,107
public function imageExists ( Image $ client , $ hash , $ organizationName = '' ) { try { $ sourceImage = $ client -> getSourceImage ( $ hash , $ organizationName ) ; return $ sourceImage instanceof SourceImage && $ sourceImage -> hash === $ hash ; } catch ( ClientException $ e ) { if ( 404 === $ e -> getCode ( ) ) { return false ; } throw $ e ; } }
Checks if the specified image exists in the organization .
25,108
public function getSourceImageContents ( Image $ client , $ hash , $ organizationName , $ stackName = null , $ format = 'jpg' ) { if ( ! $ stackName ) { return $ client -> getSourceImageContents ( $ hash , $ organizationName ) ; } $ uri = $ client -> getSourceImageUri ( $ hash , $ stackName , $ format , null , $ organizationName ) ; $ resp = ( new Client ( ) ) -> get ( $ uri ) ; return $ resp -> getBody ( ) -> getContents ( ) ; }
Download an image .
25,109
protected function handlerArguments ( $ user ) { return [ $ this -> container -> getDefinition ( 'bengor.user.infrastructure.persistence.' . $ user . '_repository' ) , $ this -> container -> getDefinition ( 'bengor.user.infrastructure.security.symfony.' . $ user . '_password_encoder' ) , ] ; }
Gets the handler arguments to inject in the constructor .
25,110
private function byRequestRememberPasswordSpecification ( $ user ) { ( new RequestRememberPasswordCommandBuilder ( $ this -> container , $ this -> persistence ) ) -> build ( $ user ) ; return [ 'command' => ByRequestRememberPasswordChangeUserPasswordCommand :: class , 'handler' => ByRequestRememberPasswordChangeUserPasswordHandler :: class , ] ; }
Gets the by request remember password specification .
25,111
public function syncData ( $ controller_data ) { if ( is_object ( $ controller_data ) ) { $ handler_data = $ this -> legacy_handler -> getData ( ) ; $ refl_class = new \ ReflectionClass ( get_class ( $ handler_data ) ) ; $ filter = \ ReflectionProperty :: IS_PUBLIC | \ ReflectionProperty :: IS_PROTECTED | \ ReflectionProperty :: IS_PRIVATE ; foreach ( $ refl_class -> getProperties ( $ filter ) as $ property ) { $ property -> setAccessible ( true ) ; $ property -> setValue ( $ handler_data , $ property -> getValue ( $ controller_data ) ) ; $ property -> setAccessible ( false ) ; } } return $ this -> legacy_handler -> getData ( ) ; }
Sync the data from the controller data to the handler data .
25,112
protected function getProcessCallback ( ) { return function ( $ state , $ response ) { list ( $ command , $ callback ) = $ this -> commands -> dequeue ( ) ; switch ( $ command -> getId ( ) ) { case 'SUBSCRIBE' : case 'PSUBSCRIBE' : $ wrapper = $ this -> getStreamingWrapperCreator ( ) ; $ callback = $ wrapper ( $ this , $ callback ) ; $ state -> setStreamingContext ( State :: PUBSUB , $ callback ) ; break ; case 'MONITOR' : $ wrapper = $ this -> getStreamingWrapperCreator ( ) ; $ callback = $ wrapper ( $ this , $ callback ) ; $ state -> setStreamingContext ( State :: MONITOR , $ callback ) ; break ; case 'MULTI' : $ state -> setState ( State :: MULTIEXEC ) ; goto process ; case 'EXEC' : case 'DISCARD' : $ state -> setState ( State :: CONNECTED ) ; goto process ; default : process : \ call_user_func ( $ callback , $ response , $ this , $ command ) ; break ; } } ; }
Returns the callback used to handle commands and firing the appropriate callbacks depending on the state of the connection .
25,113
protected function getStreamingWrapperCreator ( ) { return function ( $ connection , $ callback ) { return function ( $ state , $ response ) use ( $ connection , $ callback ) { \ call_user_func ( $ callback , $ response , $ connection , null ) ; } ; } ; }
Returns a wrapper to the user - provided callback used to handle response chunks streamed by replies to commands such as MONITOR SUBSCRIBE etc .
25,114
protected function createResource ( callable $ callback ) { $ parameters = $ this -> parameters ; $ flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT ; if ( $ parameters -> scheme === 'unix' ) { $ uri = "unix://$parameters->path" ; } else { $ uri = "$parameters->scheme://$parameters->host:$parameters->port" ; } if ( ! $ stream = @ stream_socket_client ( $ uri , $ errno , $ errstr , 0 , $ flags ) ) { $ this -> onError ( new ConnectionException ( $ this , \ trim ( $ errstr ) , $ errno ) ) ; return ; } \ stream_set_blocking ( $ stream , 0 ) ; $ this -> state -> setState ( State :: CONNECTING ) ; $ this -> loop -> addWriteStream ( $ stream , function ( $ stream ) use ( $ callback ) { if ( $ this -> onConnect ( ) ) { \ call_user_func ( $ callback , $ this ) ; $ this -> write ( ) ; } } ) ; $ this -> timeout = $ this -> armTimeoutMonitor ( $ parameters -> timeout ? : 5 , $ this -> errorCallback ? : function ( ) { } ) ; return $ stream ; }
Creates the underlying resource used to communicate with Redis .
25,115
public function sendMessage ( $ messageId , $ to = null , $ parameters = [ ] ) { $ message = $ messageId ; if ( is_string ( $ to ) ) { $ player = $ this -> playerStorage -> getPlayerInfo ( $ to ) ; $ message = $ this -> translations -> getTranslation ( $ messageId , $ parameters , strtolower ( $ player -> getLanguage ( ) ) ) ; } if ( is_array ( $ to ) ) { $ to = implode ( "," , $ to ) ; $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; } if ( $ to instanceof Group ) { $ to = implode ( "," , $ to -> getLogins ( ) ) ; $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; } if ( $ to === null || $ to instanceof Group ) { $ message = $ this -> translations -> getTranslations ( $ messageId , $ parameters ) ; $ this -> console -> writeln ( end ( $ message ) [ 'Text' ] ) ; } try { $ this -> factory -> getConnection ( ) -> chatSendServerMessage ( $ message , $ to ) ; } catch ( UnknownPlayerException $ e ) { $ this -> logger -> info ( "can't send chat message: $message" , [ "to" => $ to , "exception" => $ e ] ) ; } catch ( InvalidArgumentException $ ex ) { } }
Send message .
25,116
public static function guess ( string $ filename ) : ? string { if ( ! \ is_file ( $ filename ) ) { throw new FileNotFoundException ( $ filename ) ; } if ( ! \ is_readable ( $ filename ) ) { throw new AccessDeniedException ( $ filename ) ; } if ( self :: $ magicFile !== null ) { $ finfo = \ finfo_open ( \ FILEINFO_MIME_TYPE , self :: $ magicFile ) ; } else { $ finfo = \ finfo_open ( \ FILEINFO_MIME_TYPE ) ; } $ type = \ finfo_file ( $ finfo , $ filename ) ; \ finfo_close ( $ finfo ) ; return $ type ?? null ; }
Guesses the mime type using the PECL extension FileInfo .
25,117
public function remove ( $ name ) { $ name = $ this -> getFullName ( $ name ) ; if ( isset ( $ this -> responseCookies [ $ name ] ) ) { unset ( $ this -> responseCookies [ $ name ] ) ; } if ( null !== $ this -> get ( $ name ) ) { $ this -> set ( $ name , 'deleted' , '1' ) ; } return $ this ; }
Remove response cookie .
25,118
protected function checkValue ( $ value , $ condition ) { list ( $ filterType , $ valueToCheck ) = $ condition ; switch ( $ filterType ) { case self :: FILTER_TYPE_EQ : return $ valueToCheck == $ value ; case self :: FILTER_TYPE_NEQ : return $ valueToCheck != $ value ; case self :: FILTER_TYPE_LIKE : return strpos ( $ value , $ valueToCheck ) !== false ; default : throw new InvalidFilterTypeException ( "Filter type '$filterType' is unknown'" ) ; } }
Check if value respects condition .
25,119
public function getCodeFromCountry ( $ country ) { $ output = 'OTH' ; if ( array_key_exists ( $ country , $ this -> countriesMapping ) ) { $ output = $ this -> countriesMapping [ $ country ] ; } return $ output ; }
Get 3 - letter country code from full country name
25,120
public function getCountryFromCode ( $ code ) { $ code = strtoupper ( $ code ) ; $ output = "Other" ; if ( in_array ( $ code , $ this -> countriesMapping ) ) { foreach ( $ this -> countriesMapping as $ country => $ short ) { if ( $ code == $ short ) { $ output = $ country ; break ; } } } return $ output ; }
Get full country name from 3 - letter country code
25,121
public function getIsoAlpha2FromName ( $ name ) { try { return $ this -> iso -> alpha3 ( $ this -> getCodeFromCountry ( $ name ) ) [ 'alpha2' ] ; } catch ( OutOfBoundsException $ e ) { } try { return $ this -> iso -> name ( $ name ) [ 'alpha2' ] ; } catch ( OutOfBoundsException $ e ) { $ this -> logger -> warning ( "Can't get valid alpha2 code for country '$name'" ) ; } return "OT" ; }
Get iso2 code from Maniaplanet Country name
25,122
protected function dispatch ( $ method , $ params ) { foreach ( $ this -> plugins as $ plugin ) { $ plugin -> $ method ( ... $ params ) ; } }
Dispatch method call to all plugins .
25,123
public function byOrganizationAndByKey ( $ organizationId , $ key ) { return $ this -> CostCenter -> where ( 'organization_id' , '=' , $ organizationId ) -> where ( 'key' , '=' , $ key ) -> get ( ) ; }
Retrieve cost centers by organization and by key
25,124
protected function execute ( $ value , EntityInterface $ entity = null ) { $ success = true ; $ collection = null ; if ( $ value instanceof EntityList ) { $ collection = $ value ; } elseif ( null === $ value ) { $ collection = new EntityList ( ) ; } elseif ( is_array ( $ value ) ) { $ collection = $ this -> createEntityList ( $ value ) ; } else { $ this -> throwError ( 'invalid_type' ) ; $ success = false ; } if ( $ success ) { $ this -> setSanitizedValue ( $ collection ) ; } return $ success ; }
Valdiates and sanitizes a given value respective to the reference - valueholder s expectations .
25,125
public function addMap ( $ locale , $ map ) { $ locale = Locale :: sanitizeLocale ( $ locale ) ; $ this -> maps [ $ locale ] = $ map ; return $ this ; }
Add map for a virtual locale .
25,126
public function addMaps ( array $ maps ) { foreach ( $ maps as $ locale => $ map ) { $ this -> addMap ( $ locale , $ map ) ; } return $ this ; }
Add maps for virtual locales .
25,127
public function findAvailableLocales ( ) { $ path = $ this -> getPath ( ) ; $ domain = $ this -> getDomain ( ) ; if ( ! $ path || ! $ domain ) { throw new Exception ( "Values for 'path' and 'domain' must be set." ) ; } $ regexLocale = Locale :: REGEX_LOCALE ; $ regexDefault = "/^{$regexLocale}\/LC_MESSAGES\/{$domain}\.mo$/ui" ; $ regexVirtual = "/^(?<virtualLocale>C)\/LC_MESSAGES\/(?<virtualDomain>{$domain}[^a-z]{$regexLocale})\.mo$/ui" ; $ glob = "{$path}/*/LC_MESSAGES/{$domain}*.mo" ; foreach ( glob ( $ glob ) as $ parse ) { $ parse = str_replace ( $ path . '/' , '' , $ parse ) ; if ( preg_match ( $ regexDefault , $ parse , $ found ) || preg_match ( $ regexVirtual , $ parse , $ found ) ) { $ this -> addLocale ( $ found [ 'locale' ] ) ; if ( ! empty ( $ found [ 'virtualLocale' ] ) ) { $ map = [ 'domain' => $ found [ 'virtualDomain' ] , 'locale' => $ found [ 'virtualLocale' ] , ] ; $ this -> addMap ( $ found [ 'locale' ] , $ map ) ; } } } return $ this ; }
Dynamically find all available locales .
25,128
public function getDomain ( $ realDomain = false ) { if ( $ realDomain ) { return $ this -> getMap ( $ this -> getActive ( ) , 'domain' ) ? : $ this -> domain ; } return $ this -> domain ; }
Get locale domain .
25,129
public function getMap ( $ locale , $ key = null ) { $ locale = Locale :: sanitizeLocale ( $ locale ) ; if ( $ key ) { return isset ( $ this -> maps [ $ locale ] [ $ key ] ) ? $ this -> maps [ $ locale ] [ $ key ] : null ; } return isset ( $ this -> maps [ $ locale ] ) ? $ this -> maps [ $ locale ] : null ; }
Get map for specified name .
25,130
public function getRankingForUpdate ( Chart $ chart ) { $ queryBuilder = $ this -> createQueryBuilder ( 'pc' ) ; $ queryBuilder -> innerJoin ( 'pc.player' , 'p' ) -> addSelect ( 'p' ) -> innerJoin ( 'pc.status' , 'status' ) -> addSelect ( 'status' ) -> where ( 'pc.chart = :chart' ) -> setParameter ( 'chart' , $ chart ) -> andWhere ( 'status.boolRanking = 1' ) ; foreach ( $ chart -> getLibs ( ) as $ lib ) { $ key = 'value_' . $ lib -> getIdLibChart ( ) ; $ alias = 'pcl_' . $ lib -> getIdLibChart ( ) ; $ subQueryBuilder = $ this -> getEntityManager ( ) -> createQueryBuilder ( ) -> select ( sprintf ( '%s.value' , $ alias ) ) -> from ( 'VideoGamesRecordsCoreBundle:PlayerChartLib' , $ alias ) -> where ( sprintf ( '%s.libChart = :%s' , $ alias , $ key ) ) -> andWhere ( sprintf ( '%s.player = pc.player' , $ alias ) ) -> setParameter ( $ key , $ lib ) ; $ queryBuilder -> addSelect ( sprintf ( '(%s) as %s' , $ subQueryBuilder -> getQuery ( ) -> getDQL ( ) , $ key ) ) -> addOrderBy ( $ key , $ lib -> getType ( ) -> getOrderBy ( ) ) -> setParameter ( $ key , $ lib ) ; } return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Provides every playerChart for update purpose .
25,131
public function getRanking ( Chart $ chart , $ player = null , $ limit = null ) { $ queryBuilder = $ this -> getRankingBaseQuery ( $ chart ) ; $ queryBuilder -> andWhere ( 'status.boolRanking = 1' ) ; if ( null !== $ limit && null !== $ player ) { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> orX ( 'pc.rank <= :maxRank' , 'pc.player = :player' ) ) -> setParameter ( 'maxRank' , $ limit ) -> setParameter ( 'player' , $ player ) ; } elseif ( null !== $ limit ) { $ queryBuilder -> andWhere ( 'pc.rank <= :maxRank' ) -> setParameter ( 'maxRank' , $ limit ) ; } return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Provides valid ranking .
25,132
public function getDisableRanking ( Chart $ chart ) { $ queryBuilder = $ this -> getRankingBaseQuery ( $ chart ) ; $ queryBuilder -> andWhere ( 'status.boolRanking = 0' ) ; return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Provides disabled list .
25,133
static function dueLabel ( $ date ) { $ days = \ FlexiPeeHP \ FakturaVydana :: overdueDays ( $ date ) ; if ( $ days < 0 ) { $ type = 'success' ; $ msg = sprintf ( _ ( ' %s days to due' ) , new \ Ease \ TWB \ Badge ( abs ( $ days ) ) ) ; } else { $ msg = sprintf ( _ ( ' %s days after due' ) , new \ Ease \ TWB \ Badge ( abs ( $ days ) ) ) ; if ( $ days > 14 ) { $ type = 'danger' ; } else { $ type = 'warning' ; } } return new \ Ease \ TWB \ Label ( $ type , $ msg ) ; }
Ovedude label with days
25,134
protected function _createFileVersion ( $ timestamp = null ) { if ( ! is_int ( $ timestamp ) ) { $ timestamp = time ( ) ; } $ result = dechex ( $ timestamp ) ; return $ result ; }
Return version from timestamp .
25,135
protected function _prepareFilePath ( $ path = null ) { if ( empty ( $ path ) ) { return false ; } if ( DIRECTORY_SEPARATOR !== '\\' ) { return $ path ; } $ path = str_replace ( '\\' , '/' , $ path ) ; return $ path ; }
Replacing directory separator for Windows from backslash to slash .
25,136
protected function _getIncludeFilePath ( $ specificFullPath = null , $ specificPath = null , $ specificFileName = null ) { if ( empty ( $ specificFullPath ) || empty ( $ specificPath ) || empty ( $ specificFileName ) ) { return false ; } $ oFile = new File ( $ specificFullPath . $ specificFileName ) ; if ( ! $ oFile -> exists ( ) ) { return false ; } $ includeFilePath = $ this -> _prepareFilePath ( $ specificPath . $ specificFileName ) ; $ lastChange = $ oFile -> lastChange ( ) ; $ version = $ this -> _createFileVersion ( $ lastChange ) ; $ result = $ includeFilePath . '?v=' . $ version ; return $ result ; }
Return specific file for action View
25,137
public function css ( $ options = [ ] , $ params = [ ] , $ includeOnlyParam = false , $ useUserRolePrefix = false ) { $ css = $ this -> getFilesForAction ( 'css' , $ params , $ includeOnlyParam , $ useUserRolePrefix ) ; if ( empty ( $ css ) ) { return null ; } return $ this -> Html -> css ( $ css , $ options ) ; }
Creates a link element for specific files for action View CSS stylesheets .
25,138
public function run ( $ id , $ databaseConnectionName , & $ userAppsRecommendations ) { $ this -> Setting -> changeDatabaseConnection ( $ databaseConnectionName ) ; $ this -> Setting -> create ( array ( 'organization_id' => $ id ) ) ; array_push ( $ userAppsRecommendations , array ( 'appName' => $ this -> Lang -> get ( 'decima-accounting::menu.initialAccountingSetup' ) , 'appAction' => $ this -> Lang -> get ( 'decima-accounting::initial-accounting-setup.action' ) ) ) ; }
This method will be executed after an organization has been created .
25,139
public function create ( $ model = null , $ options = [ ] ) { $ form = parent :: create ( $ model , $ options ) ; if ( ! isset ( $ options [ 'url' ] ) || ( $ options [ 'url' ] !== false ) ) { return $ form ; } $ result = mb_ereg_replace ( 'action=\"[^\"]*\"' , '' , $ form ) ; return $ result ; }
Returns an HTML FORM element . Fix Ignore options url = > false
25,140
protected function _initLabel ( $ options ) { if ( isset ( $ options [ 'label' ] ) && is_array ( $ options [ 'label' ] ) ) { $ options [ 'label' ] = [ 'text' => $ options [ 'label' ] ] ; } return parent :: _initLabel ( $ options ) ; }
If label is a array transform it to proper label options array with the text option
25,141
public function getLabelTextFromField ( $ fieldName = null ) { $ text = '' ; if ( empty ( $ fieldName ) ) { return $ text ; } if ( strpos ( $ fieldName , '.' ) !== false ) { $ fieldElements = explode ( '.' , $ fieldName ) ; $ text = array_pop ( $ fieldElements ) ; } else { $ text = $ fieldName ; } if ( substr ( $ text , - 3 ) === '_id' ) { $ text = substr ( $ text , 0 , - 3 ) ; } $ text = Inflector :: humanize ( Inflector :: underscore ( $ text ) ) ; return $ text ; }
Returns text for label from field name .
25,142
protected function _prepareExtraOptions ( array & $ options , $ listExtraOptions = [ ] , $ optionPrefix = 'data-' ) { if ( empty ( $ options ) || empty ( $ listExtraOptions ) ) { return ; } if ( ! is_array ( $ listExtraOptions ) ) { $ listExtraOptions = [ $ listExtraOptions ] ; } $ extraOptions = array_intersect_key ( $ options , array_flip ( $ listExtraOptions ) ) ; if ( empty ( $ extraOptions ) ) { return ; } foreach ( $ extraOptions as $ extraOptionName => $ extraOptionValue ) { if ( is_bool ( $ extraOptionValue ) ) { if ( $ extraOptionValue ) { $ extraOptionValue = 'true' ; } else { $ extraOptionValue = 'false' ; } } $ options [ $ optionPrefix . $ extraOptionName ] = $ extraOptionValue ; unset ( $ options [ $ extraOptionName ] ) ; } }
Prepare extra option for form input .
25,143
protected function _inputMaskAlias ( $ fieldName , $ options = [ ] , $ alias = '' ) { if ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ defaultOptions = [ 'label' => false , ] ; $ options += $ defaultOptions ; $ options [ 'data-inputmask-alias' ] = $ alias ; return $ this -> text ( $ fieldName , $ options ) ; }
Creates input with input mask alias .
25,144
public function spin ( $ fieldName , $ options = [ ] ) { if ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ defaultOptions = $ this -> _getOptionsForElem ( 'spin.defaultOpt' ) ; $ options = $ defaultOptions + $ options ; $ listExtraOptions = $ this -> _getOptionsForElem ( 'spin.extraOpt' ) ; $ this -> _prepareExtraOptions ( $ options , $ listExtraOptions , 'data-spin-' ) ; $ numbers = '' ; $ decimals = '' ; if ( isset ( $ options [ 'data-spin-max' ] ) && ! empty ( $ options [ 'data-spin-max' ] ) ) { $ numbers = mb_strlen ( $ options [ 'data-spin-max' ] ) ; } if ( isset ( $ options [ 'data-spin-decimals' ] ) && ! empty ( $ options [ 'data-spin-decimals' ] ) ) { $ decimals = ( int ) $ options [ 'data-spin-decimals' ] ; } $ options [ 'data-inputmask-mask' ] = '9{1,' . $ numbers . '}' ; if ( ! empty ( $ decimals ) ) { $ options [ 'data-inputmask-mask' ] .= '.9{' . $ decimals . '}' ; } return $ this -> text ( $ fieldName , $ options ) ; }
Creates a touch spin input widget .
25,145
public function flag ( $ fieldName , $ options = [ ] ) { if ( ! empty ( $ fieldName ) ) { $ this -> setEntity ( $ fieldName ) ; } $ this -> unlockField ( $ this -> field ( ) ) ; if ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ defaultOptions = $ this -> _getOptionsForElem ( 'flag.defaultOpt' ) ; $ options = $ defaultOptions + $ options ; $ divClass = 'form-group' ; $ label = '' ; $ list = [ ] ; $ options = $ this -> _optionsOptions ( $ options ) ; if ( isset ( $ options [ 'label' ] ) ) { $ label = $ this -> label ( $ fieldName , $ options [ 'label' ] , [ 'class' => 'control-label' ] ) ; } if ( isset ( $ options [ 'options' ] ) ) { $ list = $ options [ 'options' ] ; } $ listExtraOptions = $ this -> _getOptionsForElem ( 'flag.extraOpt' ) ; $ this -> _prepareExtraOptions ( $ options , $ listExtraOptions ) ; $ errors = FormHelper :: error ( $ fieldName , null , [ 'class' => 'help-block' ] ) ; if ( ! empty ( $ errors ) ) { $ divClass .= ' has-error error' ; } $ divOptions = [ 'id' => $ this -> domId ( $ fieldName ) , 'data-input-name' => $ this -> _name ( null , $ fieldName ) , 'data-selected-country' => $ this -> value ( $ fieldName ) , ] ; $ divOptionsDefault = $ this -> _getOptionsForElem ( 'flag.divOpt' ) ; if ( ! empty ( $ list ) ) { $ divOptions [ 'data-countries' ] = json_encode ( $ list ) ; } foreach ( $ listExtraOptions as $ extraOptionName ) { if ( isset ( $ options [ 'data-' . $ extraOptionName ] ) ) { $ divClass [ 'data-' . $ extraOptionName ] = $ options [ 'data-' . $ extraOptionName ] ; } } $ result = $ this -> Html -> div ( $ divClass , $ label . $ this -> Html -> div ( null , '' , $ divOptions + $ divOptionsDefault ) . $ errors ) ; return $ result ; }
Creates a flagstrap input widget .
25,146
public function autocomplete ( $ fieldName , $ options = [ ] ) { if ( ! is_array ( $ options ) ) { $ options = [ ] ; } $ defaultOptions = $ this -> _getOptionsForElem ( 'autocomplete.defaultOpt' ) ; $ options = $ defaultOptions + $ options ; $ listExtraOptions = $ this -> _getOptionsForElem ( 'autocomplete.extraOpt' ) ; $ this -> _prepareExtraOptions ( $ options , $ listExtraOptions , 'data-autocomplete-' ) ; if ( ! isset ( $ options [ 'data-autocomplete-url' ] ) && ! isset ( $ options [ 'data-autocomplete-local' ] ) ) { $ options [ 'data-autocomplete-url' ] = $ this -> url ( $ this -> ViewExtension -> addUserPrefixUrl ( [ 'controller' => 'filter' , 'action' => 'autocomplete' , 'plugin' => 'cake_theme' , 'ext' => 'json' , 'prefix' => false ] ) ) ; } if ( isset ( $ options [ 'data-autocomplete-local' ] ) && ! empty ( $ options [ 'data-autocomplete-local' ] ) ) { if ( ! is_array ( $ options [ 'data-autocomplete-local' ] ) ) { $ options [ 'data-autocomplete-local' ] = [ $ options [ 'data-autocomplete-local' ] ] ; } $ options [ 'data-autocomplete-local' ] = json_encode ( $ options [ 'data-autocomplete-local' ] ) ; } return $ this -> text ( $ fieldName , $ options ) ; }
Creates text input with autocomplete .
25,147
public function createUploadForm ( $ model = null , $ options = [ ] ) { if ( empty ( $ options ) || ! is_array ( $ options ) ) { $ options = [ ] ; } $ optionsDefault = $ this -> _getOptionsForElem ( 'createUploadForm' ) ; $ options = $ this -> ViewExtension -> getFormOptions ( $ optionsDefault + $ options ) ; $ result = $ this -> create ( $ model , $ options ) ; return $ result ; }
Returns an HTML FORM element for upload file .
25,148
public function upload ( $ url = null , $ maxfilesize = 0 , $ acceptfiletypes = null , $ redirecturl = null , $ btnTitle = null , $ btnClass = null ) { if ( empty ( $ url ) ) { return null ; } if ( empty ( $ btnTitle ) ) { $ btnTitle = $ this -> ViewExtension -> iconTag ( 'fas fa-file-upload' ) . '&nbsp;' . $ this -> _getOptionsForElem ( 'upload.btnTitle' ) ; } if ( empty ( $ btnClass ) ) { $ btnClass = 'btn-success' ; } $ inputId = uniqid ( 'input_' ) ; $ progressId = uniqid ( 'progress_' ) ; $ filesId = uniqid ( 'files_' ) ; $ inputOptions = [ 'id' => $ inputId , 'data-progress-id' => $ progressId , 'data-files-id' => $ filesId , 'data-fileupload-url' => $ url , 'data-fileupload-maxfilesize' => $ maxfilesize , 'data-fileupload-acceptfiletypes' => $ acceptfiletypes , 'data-fileupload-redirecturl' => $ redirecturl ] ; $ optionsDefault = $ this -> _getOptionsForElem ( 'upload.inputOpt' ) ; $ result = $ this -> Html -> tag ( 'span' , $ btnTitle . $ this -> input ( null , $ inputOptions + $ optionsDefault ) , [ 'class' => 'fileinput-button btn ' . $ btnClass ] ) . $ this -> Html -> tag ( 'br' ) . $ this -> Html -> tag ( 'br' ) . $ this -> Html -> div ( 'progress' , $ this -> Html -> div ( 'progress-bar progress-bar-success' , '' ) , [ 'id' => $ progressId ] ) . $ this -> Html -> tag ( 'hr' ) . $ this -> Html -> div ( 'files' , '' , [ 'id' => $ filesId ] ) . $ this -> Html -> tag ( 'br' ) ; return $ result ; }
Creates a upload input widget .
25,149
public function hiddenFields ( $ hiddenFields = null ) { if ( empty ( $ hiddenFields ) ) { return null ; } if ( ! is_array ( $ hiddenFields ) ) { $ hiddenFields = [ $ hiddenFields ] ; } $ result = '' ; $ options = [ 'type' => 'hidden' ] ; foreach ( $ hiddenFields as $ hiddenField ) { $ result .= $ this -> input ( $ hiddenField , $ options ) ; if ( $ this -> isFieldError ( $ hiddenField ) ) { $ result .= $ this -> Html -> div ( 'form-group has-error' , $ this -> error ( $ hiddenField , null , [ 'class' => 'help-block' ] ) ) ; } } return $ result ; }
Create hidden fields with validation error message .
25,150
public function create ( array $ data ) { $ AccountType = new AccountType ( ) ; $ AccountType -> setConnection ( $ this -> databaseConnectionName ) ; $ AccountType -> fill ( $ data ) -> save ( ) ; return $ AccountType ; }
Create a new account type
25,151
public function update ( array $ data , $ AccountType = null ) { if ( empty ( $ AccountType ) ) { $ AccountType = $ this -> byId ( $ data [ 'id' ] ) ; } foreach ( $ data as $ key => $ value ) { $ AccountType -> $ key = $ value ; } return $ AccountType -> save ( ) ; }
Update an existing account type
25,152
public function onProductShow ( ResourceControllerEvent $ event ) : void { $ product = $ event -> getSubject ( ) ; if ( ! $ product instanceof ProductInterface ) { return ; } $ currentRequest = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ currentRequest instanceof Request ) { $ currentRequest -> attributes -> set ( 'nglayouts_sylius_product' , $ product ) ; $ this -> context -> set ( 'sylius_product_id' , ( int ) $ product -> getId ( ) ) ; } }
Sets the currently displayed product to the request to be able to match with layout resolver .
25,153
public static function svgImg ( $ src , $ options = [ ] ) { $ fallback = ArrayHelper :: getValue ( $ options , 'fallback' , true ) ; $ fallbackExt = ArrayHelper :: getValue ( $ options , 'fallbackExt' , 'png' ) ; if ( $ fallback ) { if ( is_bool ( $ fallback ) && is_string ( $ src ) ) { $ fallback = rtrim ( $ src , 'svg' ) . $ fallbackExt ; $ options [ 'onerror' ] = "this.src = '$fallback'; this.onerror = '';" ; } else if ( is_string ( $ fallback ) ) { $ options [ 'onerror' ] = "this.src = '$fallback'; this.onerror = '';" ; } } return self :: img ( $ src , $ options ) ; }
Add an SVG image with the option of providing a fallback image . This is useful when you want to use SVG images but still provide fallback support for browsers that don t support SVG like IE8 and below .
25,154
public function run ( ) { if ( ! $ this -> server ) { try { $ this -> server = new AppServer ( $ this -> config -> socket -> host , $ this -> config -> socket -> port ) ; $ app = new Sonar ( new StorageService ( $ this -> config -> storage ) , new QueueService ( $ this -> config -> beanstalk ) , new GeoService ( ) , new CacheService ( ) ) ; $ this -> server -> route ( '/sonar' , $ app , [ '*' ] ) ; } catch ( QueueServiceException $ e ) { throw new AppServiceException ( $ e -> getMessage ( ) ) ; } catch ( ConnectionException $ e ) { throw new SocketServiceException ( $ e -> getMessage ( ) ) ; } catch ( StorageServiceException $ e ) { throw new AppServiceException ( $ e -> getMessage ( ) ) ; } catch ( CacheServiceException $ e ) { throw new AppServiceException ( $ e -> getMessage ( ) ) ; } } if ( isset ( $ this -> config -> storage ) === false ) { throw new AppServiceException ( 'There is no option `storage` in your configurations' ) ; } $ this -> server -> run ( ) ; }
Run the server application through the WebSocket protocol
25,155
public static function handleError ( $ code , $ message , $ file , $ line ) { $ list = static :: getSystemError ( $ code ) ; $ name = $ list [ 0 ] ; $ type = $ list [ 1 ] ; $ message = "\"$message\" in $file:$line" ; switch ( $ type ) { case static :: E_NOTICE : throw new NoticeError ( $ message ) ; case static :: E_WARNING : throw new WarningError ( $ message ) ; case static :: E_ERROR : throw new FatalError ( $ message ) ; default : return ; } }
Invoke default Error Handler .
25,156
public static function handleShutdown ( $ forceKill = false ) { $ err = error_get_last ( ) ; try { static :: handleError ( $ err [ 'type' ] , $ err [ 'message' ] , $ err [ 'file' ] , $ err [ 'line' ] ) ; } catch ( \ Error $ ex ) { echo call_user_func ( static :: $ errHandler , $ ex ) . PHP_EOL ; } catch ( \ Exception $ ex ) { echo call_user_func ( static :: $ excHandler , $ ex ) . PHP_EOL ; } if ( $ forceKill ) { posix_kill ( posix_getpid ( ) , 9 ) ; } }
Invoke default Shutdown Handler .
25,157
public function getInvocationId ( ) { $ dsServiceNode = $ this -> ldap -> getNode ( $ this -> getRootDse ( ) -> getDsServiceName ( ) ) ; $ invocationId = bin2hex ( $ dsServiceNode -> getAttribute ( 'invocationId' , 0 ) ) ; return $ invocationId ; }
Returns current invocation id
25,158
public function fullFetch ( $ uSNChangedTo ) { $ searchFilter = Filter :: andFilter ( Filter :: greaterOrEqual ( 'uSNChanged' , 0 ) , Filter :: lessOrEqual ( 'uSNChanged' , $ uSNChangedTo ) ) ; if ( $ this -> fullSyncEntryFilter ) { $ searchFilter = $ searchFilter -> addAnd ( $ this -> fullSyncEntryFilter ) ; } $ entries = $ this -> search ( $ searchFilter ) ; return $ entries ; }
Performs full fetch
25,159
public function incrementalFetch ( $ uSNChangedFrom , $ uSNChangedTo , $ detectDeleted = false ) { $ changedFilter = Filter :: andFilter ( Filter :: greaterOrEqual ( 'uSNChanged' , $ uSNChangedFrom ) , Filter :: lessOrEqual ( 'uSNChanged' , $ uSNChangedTo ) ) ; if ( $ this -> incrementalSyncEntryFilter ) { $ changedFilter = $ changedFilter -> addAnd ( $ this -> incrementalSyncEntryFilter ) ; } $ changed = $ this -> search ( $ changedFilter ) ; $ deleted = [ ] ; if ( $ detectDeleted ) { $ defaultNamingContext = $ this -> getRootDse ( ) -> getDefaultNamingContext ( ) ; $ options = $ this -> ldap -> getOptions ( ) ; $ originalHost = isset ( $ options [ 'host' ] ) ? $ options [ 'host' ] : '' ; $ hostForDeleted = rtrim ( $ originalHost , "/" ) . "/" . urlencode ( sprintf ( "<WKGUID=%s,%s>" , self :: WK_GUID_DELETED_OBJECTS_CONTAINER_W , $ defaultNamingContext ) ) ; if ( ! preg_match ( '~^ldap(?:i|s)?://~' , $ hostForDeleted ) ) { $ schema = "ldap://" ; if ( ( isset ( $ options [ 'port' ] ) && $ options [ 'port' ] == 636 ) || ( isset ( $ options [ 'useSsl' ] ) && $ options [ 'useSsl' ] == true ) ) { $ schema = "ldaps://" ; } $ hostForDeleted = $ schema . $ hostForDeleted ; } $ options [ 'host' ] = $ hostForDeleted ; $ this -> ldap -> setOptions ( $ options ) ; $ this -> ldap -> disconnect ( ) ; $ deletedFilter = Filter :: andFilter ( Filter :: equals ( 'isDeleted' , 'TRUE' ) , Filter :: greaterOrEqual ( 'uSNChanged' , $ uSNChangedFrom ) , Filter :: lessOrEqual ( 'uSNChanged' , $ uSNChangedTo ) ) ; if ( $ this -> deletedSyncEntryFilter ) { $ deletedFilter = $ deletedFilter -> addAnd ( $ this -> deletedSyncEntryFilter ) ; } $ deleted = $ this -> search ( $ deletedFilter ) ; } return [ $ changed , $ deleted ] ; }
Performs incremental fetch
25,160
private function getRootDse ( ) { if ( ! $ this -> rootDse ) { $ rootDse = $ this -> ldap -> getRootDse ( ) ; if ( ! $ rootDse instanceof ActiveDirectory ) { throw new UnsupportedRootDseException ( $ rootDse ) ; } $ this -> rootDse = $ rootDse ; } return $ this -> rootDse ; }
Returns current AD root dse
25,161
private function setupEntryFilter ( $ entryFilter ) { if ( $ entryFilter == null ) { return null ; } if ( is_string ( $ entryFilter ) ) { $ filter = new Filter \ StringFilter ( $ entryFilter ) ; } elseif ( $ entryFilter instanceof AbstractFilter ) { $ filter = $ entryFilter ; } else { throw new InvalidArgumentException ( sprintf ( 'baseEntryFilter argument must be either instance of %s or string. %s given' , AbstractFilter :: class , gettype ( $ entryFilter ) ) ) ; } return $ filter ; }
Validates specified zend ldap filter and cast it to AbstractFilter implementation
25,162
private function search ( AbstractFilter $ filter ) { if ( $ this -> ldapSearchOptions ) { $ ldapResource = $ this -> ldap -> getResource ( ) ; foreach ( $ this -> ldapSearchOptions as $ name => $ options ) { ldap_set_option ( $ ldapResource , $ name , $ options ) ; } } return $ this -> ldap -> searchEntries ( $ filter , null , Ldap :: SEARCH_SCOPE_SUB , $ this -> entryAttributesToFetch ) ; }
Performs ldap search by filter
25,163
public function setValue ( $ value , EntityInterface $ entity = null ) { $ attribute_validator = $ this -> getAttribute ( ) -> getValidator ( ) ; $ validation_result = $ attribute_validator -> validate ( $ value , $ entity ) ; if ( $ validation_result -> getSeverity ( ) <= IncidentInterface :: NOTICE ) { $ previous_native_value = $ this -> toNative ( ) ; $ this -> value = $ validation_result -> getSanitizedValue ( ) ; if ( ! $ this -> sameValueAs ( $ previous_native_value ) ) { $ value_changed_event = $ this -> createValueHolderChangedEvent ( $ previous_native_value ) ; $ this -> propagateValueChangedEvent ( $ value_changed_event ) ; } if ( $ this -> value instanceof CollectionInterface ) { $ this -> value -> addListener ( $ this ) ; } if ( $ this -> value instanceof EntityList ) { $ this -> value -> addEntityChangedListener ( $ this ) ; } } return $ validation_result ; }
Sets the valueholder s value .
25,164
public function sameValueAs ( $ other_value ) { $ null_value = $ this -> attribute -> getNullValue ( ) ; if ( $ null_value === $ this -> getValue ( ) && $ null_value === $ other_value ) { return true ; } $ validation_result = $ this -> getAttribute ( ) -> getValidator ( ) -> validate ( $ other_value ) ; if ( $ validation_result -> getSeverity ( ) !== IncidentInterface :: SUCCESS ) { return false ; } return $ this -> valueEquals ( $ validation_result -> getSanitizedValue ( ) ) ; }
Tells whether a specific ValueHolderInterface instance s value is considered equal to the given value .
25,165
public function isEqualTo ( ValueHolderInterface $ other_value_holder ) { if ( get_class ( $ this ) !== get_class ( $ other_value_holder ) ) { return false ; } return $ this -> sameValueAs ( $ other_value_holder -> getValue ( ) ) ; }
Tells whether a valueholder is considered being equal to the given valueholder . That is class and value are the same . The attribute and entity may be different .
25,166
public function addValueChangedListener ( ValueChangedListenerInterface $ listener ) { if ( ! $ this -> listeners -> hasItem ( $ listener ) ) { $ this -> listeners -> push ( $ listener ) ; } }
Registers a given listener as a recipient of value changed events .
25,167
public function removedValueChangedListener ( ValueChangedListenerInterface $ listener ) { if ( $ this -> listeners -> hasItem ( $ listener ) ) { $ this -> listeners -> removeItem ( $ listener ) ; } }
Removes a given listener as from our list of value - changed listeners .
25,168
public function onEntityChanged ( EntityChangedEvent $ embedded_entity_event ) { $ value_changed_event = $ embedded_entity_event -> getValueChangedEvent ( ) ; $ this -> propagateValueChangedEvent ( new ValueChangedEvent ( array ( 'attribute_name' => $ value_changed_event -> getAttributeName ( ) , 'prev_value' => $ value_changed_event -> getOldValue ( ) , 'value' => $ value_changed_event -> getNewValue ( ) , 'embedded_event' => $ embedded_entity_event ) ) ) ; }
Handles entity changed events that are sent by our embedd entity .
25,169
protected function propagateValueChangedEvent ( ValueChangedEvent $ event ) { foreach ( $ this -> listeners as $ listener ) { $ listener -> onValueChanged ( $ event ) ; } }
Propagates a given value changed event to all corresponding listeners .
25,170
protected function createValueHolderChangedEvent ( $ prev_value , EventInterface $ embedded_event = null ) { return new ValueChangedEvent ( array ( 'attribute_name' => $ this -> getAttribute ( ) -> getName ( ) , 'prev_value' => $ prev_value , 'value' => $ this -> toNative ( ) , 'embedded_event' => $ embedded_event ) ) ; }
Create a new value - changed event instance from the given info .
25,171
protected function resolveHandlingMethod ( $ eventType ) { $ pos = strrpos ( $ eventType , '\\' ) ; if ( $ pos !== false ) { $ eventType = substr ( $ eventType , $ pos + 1 ) ; } if ( substr ( $ eventType , - 5 ) === 'Event' ) { $ eventType = substr ( $ eventType , 0 , - 5 ) ; } return 'on' . $ eventType ; }
Derives event handling method name from event type
25,172
protected function setOptions ( $ options ) { if ( ! $ options instanceof OptionsInterface ) { $ options = is_array ( $ options ) ? $ options : [ ] ; $ options = new Options ( $ options ) ; } $ this -> options = $ options ; }
Sets the given options .
25,173
protected function shouldSkip ( $ object , $ propertyPath ) { if ( ! \ is_object ( $ object ) && ! \ is_array ( $ object ) ) { return false ; } if ( ! empty ( $ propertyPath ) ) { $ parts = \ explode ( '.' , $ propertyPath ) ; $ accessor = new PropertyAccessor ( ) ; $ parent = $ object ; foreach ( $ parts as $ childSubPath ) { if ( $ parent instanceof EntityInterface && $ this -> shouldSkipObjectProperty ( $ parent , $ childSubPath ) ) { return true ; } if ( $ accessor -> isReadable ( $ parent , $ childSubPath ) ) { $ parent = $ accessor -> getValue ( $ parent , $ childSubPath ) ; } else { return false ; } } } return false ; }
Returns true if a property of a given object should be ignored in the validation .
25,174
public function getAliasForClassname ( Classname $ class ) { foreach ( $ this -> classnames as $ c ) { if ( $ c [ 'classname' ] -> equals ( $ class ) ) { return str_replace ( '\\' , '_' , ltrim ( $ class -> classname , '\\' ) ) ; } } return str_replace ( '\\' , '_' , ltrim ( $ class -> classname , '\\' ) ) ; }
Renamed the given class name by replacing all slashes with underscores for loading using Magento s classloader
25,175
private function getParameter ( $ paramName ) { if ( array_key_exists ( $ paramName , $ _REQUEST ) ) { return str_replace ( FileUtil :: Slash ( ) . FileUtil :: Slash ( ) , FileUtil :: Slash ( ) , $ _REQUEST [ $ paramName ] ) ; } else { return "" ; } }
Look for a param name into the HttpContext Request already processed .
25,176
public function get ( $ key , $ persistent = false ) { if ( $ persistent ) { $ origKey = $ key ; $ key = "PVALUE.$key" ; } $ key = strtoupper ( $ key ) ; if ( isset ( $ this -> _config [ $ key ] ) ) { $ value = $ this -> _config [ $ key ] ; if ( $ value instanceof IProcessParameter ) { return $ value -> getParameter ( ) ; } else { return $ value ; } } elseif ( $ persistent ) { if ( $ this -> get ( $ origKey ) != "" ) $ value = $ this -> get ( $ origKey ) ; else if ( $ this -> getSession ( $ key ) ) $ value = $ this -> getSession ( $ key ) ; else $ value = "" ; $ this -> setSession ( $ key , $ value ) ; $ this -> set ( $ key , $ value ) ; return $ value ; } else { return "" ; } }
Access the Context collection and returns the value from a key .
25,177
public function authenticatedUser ( ) { if ( $ this -> IsAuthenticated ( ) ) { $ user = UserContext :: getInstance ( ) -> userInfo ( ) ; return $ user [ $ this -> getUsersDatabase ( ) -> getUserTable ( ) -> username ] ; } else { return "" ; } }
Get the authenticated user name
25,178
public function MakeLogin ( $ user , $ id ) { $ userObj = $ this -> getUsersDatabase ( ) -> getById ( $ id ) ; UserContext :: getInstance ( ) -> registerLogin ( $ userObj -> toArray ( ) ) ; }
Make login in XMLNuke Engine
25,179
private function AddCollectionToConfig ( $ collection ) { foreach ( $ collection as $ key => $ value ) { if ( $ key [ 0 ] == '/' ) $ this -> _virtualCommand = str_replace ( '_' , '.' , substr ( $ key , 1 ) ) ; $ this -> addPairToConfig ( $ key , $ value ) ; } }
Collection to be added
25,180
private function AddSessionToConfig ( $ collection ) { if ( is_array ( $ collection ) ) { foreach ( $ collection as $ key => $ value ) { $ this -> addPairToConfig ( 'session.' . $ key , $ value ) ; } } }
Collection Session to be added
25,181
private function AddCookieToConfig ( $ collection ) { foreach ( $ collection as $ key => $ value ) { $ this -> addPairToConfig ( 'cookie.' . $ key , $ value ) ; } }
Cookie Collection to be added
25,182
public function redirectUrl ( $ url ) { $ processor = new ParamProcessor ( ) ; $ url = $ processor -> GetFullLink ( $ url ) ; $ url = str_replace ( "&amp;" , "&" , $ url ) ; $ isBugVersion = stristr ( PHP_OS , "win" ) && stristr ( $ this -> get ( "GATEWAY_INTERFACE" ) , "cgi" ) && stristr ( $ this -> get ( "SERVER_SOFTWARE" ) , "iis" ) ; ob_clean ( ) ; if ( ! $ isBugVersion ) { header ( "Location: " . $ url ) ; } echo "<html>" ; echo "<head>" ; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=$url\">" ; echo "<style type='text/css'> " ; echo " #logo{" ; echo " width:32px;" ; echo " height:32px;" ; echo " top: 50%;" ; echo " left: 50%;" ; echo " margin-top: -16px;" ; echo " margin-left: -16px;" ; echo " position:absolute;" ; echo "} </style>" ; echo "</head>" ; echo "<h1></h1>" ; echo "<div id='logo'><a href='$url'><img src='common/imgs/ajax-loader.gif' border='0' title='If this page does not refresh, Click here' alt='If this page does not refresh, Click here' /></a></div>" ; echo "</html>" ; exit ; }
Redirect to Url .
25,183
public function getUploadFileNames ( $ systemArray = false ) { if ( $ systemArray ) { return $ _FILES ; } else { $ ret = array ( ) ; foreach ( $ _FILES as $ file => $ property ) { $ ret [ $ file ] = $ property [ "name" ] ; } } return $ ret ; }
Return the Field name and the FILENAME for Saving files
25,184
public function processUpload ( $ filenameProcessor , $ useProcessorForName , $ field = null ) { if ( ! ( $ filenameProcessor instanceof UploadFilenameProcessor ) ) { throw new UploadUtilException ( "processUpload must receive a UploadFilenameProcessor class" ) ; } else if ( is_null ( $ field ) ) { $ ret = array ( ) ; foreach ( $ _FILES as $ file => $ property ) { $ ret [ ] = $ this -> processUpload ( $ filenameProcessor , $ useProcessorForName , $ property ) ; } return $ ret ; } else if ( is_string ( $ field ) ) { $ ret = array ( ) ; $ ret [ ] = $ this -> processUpload ( $ filenameProcessor , $ useProcessorForName , $ _FILES [ $ field ] ) ; return $ ret ; } else if ( is_array ( $ field ) ) { if ( $ useProcessorForName ) { $ uploadfile = $ filenameProcessor -> FullQualifiedNameAndPath ( ) ; } else { $ uploadfile = $ filenameProcessor -> PathSuggested ( ) . FileUtil :: Slash ( ) . $ field [ "name" ] ; } if ( move_uploaded_file ( $ field [ 'tmp_name' ] , $ uploadfile ) ) { return $ uploadfile ; } else { $ message = "Unknow error: " . $ field [ 'error' ] ; switch ( $ field [ 'error' ] ) { case UPLOAD_ERR_CANT_WRITE : $ message = "Can't write" ; break ; case UPLOAD_ERR_EXTENSION : $ message = "Extension is not permitted" ; break ; case UPLOAD_ERR_FORM_SIZE : $ message = "Max post size reached" ; break ; case UPLOAD_ERR_INI_SIZE : $ message = "Max system size reached" ; break ; case UPLOAD_ERR_NO_FILE : $ message = "No file was uploaded" ; break ; case UPLOAD_ERR_NO_TMP_DIR : $ message = "No temp dir" ; break ; case UPLOAD_ERR_PARTIAL : $ message = "The uploaded file was only partially uploaded" ; break ; } throw new UploadUtilException ( $ message ) ; } } else { throw new UploadUtilException ( "Something is wrong with Upload file." ) ; } }
Process a document Upload
25,185
public function getSuggestedContentType ( ) { if ( count ( $ this -> _contentType ) == 0 ) { $ this -> _contentType [ "xsl" ] = $ this -> getXsl ( ) ; $ this -> _contentType [ "content-type" ] = "text/html" ; $ this -> _contentType [ "content-disposition" ] = "" ; $ this -> _contentType [ "extension" ] = "" ; if ( $ this -> get ( "xmlnuke.CHECKCONTENTTYPE" ) ) { $ filename = new AnydatasetFilenameProcessor ( "contenttype" ) ; $ anydataset = new AnyDataset ( $ filename -> FullQualifiedNameAndPath ( ) ) ; $ itf = new IteratorFilter ( ) ; $ itf -> addRelation ( "xsl" , Relation :: EQUAL , $ this -> getXsl ( ) ) ; $ it = $ anydataset -> getIterator ( $ itf ) ; if ( $ it -> hasNext ( ) ) { $ sr = $ it -> moveNext ( ) ; $ this -> _contentType = $ sr -> getOriginalRawFormat ( ) ; } else { $ filename = new AnydatasetSetupFilenameProcessor ( "contenttype" ) ; $ anydataset = new AnyDataset ( $ filename -> FullQualifiedNameAndPath ( ) ) ; $ itf = new IteratorFilter ( ) ; $ itf -> addRelation ( "xsl" , Relation :: EQUAL , $ this -> getXsl ( ) ) ; $ it = $ anydataset -> getIterator ( $ itf ) ; if ( $ it -> hasNext ( ) ) { $ sr = $ it -> moveNext ( ) ; $ this -> _contentType = $ sr -> getOriginalRawFormat ( ) ; } } } } return ( $ this -> _contentType ) ; }
Gets and array with the best content - type for the page . It checks the file contenttype . anydata . xsl if the property xmlnuke . CHECKCONTENTTYPE is true
25,186
public static function createFromArray ( $ properties , string $ priceType = self :: GROSS , $ validate = true ) { if ( ! is_array ( $ properties ) && ! $ properties instanceof Traversable ) { throw new InvalidArgumentException ( "prices must be iterable" ) ; } $ price = new static ( null , $ priceType ) ; if ( isset ( $ properties [ $ priceType ] ) ) { $ properties = [ $ priceType => $ properties [ $ priceType ] ] + $ properties ; } foreach ( $ properties as $ property => $ value ) { $ value = Text :: trim ( $ value ) ; if ( mb_strlen ( $ value ) ) { $ value = ConvertPrice :: getInstance ( ) -> sanitize ( $ value ) ; $ price -> set ( $ property , $ value , false , true ) ; } } if ( count ( $ properties ) > 1 ) { $ price -> calculate ( ) ; } if ( $ validate ) { $ price -> validate ( ) ; } return $ price ; }
Create new instance via static method .
25,187
public function da_request ( string $ method , string $ uri = '' , array $ options = [ ] ) : array { $ this -> lastRequest = microtime ( true ) ; try { $ response = $ this -> request ( $ method , $ uri , $ options ) ; } catch ( \ Exception $ e ) { if ( $ e instanceof RequestException ) { throw new DirectAdminRequestException ( sprintf ( 'DirectAdmin %s %s request failed.' , $ method , $ uri ) ) ; } if ( $ e instanceof TransferException ) { throw new DirectAdminTransferException ( sprintf ( 'DirectAdmin %s %s transfer failed.' , $ method , $ uri ) ) ; } } if ( $ response -> getHeader ( 'Content-Type' ) [ 0 ] === 'text/html' ) { throw new DirectAdminBadContentException ( sprintf ( 'DirectAdmin %s %s returned text/html.' , $ method , $ uri ) ) ; } $ body = $ response -> getBody ( ) -> getContents ( ) ; return $ this -> responseToArray ( $ body ) ; }
DirectAdmin request to Server .
25,188
protected function generateLanguageInput ( $ form ) { $ curValueArray = $ this -> _context -> get ( "xmlnuke.LANGUAGESAVAILABLE" ) ; foreach ( $ curValueArray as $ key => $ value ) { $ form -> addXmlnukeObject ( new XmlEasyList ( EasyListType :: SELECTLIST , "languagesavailable$key" , "xmlnuke.LANGUAGESAVAILABLE" , $ this -> getLangArray ( ) , $ value ) ) ; } $ form -> addXmlnukeObject ( new XmlEasyList ( EasyListType :: SELECTLIST , "languagesavailable" . ++ $ key , "xmlnuke.LANGUAGESAVAILABLE" , $ this -> getLangArray ( ) ) ) ; $ form -> addXmlnukeObject ( new XmlEasyList ( EasyListType :: SELECTLIST , "languagesavailable" . ++ $ key , "xmlnuke.LANGUAGESAVAILABLE" , $ this -> getLangArray ( ) ) ) ; $ form -> addXmlnukeObject ( new XmlInputHidden ( "languagesavailable" , $ key ) ) ; }
Write Languages Available function
25,189
private function needsRelogin ( SfdcConnectionInterface $ con ) { return ! $ con -> isLoggedIn ( ) || ( time ( ) - $ con -> getLastLoginTime ( ) ) > $ this -> connectionTTL ; }
Returns true if the given connection has timed out .
25,190
protected function getMinutesUntilExpired ( Payload $ payload ) { $ exp = Utils :: timestamp ( $ payload [ 'exp' ] ) ; $ iat = Utils :: timestamp ( $ payload [ 'iat' ] ) ; return $ exp -> max ( $ iat -> addMinutes ( $ this -> refreshTTL ) ) -> addMinute ( ) -> diffInMinutes ( ) ; }
Get the number of minutes until the token expiry .
25,191
public function filterByTrackuid ( $ trackuid = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ trackuid ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_TRACKUID , $ trackuid , $ comparison ) ; }
Filter the query on the trackUID column
25,192
public function filterByGbxmapname ( $ gbxmapname = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ gbxmapname ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_GBXMAPNAME , $ gbxmapname , $ comparison ) ; }
Filter the query on the gbxMapName column
25,193
public function filterByTrackid ( $ trackid = null , $ comparison = null ) { if ( is_array ( $ trackid ) ) { $ useMinMax = false ; if ( isset ( $ trackid [ 'min' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_TRACKID , $ trackid [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ trackid [ 'max' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_TRACKID , $ trackid [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_TRACKID , $ trackid , $ comparison ) ; }
Filter the query on the trackID column
25,194
public function filterByUserid ( $ userid = null , $ comparison = null ) { if ( is_array ( $ userid ) ) { $ useMinMax = false ; if ( isset ( $ userid [ 'min' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_USERID , $ userid [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ userid [ 'max' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_USERID , $ userid [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_USERID , $ userid , $ comparison ) ; }
Filter the query on the userID column
25,195
public function filterByUploadedat ( $ uploadedat = null , $ comparison = null ) { if ( is_array ( $ uploadedat ) ) { $ useMinMax = false ; if ( isset ( $ uploadedat [ 'min' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_UPLOADEDAT , $ uploadedat [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ uploadedat [ 'max' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_UPLOADEDAT , $ uploadedat [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_UPLOADEDAT , $ uploadedat , $ comparison ) ; }
Filter the query on the uploadedAt column
25,196
public function filterByUpdatedat ( $ updatedat = null , $ comparison = null ) { if ( is_array ( $ updatedat ) ) { $ useMinMax = false ; if ( isset ( $ updatedat [ 'min' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_UPDATEDAT , $ updatedat [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ updatedat [ 'max' ] ) ) { $ this -> addUsingAlias ( MxmapTableMap :: COL_UPDATEDAT , $ updatedat [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_UPDATEDAT , $ updatedat , $ comparison ) ; }
Filter the query on the updatedAt column
25,197
public function filterByMaptype ( $ maptype = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ maptype ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_MAPTYPE , $ maptype , $ comparison ) ; }
Filter the query on the mapType column
25,198
public function filterByTitlepack ( $ titlepack = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ titlepack ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_TITLEPACK , $ titlepack , $ comparison ) ; }
Filter the query on the titlePack column
25,199
public function filterByStylename ( $ stylename = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ stylename ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( MxmapTableMap :: COL_STYLENAME , $ stylename , $ comparison ) ; }
Filter the query on the styleName column