idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
19,100
public function getItems ( ) { uasort ( $ this -> items , function ( AdminMenuItem $ first , AdminMenuItem $ second ) { if ( $ first -> getPriority ( ) <= $ second -> getPriority ( ) ) { return 1 ; } return - 1 ; } ) ; return $ this -> items ; }
Get admin menu items .
19,101
public function setMenuAttributes ( $ type , ItemInterface $ menu ) { if ( isset ( $ this -> getBag ( ) -> get ( 'config' ) -> nav -> attributes -> { $ type } ) ) { $ attributes = ( array ) $ this -> getBag ( ) -> get ( 'config' ) -> nav -> attributes -> { $ type } ; switch ( $ type ) { case 'root' : $ menu -> setChildrenAttributes ( $ attributes ) ; break ; case 'parent' : $ menu -> setChildrenAttributes ( $ attributes ) ; break ; case 'child' : $ menu -> setAttributes ( $ attributes ) ; break ; case 'link' : $ menu -> setLinkAttributes ( $ attributes ) ; break ; case 'label' : $ menu -> setLabelAttributes ( $ attributes ) ; break ; default : break ; } } }
Responsible for adding attributes to menu item groups
19,102
public function exists ( ) : bool { if ( $ this -> caching == false ) { return file_exists ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> exists == null ) { $ this -> exists = file_exists ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> exists ; }
Returns true if the file exists ; otherwise returns false .
19,103
public function getGroup ( ) : string { if ( $ this -> caching == false ) { $ groupId = $ this -> getGroupId ( ) ; if ( $ groupId == - 2 ) { return "" ; } $ group = posix_getgrgid ( $ groupId ) ; return $ group [ "name" ] ; } if ( $ this -> group == null ) { $ groupId = $ this -> getOwnerId ( ) ; if ( $ groupId == - 2 ) { $ this -> group = "" ; } $ group = posix_getpwuid ( $ groupId ) ; $ this -> group = $ group [ "name" ] ; } return $ this -> group ; }
Returns the group of the file . On Windows on systems where files do not have groups or if an error occurs an empty string is returned .
19,104
public function isDir ( ) : bool { if ( $ this -> caching == false ) { return is_dir ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> isDir == null ) { $ this -> isDir = is_dir ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> isDir ; }
Returns true if this object points to a directory or to a symbolic link to a directory ; otherwise returns false .
19,105
public function isFile ( ) : bool { if ( $ this -> caching == false ) { return is_file ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> isFile == null ) { $ this -> isFile = is_file ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> isFile ; }
Returns true if this object points to a file or to a symbolic link to a file . Returns false if the object points to something which isn t a file such as a directory .
19,106
public function isReadable ( ) : bool { if ( $ this -> caching == false ) { return is_readable ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> isReadable == null ) { $ this -> isReadable = is_readable ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> isReadable ; }
Returns true if the user can read the file ; otherwise returns false .
19,107
public function isWritable ( ) : bool { if ( $ this -> caching == false ) { return is_writable ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> isWritable == null ) { $ this -> isWritable = is_writable ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> isWritable ; }
Returns true if the user can write to the file ; otherwise returns false .
19,108
public function getLastModified ( ) : \ DateTime { if ( $ this -> caching == false ) { return \ DateTime :: createFromFormat ( "F d Y H:i:s." , date ( "F d Y H:i:s." , filemtime ( $ this -> getAbsoluteFilePath ( ) ) ) ) ; } if ( $ this -> lastModified == null ) { $ this -> lastModified = \ DateTime :: createFromFormat ( "F d Y H:i:s." , date ( "F d Y H:i:s." , filemtime ( $ this -> getAbsoluteFilePath ( ) ) ) ) ; } return $ this -> lastModified ; }
Returns the date and time when the file was last modified .
19,109
public function getOwner ( ) : string { if ( $ this -> caching == false ) { $ ownerId = $ this -> getOwnerId ( ) ; if ( $ ownerId == - 2 ) { return "" ; } $ owner = posix_getpwuid ( $ ownerId ) ; return $ owner [ "name" ] ; } if ( $ this -> owner == null ) { $ ownerId = $ this -> getOwnerId ( ) ; if ( $ ownerId == - 2 ) { $ this -> owner = "" ; } $ owner = posix_getpwuid ( $ ownerId ) ; $ this -> owner = $ owner [ "name" ] ; } return $ this -> owner ; }
Returns the owner of the file . On systems where files do not have owners or if an error occurs an empty string is returned .
19,110
public function refresh ( ) : void { $ this -> size = null ; $ this -> lastModified = null ; $ this -> isReadable = null ; $ this -> isWritable = null ; $ this -> exists = null ; $ this -> created = null ; $ this -> isSymLink = null ; $ this -> isDir = null ; $ this -> isFile = null ; $ this -> isExecutable = null ; $ this -> ownerId = null ; $ this -> owner = null ; $ this -> group = null ; $ this -> groupId = null ; $ this -> lastRead = null ; }
Refreshes the information about the file i . e . reads in information from the file system the next time a cached property is fetched .
19,111
public function getSize ( ) : int { if ( $ this -> caching == false ) { return filesize ( $ this -> getAbsoluteFilePath ( ) ) ; } if ( $ this -> size == null ) { $ this -> size = filesize ( $ this -> getAbsoluteFilePath ( ) ) ; } return $ this -> size ; }
Returns the file size in bytes . If the file does not exist or cannot be fetched 0 is returned .
19,112
public function augmentNewSiteTreeItem ( & $ item ) { if ( isset ( $ _POST [ 'PageTypeFake' ] ) ) { $ item -> PageTypeFake = $ _POST [ 'PageTypeFake' ] ; } if ( isset ( $ _POST [ 'PageTypeID' ] ) ) { $ item -> PageTypeID = $ _POST [ 'PageTypeID' ] ; } }
Assigns new placeable pages to a page type
19,113
public static function firstSpace ( $ string ) { $ firstSpace = strpos ( $ string , " " ) ; return ( $ firstSpace === false ) ? strlen ( $ string ) : $ firstSpace ; }
First occurance of a space character
19,114
public static function calculate ( $ numSlots = 1 , $ numCores = 1 , $ ht = 'N' ) { $ totalCpu = ( $ ht == 'S' ) ? ( ( $ numSlots * $ numCores ) * 2 ) : ( $ numSlots * $ numCores ) ; $ aReturn = Array ( ) ; $ aReturn [ 'warning' ] = Array ( ) ; $ aReturn [ 'critical' ] = Array ( ) ; $ aReturn [ 'warning' ] [ 'load1min' ] = round ( ( $ totalCpu * 0.7 ) , 2 ) ; $ aReturn [ 'warning' ] [ 'load5min' ] = round ( ( $ totalCpu * 0.65 ) , 2 ) ; $ aReturn [ 'warning' ] [ 'load15min' ] = round ( ( $ totalCpu * 0.6 ) , 2 ) ; $ aReturn [ 'critical' ] [ 'load1min' ] = round ( ( $ totalCpu * 1.0 ) , 2 ) ; $ aReturn [ 'critical' ] [ 'load5min' ] = round ( ( $ totalCpu * 0.9 ) , 2 ) ; $ aReturn [ 'critical' ] [ 'load15min' ] = round ( ( $ totalCpu * 0.8 ) , 2 ) ; return $ aReturn ; }
Return calculation Threshoud alert CPU
19,115
public function getLastBuild ( ) { if ( $ this -> lastBuild == null ) { $ build = new self ( $ this -> getEngine ( ) , $ this -> getProject ( ) ) ; return $ build ; } return $ this -> lastBuild ; }
Returns the last build .
19,116
public function serialize ( ) { Xinc_Logger :: getInstance ( ) -> flush ( ) ; $ this -> setLastBuild ( ) ; if ( ! in_array ( $ this -> getStatus ( ) , array ( self :: PASSED , self :: FAILED , self :: STOPPED ) ) ) { throw new Xinc_Build_Exception_NotRun ( ) ; } elseif ( $ this -> getBuildTime ( ) == null ) { throw new Xinc_Build_Exception_Serialization ( $ this -> getProject ( ) , $ this -> getBuildTime ( ) ) ; } $ statusDir = Xinc :: getInstance ( ) -> getStatusDir ( ) ; $ buildHistoryFile = $ statusDir . DIRECTORY_SEPARATOR . $ this -> getProject ( ) -> getName ( ) . '.history' ; $ subDirectory = self :: generateStatusSubDir ( $ this -> getProject ( ) -> getName ( ) , $ this -> getBuildTime ( ) ) ; $ fileName = $ statusDir . DIRECTORY_SEPARATOR . $ subDirectory . DIRECTORY_SEPARATOR . 'build.ser' ; $ logfileName = $ statusDir . DIRECTORY_SEPARATOR . $ subDirectory . DIRECTORY_SEPARATOR . 'buildlog.xml' ; $ lastBuildFileName = $ statusDir . DIRECTORY_SEPARATOR . $ this -> getProject ( ) -> getName ( ) . DIRECTORY_SEPARATOR . 'build.ser' ; $ lastLogFileName = $ statusDir . DIRECTORY_SEPARATOR . $ this -> getProject ( ) -> getName ( ) . DIRECTORY_SEPARATOR . 'buildlog.xml' ; if ( ! file_exists ( dirname ( $ fileName ) ) ) { mkdir ( dirname ( $ fileName ) , 0755 , true ) ; } $ contents = serialize ( $ this ) ; $ written = file_put_contents ( $ lastBuildFileName , $ contents ) ; if ( $ written == strlen ( $ contents ) ) { $ res = copy ( $ lastBuildFileName , $ fileName ) ; if ( ! $ res ) { throw new Xinc_Build_Exception_Serialization ( $ this -> getProject ( ) , $ this -> getBuildTime ( ) ) ; } else { if ( file_exists ( $ lastLogFileName ) ) { copy ( $ lastLogFileName , $ logfileName ) ; unlink ( $ lastLogFileName ) ; } Xinc_Build_History :: addBuild ( $ this , $ fileName ) ; } return true ; } else { throw new Xinc_Build_Exception_Serialization ( $ this -> getProject ( ) , $ this -> getBuildTime ( ) ) ; } }
stores the build information .
19,117
public static function unserialize ( Project $ project , $ buildTimestamp = null , $ statusDir = null ) { if ( $ statusDir == null ) { $ statusDir = Xinc :: getInstance ( ) -> getStatusDir ( ) ; } if ( $ buildTimestamp == null ) { $ fileName = Xinc_Build_History :: getLastBuildFile ( $ project ) ; } else { $ fileName = Xinc_Build_History :: getBuildFile ( $ project , $ buildTimestamp ) ; } if ( ! file_exists ( $ fileName ) ) { throw new Xinc_Build_Exception_NotFound ( $ project , $ buildTimestamp ) ; } else { $ serializedString = file_get_contents ( $ fileName ) ; $ unserialized = @ unserialize ( $ serializedString ) ; if ( ! $ unserialized instanceof Xinc_Build ) { throw new Xinc_Build_Exception_Unserialization ( $ project , $ buildTimestamp ) ; } else { if ( $ unserialized -> getStatistics ( ) === null ) { $ unserialized -> _statistics = new Xinc_Build_Statistics ( ) ; } if ( $ unserialized -> getConfigDirective ( 'timezone.reporting' ) == true ) { $ unserialized -> setConfigDirective ( 'timezone' , null ) ; } if ( ! isset ( $ unserialized -> _internalProperties ) ) { if ( method_exists ( $ unserialized , 'init' ) ) { $ unserialized -> init ( ) ; } } return $ unserialized ; } } }
Unserialize a build by its project and buildtimestamp .
19,118
public function setNumber ( $ no ) { $ this -> info ( 'Setting Buildnumber to:' . $ no ) ; $ this -> setProperty ( 'build.number' , $ no ) ; $ this -> no = $ no ; }
Sets the sequence number for this build .
19,119
public function process ( $ slot ) { $ tasks = $ this -> getTasksForSlot ( $ slot ) ; while ( $ tasks -> valid ( ) ) { $ task = $ tasks -> current ( ) ; $ this -> log -> info ( 'Processing task: ' . $ task -> getName ( ) ) ; try { $ task -> process ( $ this ) ; } catch ( Exception $ e ) { var_dump ( $ e ) ; } $ tasks -> next ( ) ; } $ tasks -> rewind ( ) ; }
processes the tasks that are registered for the slot .
19,120
public function getStatusMessage ( $ status = null ) { if ( ! $ status ) $ status = $ this -> getStatus ( ) ; if ( ! $ status || ! isset ( $ this -> status_messages [ $ status ] ) ) throw new \ LogicException ( "No such status. -> {$status}" ) ; return $ this -> status_messages [ $ status ] ; }
get status message .
19,121
private function sendStatus ( ) { if ( headers_sent ( ) ) return ; if ( isset ( $ this -> status_messages [ $ this -> status ] ) ) { header ( sprintf ( 'HTTP/%s %d %s' , $ this -> request -> getHttpVersion ( ) , $ this -> status , $ this -> status_messages [ $ this -> status ] ) ) ; } else { header ( 'Status: ' . $ this -> status ) ; } }
send status code .
19,122
private function sendHeaders ( ) { foreach ( $ this -> body -> getHeaders ( ) as $ key => $ value ) { $ key = join ( '-' , array_map ( 'ucfirst' , explode ( '-' , $ key ) ) ) ; header ( sprintf ( '%s: %s' , $ key , $ value ) ) ; } }
send headers .
19,123
protected function getFields ( ) : array { if ( ! $ this -> fields ) { preg_match_all ( "~(?<!\\\\)(?:\\\\{2})*\(\?(?|P?<([_A-Za-z]\w{0,31})>|'([_A-Za-z]\w{0,31})')~" , $ this -> getPattern ( ) , $ matches ) ; $ this -> fields = $ matches [ 1 ] ; if ( ! $ this -> fields ) { throw new \ RuntimeException ( 'Pattern must contain named subpatterns.' ) ; } if ( count ( array_unique ( $ this -> fields ) ) != count ( $ this -> fields ) ) { throw new \ RuntimeException ( 'Subpattern names must be unique.' ) ; } } return $ this -> fields ; }
Gets names of fields to insert into .
19,124
protected function validate ( $ config , $ name , $ path ) { if ( ! is_array ( $ config ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The definition of "%s" in "%s" must be a YAML array.' , $ name , $ path ) ) ; } if ( $ extraKeys = array_diff ( array_keys ( $ config ) , self :: $ availableKeys ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".' , $ path , $ name , implode ( '", "' , $ extraKeys ) , implode ( '", "' , self :: $ availableKeys ) ) ) ; } }
Validates the metadata configuration .
19,125
public function doLogin ( Request $ request ) { $ userdata = array ( 'email' => $ request -> email , 'password' => $ request -> password ) ; if ( \ Auth :: attempt ( $ userdata , true , true ) ) { if ( config ( 'entrance.activated' ) ) { if ( \ Auth :: user ( ) -> status != 1 ) { \ Auth :: logout ( ) ; $ request -> session ( ) -> flash ( 'message' , 'Dit account is staat niet op active' ) ; return redirect ( ) -> route ( 'login.index' ) ; } } $ request -> session ( ) -> flash ( 'message' , 'Ingelogd' ) ; return redirect ( ) -> intended ( ) ; } else { $ request -> session ( ) -> flash ( 'message' , 'E-mail of wachtwoord onjuist!' ) ; return redirect ( ) -> route ( 'login.index' ) -> withInput ( ) ; } }
Logs user in after checking inserted data .
19,126
public function doLogout ( Request $ request ) { \ Auth :: logout ( ) ; $ request -> session ( ) -> flash ( 'message' , 'Succesvol uitgelogd' ) ; return redirect ( ) -> route ( 'login.index' ) ; }
Logs user out .
19,127
public function sendReset ( Request $ request ) { $ user = User :: where ( 'email' , '=' , $ request -> email ) -> first ( ) ; if ( $ user !== null ) { $ existingReset = Password_reset :: where ( 'email' , $ request -> email ) -> first ( ) ; if ( $ existingReset !== null ) { $ existingReset -> created_at = Carbon :: now ( ) -> toDateTimeString ( ) ; $ existingReset -> save ( ) ; \ Mail :: send ( config ( 'entrance.mail.password_reset' ) , [ 'reset' => $ existingReset -> token ] , function ( $ m ) use ( $ user ) { $ m -> to ( $ user -> email , $ user -> name ) -> subject ( 'Your Password Reset!' ) ; } ) ; $ request -> session ( ) -> flash ( 'message' , 'Er is een e-mail met een link verzonden.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } else { $ passwordReset = new Password_reset ( ) ; $ passwordReset -> email = $ request -> email ; $ passwordReset -> token = $ request -> _token ; $ passwordReset -> created_at = Carbon :: now ( ) -> toDateTimeString ( ) ; $ passwordReset -> save ( ) ; \ Mail :: send ( config ( 'entrance.mail.password_reset' ) , [ 'reset' => $ request -> _token ] , function ( $ m ) use ( $ user ) { $ m -> to ( $ user -> email , $ user -> name ) -> subject ( 'Your Password Reset!' ) ; } ) ; $ request -> session ( ) -> flash ( 'message' , 'Er is een e-mail met een link verzonden.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } } else { $ request -> session ( ) -> flash ( 'message' , 'Er bestaat geen gebruiker met het ingevoerde e-mail adres.' ) ; return redirect ( ) -> route ( 'reset.password' ) ; } }
Sends a password reset e - mail to the user .
19,128
public function doReset ( Request $ request ) { $ existingReset = Password_reset :: where ( 'email' , $ request -> email ) -> where ( 'token' , $ request -> token ) -> first ( ) ; if ( $ existingReset !== null ) { if ( $ request -> password === $ request -> input ( 'repeat-password' ) ) { $ user = User :: where ( 'email' , $ request -> email ) -> first ( ) ; $ user -> password = bcrypt ( $ request -> password ) ; $ user -> save ( ) ; $ existingReset -> delete ( ) ; return redirect ( ) -> route ( 'success' ) ; } else { $ request -> session ( ) -> flash ( 'message' , 'De ingevoerde wachtwoorden komen niet overeen.' ) ; return back ( ) -> withInput ( ) ; } } else { $ request -> session ( ) -> flash ( 'message' , 'Het ingevoerde e-mail adres is onjuist.' ) ; return back ( ) -> withInput ( $ request -> except ( 'email' ) ) ; } }
Resets the users password .
19,129
public function doRegister ( RegisterRequest $ request ) { $ request [ 'password' ] = bcrypt ( $ request -> password ) ; $ userModel = config ( 'entrance.classes.user_model' ) ; $ user = $ userModel :: create ( $ request -> all ( ) ) ; if ( config ( 'intothesource' ) ) { $ roleModel = config ( 'intothesource.usermanager.default_role_model' ) ; $ role = $ roleModel :: where ( 'name' , config ( 'intothesource.usermanager.default_role' ) ) -> firstOrFail ( ) -> id ; $ user -> roles ( ) -> attach ( [ $ role ] ) ; } $ request -> session ( ) -> flash ( 'message' , 'Succesvol geregistreerd' ) ; return Redirect ( ) -> route ( 'register' ) ; }
Register the given input
19,130
protected function aggregate ( ) : array { $ ret = [ ] ; if ( $ this -> flags & Benchmark :: BENCHMARK_TIME === Benchmark :: BENCHMARK_TIME ) { $ ret [ 'time' ] = TimeBenchmark :: score ( $ this -> h_time ) ; } if ( $ this -> flags & Benchmark :: BENCHMARK_MEMORY === Benchmark :: BENCHMARK_MEMORY ) { $ ret [ 'memory' ] = MemoryBenchmark :: score ( $ this -> h_memory ) ; } return $ ret ; }
Aggregate benchmark result
19,131
public function edit ( $ name , $ slug , $ locale , $ alias , $ icon ) : void { $ this -> name = $ name ; $ this -> slug = $ slug ; $ this -> locale = $ locale ; $ this -> alias = $ alias ; $ this -> icon = $ icon ; $ this -> updated_by = Yii :: $ app -> user -> identity -> id ; }
Edit a language .
19,132
public function checkRateLimits ( array $ response , array $ original_arguments ) { if ( is_array ( $ response ) && isset ( $ response [ 'errors' ] , $ response [ 'tts' ] ) ) { if ( $ this -> sleep_on_rate_limit ) { if ( $ response [ 'tts' ] == 0 ) { $ this -> api -> debug ( 'An error occured: ' . print_r ( $ response [ 'errors' ] , true ) ) ; $ this -> max_id = $ this -> since_id = 0 ; return [ ] ; } else { $ this -> api -> debug ( "Sleeping for {$response['tts']}s. ..." ) ; sleep ( $ response [ 'tts' ] + 1 ) ; return $ this -> api -> get ( $ this -> endpoint , $ original_arguments ) ; } } else { $ this -> max_id = $ this -> since_id = 0 ; return [ ] ; } } return $ response ; }
Check whether the response from Twitter s API is rate limiting the calls or not .
19,133
public function getInitOptionsResolver ( ) { if ( null === $ this -> initOptionsResolver ) { if ( null !== $ this -> parent ) { $ this -> initOptionsResolver = clone $ this -> parent -> getInitOptionsResolver ( ) ; } else { $ this -> initOptionsResolver = new OptionsResolver ( ) ; } $ this -> innerType -> setInitOptions ( $ this -> initOptionsResolver ) ; foreach ( $ this -> typeExtensions as $ extension ) { $ extension -> setInitOptions ( $ this -> initOptionsResolver ) ; } } return $ this -> initOptionsResolver ; }
Init options with innerType requirements
19,134
public function getExecOptionsResolver ( ) { if ( null === $ this -> execOptionsResolver ) { if ( null !== $ this -> parent ) { $ this -> execOptionsResolver = clone $ this -> parent -> getExecOptionsResolver ( ) ; } else { $ this -> execOptionsResolver = new OptionsResolver ( ) ; } $ this -> innerType -> setExecOptions ( $ this -> execOptionsResolver ) ; foreach ( $ this -> typeExtensions as $ extension ) { $ extension -> setExecOptions ( $ this -> execOptionsResolver ) ; } } return $ this -> execOptionsResolver ; }
Exec options with innerType requirements
19,135
protected function newBuilder ( $ name , JobFactory $ factory , array $ initOptions , array $ execOptions ) { return new JobBuilder ( $ name , $ factory , new EventDispatcher ( ) , $ initOptions , $ execOptions ) ; }
Create new JobBuilder for the innerType
19,136
public function createCollection ( $ name , $ capped = false , $ size = 0 , $ max = 0 ) { $ this -> native -> createCollection ( $ name , $ capped , $ size , $ max ) ; return $ this -> selectCollection ( $ name ) ; }
Create a new Collection
19,137
protected function decideOnFailure ( $ error ) { if ( ! isset ( $ this -> errors [ $ error ] ) ) { throw new UnexpectedValueException ( sprintf ( 'Unexpected error "%s" received. All error must be specified ' . 'in errors array of this instance.' , $ error ) ) ; } $ this -> state = static :: STATE_FAILURE | static :: STATE_BREAK ; $ this -> operationError = $ error ; $ this -> operationErrorDescription = $ this -> errors [ $ error ] ; }
Decides on failure .
19,138
protected function decideOnSuccess ( ) { $ this -> state = static :: STATE_SUCCESS ; $ this -> operationError = null ; $ this -> operationErrorDescription = null ; }
Decides on success .
19,139
public static function Gd2gc ( iauRefEllips $ n , $ elong , $ phi , $ height , array & $ xyz ) { $ j ; $ a ; $ f ; $ j = IAU :: Eform ( $ n , $ a , $ f ) ; if ( $ j == 0 ) { $ j = IAU :: Gd2gce ( $ a , $ f , $ elong , $ phi , $ height , $ xyz ) ; if ( $ j != 0 ) $ j = - 2 ; } if ( $ j != 0 ) IAU :: Zp ( $ xyz ) ; return $ j ; }
- - - - - - - - - i a u G d 2 g c - - - - - - - - -
19,140
public function load ( $ resource , $ type = null ) { $ collection = $ this -> loader -> load ( $ resource , $ type ) ; foreach ( $ collection -> all ( ) as $ route ) { if ( 'https' === $ route -> getRequirement ( '_scheme' ) ) { $ requirements = $ route -> getRequirements ( ) ; unset ( $ requirements [ '_scheme' ] ) ; $ route -> setRequirements ( $ requirements ) ; } } return $ collection ; }
Loads a RouteCollection but removes HTTPS scheme requirements from its routes before returning the collection .
19,141
protected function getEvent ( ) { if ( $ this -> event ) { return $ this -> event ; } $ controller = $ this -> getController ( ) ; if ( ! $ controller instanceof InjectApplicationEventInterface ) { throw new Exception \ DomainException ( 'getParam plugin requires a controller that implements InjectApplicationEventInterface' ) ; } $ event = $ controller -> getEvent ( ) ; if ( ! $ event instanceof MvcEvent ) { $ params = $ event -> getParams ( ) ; $ event = new MvcEvent ( ) ; $ event -> setParams ( $ params ) ; } $ this -> event = $ event ; return $ this -> event ; }
Get the event
19,142
public function setType ( $ type ) { $ this -> type = in_array ( $ type = strtolower ( $ type ) , [ 'button' , 'submit' , 'reset' ] ) ? $ type : 'button' ; return $ this ; }
Set the button type .
19,143
public static function make ( $ action , $ type = 'button' , array $ attributes = [ ] , $ disabled = false ) { return new static ( $ action , $ type , $ attributes , $ disabled ) ; }
Make a button instance .
19,144
protected function renderAttributes ( ) { $ attributes = collect ( ) ; $ attributes -> put ( 'type' , $ this -> type ) ; $ attributes -> put ( 'class' , $ this -> getStyleClass ( ) ) ; if ( $ this -> withTooltip ) { $ attributes -> put ( 'data-toggle' , 'tooltip' ) ; $ attributes -> put ( 'data-original-title' , $ this -> getTitle ( ) ) ; } if ( $ this -> disabled ) { $ attributes -> put ( 'type' , 'button' ) ; $ attributes -> put ( 'disabled' , 'disabled' ) ; } return html ( ) -> attributes ( $ attributes -> merge ( $ this -> attributes ) -> toArray ( ) ) ; }
Render the attributes .
19,145
public function query ( $ sql , $ ERROR_LOG_OUTPUT = true ) { if ( $ ERROR_LOG_OUTPUT ) { $ this -> BackyardError -> log ( 5 , "Start of query {$sql}" , array ( 11 ) ) ; } if ( empty ( $ sql ) || ! is_string ( $ sql ) ) { if ( $ ERROR_LOG_OUTPUT ) { $ this -> BackyardError -> log ( 1 , "No mysql_query_string set. End of query" , array ( 11 ) ) ; } return false ; } $ result = parent :: query ( $ sql ) ; if ( $ this -> errno != 0 ) { if ( $ ERROR_LOG_OUTPUT ) { $ this -> BackyardError -> log ( 1 , "{$this->errno} : {$this->error} /with query: {$sql}" , array ( 11 ) ) ; } } if ( $ ERROR_LOG_OUTPUT ) { $ this -> BackyardError -> log ( 6 , "End of query {$sql}" , array ( 11 ) ) ; } return $ result ; }
Query method if everything is OK return the mysqli_result object that is returned from parent query method
19,146
public static function addHook ( $ point , $ handler ) { if ( ! $ handler instanceof \ Closure and ! in_array ( Hook :: class , class_implements ( $ handler ) , false ) ) { throw new \ InvalidArgumentException ( "Failed adding hook. Provided handler for [{$point}] is not valid. Either provider a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Hook" ) ; } static :: ensureHookPoint ( $ point ) ; static :: $ hooks [ $ point ] [ ] = $ handler ; }
Register a hook instance .
19,147
public static function runHook ( $ name , array $ params = [ ] ) { static :: ensureHookPoint ( $ name ) ; foreach ( static :: $ hooks [ $ name ] as $ handler ) { if ( $ handler instanceof \ Closure ) { call_user_func_array ( $ handler , $ params ) ; } elseif ( class_exists ( $ handler ) ) { $ instance = app ( ) -> make ( $ handler ) ; call_user_func_array ( [ $ instance , 'handle' ] , $ params ) ; } } }
Run the given hook .
19,148
public static function filter ( $ name , $ handler ) { if ( ! $ handler instanceof \ Closure and ! in_array ( Filter :: class , class_implements ( $ handler ) , false ) ) { throw new \ InvalidArgumentException ( "Failed adding Filter. Provided handler for [{$name}] is not valid. Must either provide a \\Closure or classpath that impelments \\Docit\\Docit\\Contracts\\Filter" ) ; } static :: $ filters [ $ name ] = $ handler ; }
Add a new filter to the registered filters list .
19,149
public static function getFilters ( $ filterNames = null ) { if ( ! is_null ( $ filterNames ) ) { if ( ! is_array ( $ filterNames ) ) { $ filterNames = [ $ filterNames ] ; } return array_only ( static :: $ filters , $ filterNames ) ; } else { return static :: $ filters ; } }
get filters value
19,150
public function transform ( array $ element ) { $ isArgument = $ this -> isArgument ( $ element [ 0 ] ) ; $ class = 'Symfony\Component\Console\Input\Input' . ( $ isArgument ? 'Argument' : 'Option' ) ; $ reflector = new \ ReflectionClass ( $ class ) ; if ( $ isArgument ) { $ element [ 1 ] = $ this -> transformMode ( $ element [ 1 ] ) ; } else { $ element [ 2 ] = $ this -> transformMode ( $ element [ 2 ] ) ; } $ element [ 0 ] = $ this -> cleanName ( $ element [ 0 ] ) ; return $ reflector -> newInstanceArgs ( $ element ) ; }
Transform the element to an instance of InputArgument or InputOption .
19,151
function getTotalSpace ( ) : float { $ directory = $ this -> isDirectory ( ) ? $ this -> fileName : $ this -> getParent ( ) ; return disk_total_space ( $ directory ) ; }
Returns the size of the partition named by this path .
19,152
function getFreeSpace ( ) { $ directory = $ this -> isDirectory ( ) ? $ this -> fileName : $ this -> getParent ( ) ; return disk_free_space ( $ directory ) ; }
Returns the number of unallocated bytes in the partition named by this path .
19,153
public static function factory ( $ config = array ( ) ) { $ default = array ( 'Accept' => 'application/json' , 'environment' => 'prod' , 'service-description-name' => Client :: NAME_SERVICE_AUTH , 'ssl' => false ) ; $ required = array ( 'base_url' , 'Accept' , 'environment' , 'client_id' , 'secret' , 'ssl' ) ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; if ( $ config [ 'environment' ] == 'dev' && $ config [ 'ssl' ] == false ) { $ config [ 'ssl.certificate_authority' ] = 'system' ; $ config [ 'curl.options' ] = array ( CURLOPT_SSL_VERIFYHOST => false , CURLOPT_SSL_VERIFYPEER => false ) ; } $ client = new ChateaOAuth2Client ( $ config -> get ( 'base_url' ) , $ config ) ; $ client -> addSubscriber ( new AcceptHeaderPluging ( $ config -> toArray ( ) ) ) ; return $ client ; }
Build new class ChateaOAuth2Client this provides user authentication for ApiChateaClient
19,154
public function withClientCredentials ( ) { $ command = $ this -> getCommand ( 'withClientCredentials' , array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getSecret ( ) ) ) ; try { return $ command -> execute ( ) ; } catch ( ServerErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getResponse ( ) -> getBody ( true ) , $ ex -> getResponse ( ) -> getStatusCode ( ) , $ ex ) ; } catch ( BadResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( ClientErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getResponse ( ) -> getBody ( true ) , $ ex -> getResponse ( ) -> getStatusCode ( ) , $ ex ) ; } catch ( CurlException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } }
Enables the apps to get service credentials as well as service credential authentication settings for use on the apps side of communication .
19,155
public function withRefreshToken ( $ refresh_token ) { if ( ! is_string ( $ refresh_token ) || 0 >= strlen ( $ refresh_token ) ) { throw new InvalidArgumentException ( "refresh_token must be a non-empty string" ) ; } $ command = $ this -> getCommand ( 'withRefreshToken' , array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getSecret ( ) , 'refresh_token' => $ refresh_token ) ) ; try { return $ command -> execute ( ) ; } catch ( ServerErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( BadResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( ClientErrorResponseException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } catch ( CurlException $ ex ) { throw new AuthenticationException ( $ ex -> getMessage ( ) , 400 , $ ex ) ; } }
After the client has been authorized for access they can use a refresh token to get a new access token .
19,156
public function applyPatch ( Patch $ patch , $ baseDirectory ) { $ error = null ; foreach ( $ patch -> getLevels ( ) as $ patchLevel ) { try { $ this -> applyPatchLevel ( $ patch , $ baseDirectory , $ patchLevel ) ; return ; } catch ( Exception \ PatchAlreadyApplied $ x ) { throw $ x ; } catch ( Exception \ PatchNotApplied $ x ) { if ( $ error === null ) { $ error = $ x ; } } } throw $ error ; }
Apply a patch to a base directory .
19,157
protected function run ( $ command , $ standardInput = null ) { $ stdOut = '' ; $ stdErr = '' ; $ stdOut = array ( ) ; $ rc = $ this -> processExecutor -> execute ( $ command , $ stdOut ) ; $ stdOut = ( string ) $ stdOut ; $ stdErr = ( string ) $ this -> processExecutor -> getErrorOutput ( ) ; return array ( $ rc , $ stdOut , $ stdErr ) ; }
Run a command and return the exit code .
19,158
protected function checkCommandExists ( $ commandName , $ argument = '--version' ) { $ command = $ commandName ; $ argument = ( string ) $ argument ; if ( $ argument !== '' ) { $ command .= ' ' . $ argument ; } list ( $ rc , , $ stdErr ) = $ this -> run ( $ command ) ; if ( $ rc !== 0 ) { throw new Exception \ CommandNotFound ( $ commandName , $ stdErr ? $ stdErr : null ) ; } }
Check if a command exists .
19,159
private function read ( ) { flock ( $ this -> file , LOCK_SH ) ; rewind ( $ this -> file ) ; $ content = fgets ( $ this -> file ) ; flock ( $ this -> file , LOCK_UN ) ; $ this -> records = unserialize ( $ content ) ; }
Read cache from disk .
19,160
private function write ( ) { $ cache = serialize ( $ this -> records ) ; flock ( $ this -> file , LOCK_EX ) ; rewind ( $ this -> file ) ; ftruncate ( $ this -> file , 0 ) ; $ bytes = fwrite ( $ this -> file , $ cache ) ; flock ( $ this -> file , LOCK_UN ) ; return $ bytes === strlen ( $ cache ) ; }
Write cache to disk .
19,161
public function listAction ( ) { $ params = $ this -> params ( ) ; $ page = ( int ) $ params -> fromRoute ( 'page' ) ; $ mode = $ params -> fromRoute ( 'mode' ) ; $ all = $ mode == 'all' ; $ tags = array_map ( 'rawurldecode' , explode ( '/' , $ params -> fromRoute ( 'tags' ) ) ) ; $ paginator = $ this -> getServiceLocator ( ) -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) -> getContentPaginatorByTags ( $ tags , $ all ) ; $ this -> paragraphLayout ( ) ; return array ( 'paginator' => $ paginator , 'page' => $ page , 'mode' => $ mode , 'tags' => $ tags , ) ; }
List contents by tags
19,162
public function create ( ) { if ( ! $ this -> isFile ( $ this -> getName ( ) ) ) { $ this -> createPath ( $ this -> path ) ; $ file = fopen ( $ this -> getName ( ) , "w" ) ; fclose ( $ file ) ; } }
cree le ficher
19,163
public function writeOver ( $ content ) { $ this -> createPath ( $ this -> path ) ; file_put_contents ( $ this -> getName ( ) , $ content ) ; }
Ecrit dans un fichier En ecrasant son contenu
19,164
public function write ( $ content ) { $ this -> createPath ( $ this -> path ) ; file_put_contents ( $ this -> getName ( ) , $ content , FILE_APPEND ) ; }
Ecrire dans le fichier
19,165
public function generateName ( ) { $ chars = [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ] ; $ cod = self :: DEFAULT_AGENT ; for ( $ i = 0 ; $ i < 5 ; $ i ++ ) { $ cod .= $ chars [ mt_rand ( 0 , count ( $ chars ) - 1 ) ] ; } $ cod .= '_' ; $ cod .= time ( ) ; return $ cod ; }
genere un nom de fichier
19,166
public function metatagOutput ( $ args , $ obj ) { $ rawTitle = ! empty ( $ GLOBALS [ 'TSFE' ] -> altPageTitle ) ? $ GLOBALS [ 'TSFE' ] -> altPageTitle : $ GLOBALS [ 'TSFE' ] -> page [ 'title' ] ; if ( $ args [ 'meta.title' ] && $ args [ 'meta.title' ] [ 'attributes' ] [ 'content' ] !== $ rawTitle ) { $ args [ 'meta.title' ] [ 'attributes' ] [ 'content' ] = $ rawTitle ; } return [ $ args , $ obj ] ; }
Metaseo Signal for page metadata see - > \ Metaseo \ Metaseo \ Page \ Part \ MetatagPart - > processMetaTags
19,167
protected function executeValidation ( InputInterface $ input , OutputInterface $ output ) { $ types = [ ] ; foreach ( $ this -> getResolver ( ) -> getTypes ( ) as $ type ) { $ types [ $ type -> getType ( ) ] = $ type -> getType ( ) ; } $ invalid = [ ] ; foreach ( $ input -> getArgument ( 'id' ) as $ id ) { if ( ! isset ( $ types [ $ id ] ) ) { $ invalid [ ] = $ id ; } } if ( $ invalid ) { $ text = sprintf ( 'The content types "%s" do not exists' , implode ( ', ' , $ invalid ) ) ; if ( $ input -> getOption ( 'no-interaction' ) ) { throw new InvalidArgumentException ( $ text ) ; } $ output -> writeln ( $ text ) ; if ( ! $ this -> getQuestion ( ) -> ask ( $ input , $ output , new ConfirmationQuestion ( 'Would you want to continue? [y/N] ' , false ) ) ) { return 1 ; } } return 0 ; }
validate the ids in de input
19,168
protected function executeDelete ( InputInterface $ input , OutputInterface $ output ) { $ this -> doIndexCleanup ( $ input -> getArgument ( 'id' ) ) ; $ this -> doIndexCommit ( ) ; return 0 ; }
queue a delete on the solr index
19,169
protected function executeIndex ( InputInterface $ input , OutputInterface $ output ) { $ builder = $ this -> getDocumentManager ( ) -> createQueryBuilder ( Content :: class ) ; $ builder -> select ( 'id' , 'contentType' , 'class' ) -> hydrate ( false ) ; if ( $ input -> getOption ( 'full' ) ) { $ result = $ builder -> getQuery ( ) -> execute ( ) ; $ this -> getQueue ( ) -> clear ( ) ; } else { $ builder -> field ( 'contentType' ) -> in ( $ input -> getArgument ( 'id' ) ) ; $ result = $ builder -> getQuery ( ) -> execute ( ) ; } if ( $ count = $ result -> count ( ) ) { $ progress = $ this -> getProgress ( ) ; $ progress -> setRedrawFrequency ( min ( max ( floor ( $ count / 250 ) , 1 ) , 100 ) ) ; $ progress -> setFormat ( ProgressHelper :: FORMAT_VERBOSE ) ; $ progress -> start ( $ output , $ count ) ; $ date = new DateTime ( ) ; $ this -> doIndex ( $ result , $ progress ) ; $ this -> doIndexCleanup ( $ input -> getArgument ( 'id' ) , $ date ) ; $ this -> doIndexCommit ( ) ; $ progress -> display ( ) ; $ progress -> finish ( ) ; } else { $ this -> doIndexCleanup ( $ input -> getArgument ( 'id' ) ) ; $ this -> doIndexCommit ( ) ; } $ this -> getDocumentManager ( ) -> clear ( ) ; return 0 ; }
queue the indexing of content in to solr
19,170
protected function doIndex ( Cursor $ cursor , ProgressHelper $ progress ) { $ queue = $ this -> getQueue ( ) ; $ count = 0 ; $ manager = $ this -> getDocumentManager ( ) ; foreach ( $ cursor as $ document ) { $ progress -> advance ( ) ; $ job = new Job ( 'ADD' ) ; $ contentType = isset ( $ document [ 'contentType' ] ) ? $ document [ 'contentType' ] : '' ; $ job -> setOption ( 'document.id' , $ contentType . '-' . $ document [ '_id' ] ) ; $ job -> setOption ( 'document.data' , json_encode ( [ 'id' => $ document [ '_id' ] ] ) ) ; $ job -> setOption ( 'document.class' , $ document [ 'class' ] ) ; $ job -> setOption ( 'document.format' , 'json' ) ; $ queue -> push ( $ job ) ; if ( ( $ count ++ % 1000 ) == 0 ) { $ manager -> clear ( ) ; } } }
Add all the documents in the cursor to the solr queue
19,171
protected function doIndexCleanup ( array $ types , DateTime $ date = null ) { $ query = [ ] ; if ( $ types ) { $ query [ ] = 'type_name:("' . implode ( '" OR "' , $ types ) . '")' ; } else { $ query [ ] = '*:*' ; } if ( $ date ) { $ date = clone $ date ; $ date -> setTimezone ( new DateTimeZone ( 'UTC' ) ) ; $ query [ ] = '-_time_:[' . $ date -> format ( 'Y-m-d\TG:i:s\Z' ) . ' TO *]' ; } $ job = new Job ( 'DELETE' ) ; $ job -> setOption ( 'query' , implode ( ' ' , $ query ) ) ; $ this -> getQueue ( ) -> push ( $ job , 1 ) ; }
delete all the types or everything if none is given
19,172
private function resolveRequest ( ActionInterface $ action , CallableInterface $ callable , array $ inputArguments , \ ReflectionParameter $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( $ class -> isInterface ( ) ) { throw new \ RuntimeException ( sprintf ( 'Could not create instance via interface for parameter "%s" in method "%s". ' . 'You must set the class for type hinting.' , $ parameter -> getName ( ) , Reflection :: getCalledMethod ( $ callable -> getReflection ( ) ) ) ) ; } if ( $ class -> isAbstract ( ) ) { throw new \ RuntimeException ( sprintf ( 'Could not create instance via abstract class for parameter "%s" in method "%s". ' . 'You must set the real class for type hinting.' , $ parameter -> getName ( ) , Reflection :: getCalledMethod ( $ callable -> getReflection ( ) ) ) ) ; } $ request = $ class -> newInstance ( ) ; $ this -> objectMapper -> map ( $ request , $ inputArguments , $ action -> getRequestMappingGroup ( ) ) ; if ( $ this -> validator && $ action -> isStrictValidation ( ) ) { $ this -> strictRequestValidate ( $ request ) ; } if ( $ this -> validator && $ action -> getValidationGroups ( ) ) { $ violationList = $ this -> validator -> validate ( $ request , null , $ action -> getValidationGroups ( ) ) ; if ( count ( $ violationList ) ) { throw ViolationListException :: create ( $ violationList ) ; } } if ( $ this -> propertyConverter ) { try { $ this -> propertyConverter -> convertProperties ( $ request , PropertyConverterManagerInterface :: GROUP_DEFAULT ) ; } catch ( InvalidArgumentException $ e ) { $ constraintViolation = new ConstraintViolation ( $ e -> getMessage ( ) , null , [ ] , null , $ e -> getName ( ) , $ e -> getInvalidValue ( ) ) ; $ constraintViolationList = new ConstraintViolationList ( [ $ constraintViolation ] ) ; throw ViolationListException :: create ( $ constraintViolationList ) ; } catch ( ConverterNotFoundException $ e ) { if ( $ this -> logger ) { $ this -> logger -> warning ( sprintf ( 'Could not convert properties with message: %s.' , rtrim ( $ e -> getMessage ( ) , '.' ) ) ) ; } } } return $ request ; }
Resolve request parameter
19,173
private function strictRequestValidate ( RequestInterface $ request ) { $ requestMetadata = $ this -> validator -> getMetadataFor ( $ request ) ; $ useStrictGroup = false ; if ( $ requestMetadata instanceof ClassMetadata ) { foreach ( $ requestMetadata -> getConstrainedProperties ( ) as $ propertyName ) { $ propertyMetadata = $ requestMetadata -> getPropertyMetadata ( $ propertyName ) ; if ( count ( $ propertyMetadata ) ) { $ propertyMetadata = array_shift ( $ propertyMetadata ) ; } else { continue ; } $ constraintsInStrictGroup = $ propertyMetadata -> findConstraints ( 'Strict' ) ; if ( count ( $ constraintsInStrictGroup ) ) { $ useStrictGroup = true ; break ; } } } if ( $ useStrictGroup ) { $ violationList = $ this -> validator -> validate ( $ request , null , [ 'Strict' ] ) ; if ( count ( $ violationList ) ) { throw ViolationListException :: create ( $ violationList ) ; } return ; } if ( $ this -> validator instanceof VarTagValidatorInterface ) { $ violationList = $ this -> validator -> validateObjectByVarTags ( $ request ) ; if ( count ( $ violationList ) ) { throw ViolationListException :: create ( $ violationList ) ; } } }
Strict request validation
19,174
private function isPropertyRequired ( \ ReflectionProperty $ property , array $ groups ) { if ( ! $ this -> validator ) { return true ; } $ metadata = $ this -> validator -> getMetadataFor ( $ property -> getDeclaringClass ( ) -> getName ( ) ) ; if ( ! $ metadata instanceof ClassMetadata ) { return true ; } $ propertyMetadata = $ metadata -> getPropertyMetadata ( $ property -> getName ( ) ) ; if ( $ propertyMetadata ) { $ propertyMetadata = array_pop ( $ propertyMetadata ) ; foreach ( $ groups as $ group ) { $ constraints = $ propertyMetadata -> findConstraints ( $ group ) ; foreach ( $ constraints as $ constraint ) { if ( $ constraint instanceof NotBlank ) { return true ; } } } } return false ; }
Is required property
19,175
public function canAccess ( array $ user ) { $ can = false ; foreach ( $ user [ "roles" ] as $ userRole ) { foreach ( $ userRole [ "permissions" ] as $ permission ) { if ( in_array ( $ permission , $ this -> permissions ) ) { $ can = true ; break ; } } } return $ can ; }
Test if the user has the required permissions to access .
19,176
public function setCode ( int $ code ) { $ allowed_codes = [ 0 , 1 , 2 ] ; if ( ! in_array ( $ code , $ allowed_codes ) ) { $ code = 1 ; } $ this -> code = $ code ; }
Sets banlog code
19,177
public function add ( ) : int { if ( empty ( $ this -> logdate ) || empty ( $ this -> logstamp ) ) { $ time = time ( ) ; if ( empty ( $ this -> logdate ) ) { $ this -> logdate = date ( 'Y-m-d H:i:s' , $ time ) ; } if ( empty ( $ this -> logstamp ) ) { $ this -> logstamp = $ time ; } } if ( empty ( $ this -> client ) ) { $ this -> client = $ _SERVER [ 'HTTP_USER_AGENT' ] ; } if ( empty ( $ this -> ip ) ) { $ this -> ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } if ( empty ( $ this -> url ) ) { $ this -> url = $ _SERVER [ 'REQUEST_URI' ] ; } $ this -> db -> qb ( [ 'table' => 'core_bans' , 'data' => [ 'text' => $ this -> text , 'logdate' => $ this -> logdate , 'logstamp' => $ this -> logstamp , 'client' => $ this -> client , 'ip' => $ this -> ip , 'url' => $ this -> url , 'id_user' => $ this -> id_user , 'code' => $ this -> code ] ] , true ) ; return $ this -> db -> lastInsertId ( ) ; }
Creates log entry in Db and return log id
19,178
public function disconnect ( ) { if ( ! is_resource ( $ this -> _connection ) ) { $ this -> connected = false ; } else { $ this -> connected = ! fclose ( $ this -> _connection ) ; if ( ! $ this -> connected ) { $ this -> _connection = null ; } } return ! $ this -> connected ; }
Closes the connection to the beanstalk server .
19,179
public function reconnect ( ) { $ this -> disconnect ( ) ; $ this -> connect ( ) ; $ stats = $ this -> stats ( ) ; return $ stats === false ? false : true ; }
reset the connection to the beanstalk server .
19,180
public function usePut ( $ tube , $ data , $ pri = 0 , $ delay = 0 , $ ttr = 30 ) { $ result = $ this -> useTube ( $ tube ) ; if ( $ result === false ) return false ; $ jobId = $ this -> put ( $ pri , $ delay , $ ttr , $ data ) ; return $ jobId ; }
useTube and put
19,181
public function generatePasswordAction ( Request $ request ) { $ context = $ this -> loadContext ( $ request ) ; $ resourceName = $ this -> config -> getResourceName ( ) ; $ resource = $ context -> getResource ( $ resourceName ) ; $ this -> isGranted ( 'EDIT' , $ resource ) ; if ( in_array ( 'ROLE_SUPER_ADMIN' , $ resource -> getGroup ( ) -> getRoles ( ) ) ) { throw new AccessDeniedHttpException ( ) ; } $ this -> get ( 'fos_user.user_manager' ) -> generatePassword ( $ resource ) ; $ password = $ resource -> getPlainPassword ( ) ; $ event = new UserEvent ( $ resource ) ; $ event -> addMessage ( new ResourceMessage ( sprintf ( 'Generated password : "%s".' , $ password ) , ResourceMessage :: TYPE_INFO ) ) -> addData ( 'password' , $ password ) ; $ this -> getOperator ( ) -> update ( $ event ) ; $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; return $ this -> redirect ( $ this -> generateResourcePath ( $ resource ) ) ; }
Generates a new password for the user .
19,182
public function clearPasswordRequestAction ( Request $ request ) { $ context = $ this -> loadContext ( $ request ) ; $ resourceName = $ this -> config -> getResourceName ( ) ; $ resource = $ context -> getResource ( $ resourceName ) ; $ this -> isGranted ( 'EDIT' , $ resource ) ; if ( $ resource -> isPasswordRequestNonExpired ( $ this -> container -> getParameter ( 'fos_user.resetting.token_ttl' ) ) ) { $ resource -> setConfirmationToken ( null ) -> setPasswordRequestedAt ( null ) ; $ event = $ this -> getOperator ( ) -> update ( $ resource ) ; $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; $ this -> addFlash ( 'ekyna_user.user.alert.password_request_cleared' , 'success' ) ; } else { $ this -> addFlash ( 'ekyna_user.user.alert.no_password_request' , 'warning' ) ; } return $ this -> redirect ( $ this -> generateResourcePath ( $ resource ) ) ; }
Clears the user password request .
19,183
public function get ( $ key , $ throwIfNotFound = false ) { if ( $ this -> has ( $ key ) ) { return $ this -> data [ $ key ] ; } else if ( $ throwIfNotFound ) { throw new \ RuntimeException ( 'Key ' . $ key . ' not found in DI Container registry' ) ; } else { return null ; } }
Fetches an object from the registry .
19,184
public static function to ( $ path ) { $ currentLanguage = \ Translation :: getLanguage ( ) ; if ( \ Translation :: getDefaultLanguage ( ) === $ currentLanguage ) { $ currentLanguage = '' ; } else { $ currentLanguage = '/' . $ currentLanguage ; } return $ currentLanguage . $ path ; }
Append with language
19,185
public static function open ( $ form_attr = array ( ) ) { try { if ( ! is_array ( $ form_attr ) ) { throw new HelperException ( sprintf ( 'Expecting array of form attributes.e.g.$form_attr = array(\'name\'=>\'form1\',\'action\'=>\'post\')' , $ form_attr ) ) ; } $ form_attr_str = '' ; foreach ( $ form_attr as $ key => $ val ) { $ form_attr_str .= $ key . '="' . $ val . '" ' ; } return "<form " . $ form_attr_str . ' >' ; } catch ( BaseException $ e ) { $ e -> show ( ) ; } catch ( Exception $ e ) { echo $ e -> getMessage ( ) ; } }
Ths method create form open tag with attributes in view .
19,186
public function display ( $ cachable = false , $ urlparams = array ( ) ) { $ document = JFactory :: getDocument ( ) ; $ vName = $ this -> input -> get ( 'view' , 'categories' ) ; $ vFormat = $ document -> getType ( ) ; $ lName = $ this -> input -> get ( 'layout' , 'default' , 'string' ) ; $ id = $ this -> input -> getInt ( 'id' ) ; if ( $ vName == 'category' && $ lName == 'edit' && ! $ this -> checkEditId ( 'com_categories.edit.category' , $ id ) ) { $ this -> setError ( JText :: sprintf ( 'JLIB_APPLICATION_ERROR_UNHELD_ID' , $ id ) ) ; $ this -> setMessage ( $ this -> getError ( ) , 'error' ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=com_categories&view=categories&extension=' . $ this -> extension , false ) ) ; return false ; } if ( $ view = $ this -> getView ( $ vName , $ vFormat ) ) { $ model = $ this -> getModel ( $ vName , 'CategoriesModel' , array ( 'name' => $ vName . '.' . substr ( $ this -> extension , 4 ) ) ) ; $ view -> setModel ( $ model , true ) ; $ view -> setLayout ( $ lName ) ; $ view -> document = $ document ; JLoader :: register ( 'CategoriesHelper' , JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php' ) ; CategoriesHelper :: addSubmenu ( $ model -> getState ( 'filter.extension' ) ) ; $ view -> display ( ) ; } return $ this ; }
Method to display a view .
19,187
public function buildOutput ( $ form ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ this -> debug -> groupUncollapse ( ) ; $ str = '' ; foreach ( $ form -> currentFields as $ field ) { $ str .= $ field -> build ( ) . "\n" ; } $ this -> debug -> groupEnd ( ) ; return $ str ; }
Default fields builder
19,188
private function buildHiddenFields ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ cfg = $ this -> form -> cfg ; $ printOpts = & $ cfg [ 'output' ] ; $ hiddenFields = '' ; if ( $ printOpts [ 'inputKey' ] ) { $ hiddenFields .= '<input type="hidden" name="_key_" value="' . \ htmlspecialchars ( $ this -> keyValue ) . '" />' ; } if ( \ strtolower ( $ cfg [ 'attribs' ] [ 'method' ] ) == 'get' ) { $ this -> debug -> warn ( 'get method' ) ; $ urlParts = \ parse_url ( \ html_entity_decode ( $ cfg [ 'attribs' ] [ 'action' ] ) ) ; if ( ! empty ( $ urlParts [ 'query' ] ) ) { \ parse_str ( $ urlParts [ 'query' ] , $ params ) ; $ fieldNames = array ( ) ; foreach ( $ this -> form -> currentFields as $ field ) { $ fieldNames [ ] = $ field -> attribs [ 'name' ] ; } foreach ( $ params as $ k => $ v ) { if ( \ in_array ( $ k , $ fieldNames ) ) { continue ; } $ hiddenFields .= '<input type="hidden" name="' . \ htmlspecialchars ( $ k ) . '" value="' . \ htmlspecialchars ( $ v ) . '" />' . "\n" ; } } } $ this -> debug -> log ( 'hiddenFields' , $ hiddenFields ) ; $ this -> debug -> groupEnd ( ) ; return $ hiddenFields ; }
Generate hidden fields not related to inputs
19,189
public static function pName ( ) { if ( is_null ( self :: $ pluginName ) ) { self :: $ pluginName = explode ( '/' , plugin_basename ( __FILE__ ) ) [ 0 ] ; } return self :: $ pluginName ; }
Get plugin name
19,190
public static function pBaseN ( ) { if ( is_null ( self :: $ pluginBaseName ) ) { self :: $ pluginBaseName = self :: pName ( ) . "/index.php" ; } return self :: $ pluginBaseName ; }
Get plugin base name
19,191
public static function pDir ( $ complement = "" ) { if ( is_null ( self :: $ pluginDirectory ) ) { self :: $ pluginDirectory = WP_PLUGIN_DIR . "/" . self :: pName ( ) ; } return self :: $ pluginDirectory . $ complement ; }
Get plugin directory
19,192
public static function pUrl ( $ complement = "" ) { if ( is_null ( self :: $ pluginUrl ) ) { self :: $ pluginUrl = WP_PLUGIN_URL . "/" . self :: pName ( ) ; } return self :: $ pluginUrl . $ complement ; }
Get plugin url
19,193
public function getArchived ( ) { if ( ! $ this -> isArchivable ( ) ) { return false ; } if ( empty ( $ this -> owner -> { $ this -> archiveField } ) ) { return false ; } return true ; }
Get archived .
19,194
public function add ( $ method , $ name , $ path , $ controller = null , array $ requirements = [ ] , array $ options = [ ] , $ host = '' , array $ schemas = [ ] , $ condition = '' ) { if ( ! in_array ( strtoupper ( $ method ) , $ this -> allowedMethod ) ) { throw new HttpMethodNotAllowedException ( ) ; } $ this -> routes -> add ( $ name , new Route ( $ this -> prefix . $ path , [ '_controller' => $ controller ] , $ requirements , $ options , $ host , $ schemas , [ strtoupper ( $ method ) ] , $ condition ) ) ; return $ this ; }
add a route rule
19,195
public function get ( $ name , $ path , $ controller = null ) { $ this -> add ( 'GET' , $ name , $ path , $ controller ) ; return $ this ; }
add a get rule in route
19,196
public function post ( $ name , $ path , $ controller = null ) { $ this -> add ( 'POST' , $ name , $ path , $ controller ) ; return $ this ; }
add a post rule in route
19,197
public function put ( $ name , $ path , $ controller = null ) { $ this -> add ( 'PUT' , $ name , $ path , $ controller ) ; return $ this ; }
add a put rule in route
19,198
public function delete ( $ name , $ path , $ controller = null ) { $ this -> add ( 'DELETE' , $ name , $ path , $ controller ) ; return $ this ; }
add a delete rule in route
19,199
public function patch ( $ name , $ path , $ controller = null ) { $ this -> add ( 'PATCH' , $ name , $ path , $ controller ) ; return $ this ; }
add a patch rule in route