idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
59,700
public function getReachableRoles ( $ roles ) { if ( ! is_array ( $ roles ) ) $ roles = [ $ roles ] ; $ reachableRoles = [ ] ; foreach ( $ roles as $ role ) { $ reachableRoles [ $ role ] = $ role ; if ( ! isset ( $ this -> map [ $ role ] ) ) continue ; foreach ( $ this -> map [ $ role ] as $ role ) { $ reachableRoles [ $ role ] = $ role ; } } return $ reachableRoles ; }
Return array indexed by role
59,701
public function add ( MediaType $ mediaType ) { $ this -> mediaTypes [ $ mediaType -> getName ( ) ] = $ mediaType ; foreach ( $ mediaType -> getMimetypes ( ) as $ mimetype ) { $ this -> mimetypeMap [ $ mimetype ] = $ mediaType -> getName ( ) ; } return $ this ; }
Add media type .
59,702
public function merge ( MediaTypeCollection $ collection ) { foreach ( $ collection -> all ( ) as $ mediaType ) { $ this -> add ( $ mediaType ) ; } return $ this ; }
Merge collection .
59,703
public function verify ( $ input , $ existingHash ) { $ hash = crypt ( $ input , $ existingHash ) ; return Utils :: compareStr ( $ existingHash , $ hash ) ; }
Verify the input against an existing Hash
59,704
public function hash ( $ input ) { $ hash = crypt ( $ input , $ this -> getSalt ( ) ) ; if ( Utils :: binaryStrlen ( $ hash ) != $ this -> getResultLength ( ) ) { throw new HashException ( "Error while generating Hash" ) ; } return $ hash ; }
Generate the Hash of an input
59,705
public static function prepareKeyStrokes ( $ charList ) { $ keyStrokes = [ ] ; foreach ( ( array ) $ charList as $ char ) { if ( is_int ( $ char ) ) { if ( false === $ symbol = iconv ( 'UTF-16LE' , 'UTF-8' , pack ( 'v' , $ char ) ) ) { throw new WebDriver_UtilException ( "Invalid Unicode symbol: U+" . strtoupper ( dechex ( $ char ) ) ) ; } $ keyStrokes [ ] = $ symbol ; } else { $ keyStrokes [ ] = ( string ) $ char ; } } if ( empty ( $ keyStrokes ) ) { throw new WebDriver_UtilException ( "No keystrokes to send" ) ; } return $ keyStrokes ; }
Translates char list into keystroke sequence .
59,706
public function setCelZlozenia ( \ KCH \ PCC3 \ TNaglowekType \ CelZlozeniaAnonymousType $ celZlozenia ) { $ this -> celZlozenia = $ celZlozenia ; return $ this ; }
Sets a new celZlozenia
59,707
public function setData ( \ KCH \ PCC3 \ TNaglowekType \ DataAnonymousType $ data ) { $ this -> data = $ data ; return $ this ; }
Sets a new data
59,708
public function setSite ( \ BlackForest \ PiwikBundle \ Entity \ PiwikSite $ site = null ) { $ this -> site = $ site ; return $ this ; }
Set site .
59,709
public function setVisitorType ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisitorType $ visitorType = null ) { $ this -> visitorType = $ visitorType ; return $ this ; }
Set visitorType .
59,710
public function setEcommmerceStatus ( \ BlackForest \ PiwikBundle \ Entity \ PiwikEcomerceStatus $ ecommmerceStatus = null ) { $ this -> ecommmerceStatus = $ ecommmerceStatus ; return $ this ; }
Set ecommmerceStatus .
59,711
public function setReferrerType ( \ BlackForest \ PiwikBundle \ Entity \ PiwikReferrerType $ referrerType = null ) { $ this -> referrerType = $ referrerType ; return $ this ; }
Set referrerType .
59,712
public function setSearchEngineDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikSearchEngine $ searchEngineDetail = null ) { $ this -> searchEngineDetail = $ searchEngineDetail ; return $ this ; }
Set searchEngineDetail .
59,713
public function setLanguageDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikLanguage $ languageDetail = null ) { $ this -> languageDetail = $ languageDetail ; return $ this ; }
Set languageDetail .
59,714
public function setDeviceDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikDevice $ deviceDetail = null ) { $ this -> deviceDetail = $ deviceDetail ; return $ this ; }
Set deviceDetail .
59,715
public function setOperatingSystemDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikOperatingSystem $ operatingSystemDetail = null ) { $ this -> operatingSystemDetail = $ operatingSystemDetail ; return $ this ; }
Set operatingSystemDetail .
59,716
public function setBrowserDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikBrowser $ browserDetail = null ) { $ this -> browserDetail = $ browserDetail ; return $ this ; }
Set browserDetail .
59,717
public function setCountryDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikCountry $ countryDetail = null ) { $ this -> countryDetail = $ countryDetail ; return $ this ; }
Set countryDetail .
59,718
public function setResolutionDetail ( \ BlackForest \ PiwikBundle \ Entity \ PiwikResolution $ resolutionDetail = null ) { $ this -> resolutionDetail = $ resolutionDetail ; return $ this ; }
Set resolutionDetail .
59,719
protected function createRequestInstance ( $ requestName , $ index , $ type ) { $ class = $ this -> getClass ( $ requestName ) ; return $ this -> requestRepositoryFactory -> create ( $ class , $ index , $ type , $ this -> serializer ) ; }
creates an request instance
59,720
protected function setValue ( $ value ) { if ( ! $ this -> validate ( $ value ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s is not a valid value' , $ value ) ) ; } $ this -> value = $ value ; }
Sets the value if it is valid
59,721
private function fromArrayToXmlString ( array $ array ) { $ string = '' ; foreach ( $ array as $ key => $ value ) { $ string .= '<' . $ key . '>' . ( ( is_array ( $ value ) ) ? $ this -> fromArrayToXmlString ( $ value ) : $ value ) . '</' . $ key . '>' ; } return $ string ; }
Builds xml string from provided array .
59,722
protected function registerMiddleware ( ) { resolve ( Kernel :: class ) -> prependMiddleware ( Init :: class ) ; resolve ( Kernel :: class ) -> prependMiddleware ( MultiLanguage :: class ) ; resolve ( Kernel :: class ) -> prependMiddleware ( Timezone :: class ) ; $ router = resolve ( Router :: class ) ; $ router -> pushMiddlewareToGroup ( 'web' , CreateFreshApiToken :: class ) ; $ router -> pushMiddlewareToGroup ( 'web' , ViewComposer :: class ) ; $ router -> pushMiddlewareToGroup ( 'web' , ViewShareUser :: class ) ; }
It register all middleware
59,723
protected function registerPublishes ( ) { $ this -> publishes ( [ __DIR__ . '/../../../config/config.php' => config_path ( 'gzero.php' ) , ] , 'gzero-core config' ) ; $ this -> publishes ( [ __DIR__ . '/../../../database/factories/UserFactory.php' => database_path ( 'factories/gzero.php' ) , ] , 'gzero-core factories' ) ; $ this -> publishes ( [ __DIR__ . '/../../../resources/views' => resource_path ( 'views/vendor/gzero-core' ) , ] , 'gzero-core views' ) ; }
It registers all assets to publish
59,724
public function getMetaData ( $ key ) { return isset ( $ this -> meta [ $ key ] ) ? $ this -> meta [ $ key ] : null ; }
Retrieve the meta data .
59,725
public function addMetaData ( $ key , $ value , $ overwrite = true ) { $ this -> meta [ $ key ] = isset ( $ this -> meta [ $ key ] ) ? $ overwrite ? $ value : $ this -> meta [ $ key ] : $ value ; return $ this ; }
Add meta data .
59,726
public function removeVersion ( $ version ) { $ versionParser = new VersionParser ( ) ; if ( $ version instanceof PackageInterface ) { $ normalizedVersion = $ version -> getVersion ( ) ; } elseif ( is_string ( $ version ) ) { $ normalizedVersion = $ versionParser -> normalize ( $ version ) ; } else { throw new \ InvalidArgumentException ( 'You have to pass either an instance of PackageInterface or a version string to remove a version ' . 'from this package object!' ) ; } foreach ( $ this -> getVersions ( ) as $ key => $ attachedVersion ) { if ( $ attachedVersion -> getVersion ( ) == $ normalizedVersion ) { unset ( $ this -> versions [ $ key ] ) ; } } return $ this ; }
Remove a version from the package .
59,727
public function licenseCheck ( $ license_key , \ JaegerApp \ License $ license ) { if ( $ license_key == '' ) { $ this -> setError ( 'license_number' , 'missing_license_number' ) ; } else { if ( ! $ license -> validLicense ( $ license_key ) ) { $ this -> setError ( 'license_number' , 'invalid_license_number' ) ; } } return $ this ; }
Verifies the license key is valid
59,728
public function image ( $ email , $ size = null , array $ attributes = array ( ) , $ secure = true ) { return '<img src="' . $ this -> url ( $ email , $ size , $ secure ) . '"' . $ this -> attributes ( $ attributes ) . '>' ; }
Get gravatar image from email .
59,729
public function url ( $ email , $ size = null , $ secure = true ) { if ( ! is_null ( $ size ) ) { $ this -> validateSize ( $ size ) ; } $ url = $ secure ? $ this -> httpsUrl : $ this -> httpUrl ; $ url .= hash ( 'md5' , strtolower ( trim ( $ email ) ) ) ; $ params = array ( ) ; $ params [ 's' ] = $ size ? : $ this -> size ; $ params [ 'r' ] = $ this -> rating ; $ params [ 'd' ] = $ this -> imageSet ; $ url .= '?' . http_build_query ( array_filter ( $ params ) ) ; return $ url ; }
Get gravatar url from email
59,730
public function setImageSet ( $ imageSet ) { if ( ! in_array ( $ imageSet , $ this -> availableImageSets ) ) { throw new \ InvalidArgumentException ( 'Invalid Gravatar image set.' ) ; } $ this -> imageSet = $ imageSet ; }
Set image set .
59,731
public function setRating ( $ rating ) { if ( ! in_array ( $ rating , $ this -> availableRatings ) ) { throw new \ InvalidArgumentException ( 'Invalid Gravatar rating.' ) ; } $ this -> rating = $ rating ; }
Set rating .
59,732
protected function validateSize ( $ size ) { if ( ! is_int ( $ size ) && ! ctype_digit ( $ size ) ) { throw new \ InvalidArgumentException ( 'Avatar size specified must be an integer' ) ; } if ( $ size < 0 || $ size > 2048 ) { throw new \ InvalidArgumentException ( 'Avatar size must be within 0 pixels and 2048 pixels' ) ; } }
Validate provided size .
59,733
public static function connect ( string $ host , int $ port = 119 , array $ options = [ ] ) : Generator { $ socket = yield from Dns \ connect ( $ host , $ port , $ options ) ; $ encoder = new Rfc3977Encoder ( ) ; $ client = new static ( $ socket , $ encoder ) ; $ response = yield from $ encoder -> readResponse ( $ socket ) ; if ( $ response -> code ( ) === 201 ) { $ client -> postingAllowed = false ; } yield from $ client -> getServerCapabilities ( ) ; if ( $ client -> hasCapability ( 'MODE-READER' ) || ! $ client -> hasCapability ( 'READER' ) ) { yield from $ client -> sendCommand ( new Command ( 'MODE READER' ) ) ; } if ( $ client -> hasCapability ( 'STARTTLS' ) ) { yield from $ client -> sendCommand ( new Command ( 'STARTTLS' ) ) ; yield from $ socket -> enableCrypto ( STREAM_CRYPTO_METHOD_ANY_CLIENT ) ; } return $ client ; }
Connects to an NNTP server .
59,734
public function authenticate ( string $ user , string $ password = null ) : Generator { $ response = yield from $ this -> sendCommand ( new Command ( 'AUTHINFO USER' , $ user ) ) ; if ( $ response -> code ( ) === 381 ) { if ( $ password === null ) { throw new \ Exception ( "Password required" ) ; } yield from $ this -> sendCommand ( new Command ( 'AUTHINFO PASS' , $ password ) ) ; } }
Authenticates as a user .
59,735
public function getDate ( ) : Generator { $ response = yield from $ this -> sendCommand ( new Command ( 'DATE' ) ) ; return DateTime :: createFromFormat ( 'YmdHis' , $ response -> message ( ) , new DateTimeZone ( 'UTC' ) ) ; }
Gets the current UTC date and time on the server .
59,736
public function getGroups ( ) : Generator { $ command = new Command ( 'LIST ACTIVE' ) ; $ response = yield from $ this -> sendCommand ( $ command ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; if ( preg_match_all ( '/([A-z\._-]+)\s+(\d+)\s+(\d+)\s+(\w)/' , $ data , $ matches , PREG_SET_ORDER ) === false ) { throw new FormatException ( 'Invalid groups format' ) ; } return array_map ( function ( $ matches ) { if ( $ matches [ 4 ] === 'y' ) { $ status = Group :: POSTING_PERMITTED ; } elseif ( $ matches [ 4 ] === 'n' ) { $ status = Group :: POSTING_NOT_PERMITTED ; } elseif ( $ matches [ 4 ] === 'm' ) { $ status = Group :: POSTING_FORWARDED ; } else { $ status = Group :: STATUS_UNKNOWN ; } $ high = ( int ) $ matches [ 2 ] ; $ low = ( int ) $ matches [ 3 ] ; return new Group ( $ matches [ 1 ] , $ high - $ low , $ low , $ high , $ status ) ; } , $ matches ) ; }
Gets a list of all groups in the server .
59,737
public function getGroupsSince ( DateTime $ time ) : Generator { $ command = new Command ( 'NEWGROUPS' , $ time -> format ( 'Ymd His' ) , 'GMT' ) ; yield from $ this -> sendCommand ( $ command ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return explode ( "\r\n" , $ data ) ; }
Gets an array of groups created after a given time .
59,738
public function setCurrentGroup ( string $ group ) : Generator { $ response = yield from $ this -> sendCommand ( new Command ( 'GROUP' , $ group ) ) ; if ( preg_match ( '/(\d+)\s+(\d+)\s+(\d+)\s+([A-z\._-]+)/' , $ response -> message ( ) , $ matches ) === false ) { throw new FormatException ( 'Invalid group format' ) ; } $ this -> group = new Group ( $ matches [ 4 ] , ( int ) $ matches [ 1 ] , ( int ) $ matches [ 2 ] , ( int ) $ matches [ 3 ] ) ; return $ this -> group ; }
Sets the currently selected newsgroup .
59,739
public function articleExists ( string $ id ) { yield from $ this -> encoder -> writeCommand ( $ this -> stream , new Command ( 'STAT' , $ id ) ) ; $ response = yield from $ this -> encoder -> readResponse ( $ this -> stream ) ; return $ response -> code ( ) === 223 ; }
Checks if an article exists .
59,740
public function getArticlesSince ( string $ group , DateTime $ time ) : Generator { $ command = new Command ( 'NEWNEWS' , $ group , $ time -> format ( 'Ymd His' ) , 'GMT' ) ; yield from $ this -> sendCommand ( $ command ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return explode ( "\r\n" , $ data ) ; }
Returns an array of article IDs that have been posted or received by the server after a given time .
59,741
public function getArticle ( ) : Generator { yield from $ this -> sendCommand ( new Command ( 'ARTICLE' ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return Article :: parse ( $ data ) ; }
Gets the currently selected article .
59,742
public function getArticleById ( string $ id ) : Generator { yield from $ this -> sendCommand ( new Command ( 'ARTICLE' , $ id ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return Article :: parse ( $ data ) ; }
Gets an article by ID .
59,743
public function getArticleByNumber ( int $ number ) : Generator { yield from $ this -> sendCommand ( new Command ( 'ARTICLE' , ( string ) $ number ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return Article :: parse ( $ data ) ; }
Gets an article by its number in the current newsgroup .
59,744
public function getArticleHeaders ( ) : Generator { yield from $ this -> sendCommand ( new Command ( 'HEAD' ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return HeaderBag :: parse ( $ data ) ; }
Gets the headers of the currently selected article .
59,745
public function getArticleHeadersById ( string $ id ) : Generator { yield from $ this -> sendCommand ( new Command ( 'HEAD' , $ id ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return HeaderBag :: parse ( $ data ) ; }
Gets the headers of an article by ID .
59,746
public function getArticleHeadersByNumber ( int $ number ) : Generator { yield from $ this -> sendCommand ( new Command ( 'HEAD' , ( string ) $ number ) ) ; $ data = yield from $ this -> encoder -> readData ( $ this -> stream ) ; return HeaderBag :: parse ( $ data ) ; }
Gets the headers of an article by its number in the current newsgroup .
59,747
public function getArticleBody ( ) : Generator { yield from $ this -> sendCommand ( new Command ( 'BODY' ) ) ; return yield from $ this -> encoder -> readData ( $ this -> stream ) ; }
Gets the body text of the currently selected article .
59,748
public function getArticleBodyById ( string $ id ) : Generator { yield from $ this -> sendCommand ( new Command ( 'BODY' , $ id ) ) ; return yield from $ this -> encoder -> readData ( $ this -> stream ) ; }
Gets the body text of an article by ID .
59,749
public function getArticleBodyByNumber ( int $ number ) : Generator { yield from $ this -> sendCommand ( new Command ( 'BODY' , ( string ) $ number ) ) ; return yield from $ this -> encoder -> readData ( $ this -> stream ) ; }
Gets the body text of an article by its number in the current newsgroup .
59,750
public function postArticle ( Article $ article ) : Generator { if ( ! $ this -> postingAllowed ) { throw new \ Exception ( "Posting not allowed" ) ; } yield from $ this -> sendCommand ( new Command ( 'POST' ) ) ; yield from $ this -> encoder -> sendData ( $ this -> stream , ( string ) $ article ) ; $ response = $ this -> encoder -> readResponse ( $ this -> stream ) ; if ( ! $ response -> isOk ( ) ) { throw new RemoteException ( $ response -> message ( ) , $ response -> code ( ) ) ; } }
Posts an article to the news server .
59,751
public function sendCommand ( Command $ command ) : Generator { yield from $ this -> encoder -> writeCommand ( $ this -> stream , $ command ) ; $ response = yield from $ this -> encoder -> readResponse ( $ this -> stream ) ; if ( ! $ response -> isOk ( ) ) { throw new RemoteException ( $ response -> message ( ) , $ response -> code ( ) ) ; } return $ response ; }
Sends an arbitrary command to the server and returns the response .
59,752
public function checkAuthAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; if ( null !== $ user ) { if ( ! $ user instanceof UserInformationInterface ) { throw new \ RuntimeException ( 'Invalid user object' ) ; } $ lifetime = $ this -> determineLifeTime ( $ request ) ; $ token = $ this -> get ( 'tenside.jwt_authenticator' ) -> getTokenForData ( $ user , $ lifetime ) ; return new JsonResponse ( [ 'status' => 'OK' , 'token' => $ token , 'acl' => $ user -> getRoles ( ) , 'username' => $ user -> getUsername ( ) , 'ttl' => ( null === $ lifetime ) ? 'unlimited' : date ( 'r' , ( time ( ) + $ lifetime ) ) ] , JsonResponse :: HTTP_OK , [ 'Authentication' => $ token ] ) ; } return new JsonResponse ( [ 'status' => 'unauthorized' ] , JsonResponse :: HTTP_UNAUTHORIZED ) ; }
Try to validate the user from the request and return a jwt authentication result then .
59,753
private function determineLifeTime ( Request $ request ) { if ( $ lifetime = $ request -> query -> getInt ( 'ttl' ) ) { return $ this -> revertToNullOnMinusOne ( $ lifetime ) ; } try { $ inputData = new JsonArray ( $ request -> getContent ( ) ) ; if ( $ inputData -> has ( 'ttl' ) ) { return $ this -> revertToNullOnMinusOne ( intval ( $ inputData -> get ( 'ttl' ) ) ) ; } } catch ( \ Exception $ e ) { } return 3600 ; }
Determine the life time for the token .
59,754
public function getData ( ) { $ users = $ this -> userManager -> findLoggedInUsers ( ) ; $ data = [ ] ; foreach ( $ users as $ user ) { $ data [ ] = [ 'uid' => $ user -> getId ( ) , 'username' => $ user -> getUsername ( ) , 'image' => '/bundles/users/images/male-black-blonde.png' , ] ; } return $ data ; }
Return portlet data .
59,755
public function getUserByField ( $ field , $ data ) { $ user = new User ( ) ; $ userVarArray = get_object_vars ( $ user ) ; $ arrayKeys = array_keys ( $ userVarArray ) ; $ userData = $ this -> userStorage -> getUserByField ( $ field , $ data ) ; if ( empty ( $ userData ) ) { return $ user ; } foreach ( $ arrayKeys as $ key ) { $ user -> { $ key } = $ userData -> $ key ; } return $ user ; }
Dynamicly get user by propertie .
59,756
public function login ( $ username , $ password ) { $ user = $ this -> getUserByField ( "username" , $ username ) ; if ( $ password === null ) { throw new Exception ( "Empty password field." ) ; } if ( $ user -> id === null ) { throw new Exception ( "Error, not valid credentials." ) ; } if ( $ user -> deleted !== null ) { throw new Exception ( "User deleted." ) ; } if ( ( int ) $ user -> enabled === 0 ) { throw new Exception ( "Error, disabled account." ) ; } if ( $ this -> validatePassword ( $ password , $ user -> password ) ) { $ this -> session -> set ( "user" , $ user ) ; return true ; } throw new Exception ( "Error, not valid credentials." ) ; }
Login user and redirect to admin .
59,757
public function validLoggedInAdmin ( ) { $ loggedInUser = $ this -> getCurrentLoggedInUser ( ) ; if ( $ loggedInUser && $ loggedInUser -> administrator && $ loggedInUser -> deleted === null && $ loggedInUser -> enabled ) { return true ; } return false ; }
Check if logged in user is valid and admin .
59,758
public function do ( String $ key = NULL , $ convert = NULL ) { if ( $ this -> select === NULL ) { if ( is_file ( $ this -> lang ) ) { $ read = file_get_contents ( $ this -> lang ) ; } if ( is_file ( $ this -> externalLang ) ) { $ eread = file_get_contents ( $ this -> externalLang ) ; } $ read = json_decode ( $ read ?? '' , true ) ; $ eread = json_decode ( $ eread ?? '' , true ) ; $ this -> select = array_merge ( ( array ) $ eread , ( array ) $ read ) ; } if ( $ key === NULL ) { return $ this -> select ; } if ( isset ( $ this -> select [ $ key ] ) ) { if ( is_array ( $ convert ) ) { $ return = str_replace ( array_keys ( $ convert ) , array_values ( $ convert ) , $ this -> select [ $ key ] ) ; } else { $ return = str_replace ( '%' , $ convert , $ this -> select [ $ key ] ) ; } } else { $ return = $ key ; } return $ return ; }
Select word .
59,759
public function all ( $ app = NULL ) : Array { if ( ! is_string ( $ app ) ) { if ( $ app === NULL ) { $ MLFiles = $ this -> getMLFiles ( ) ; } elseif ( is_array ( $ app ) ) { $ MLFiles = $ app ; } else { return false ; } $ allMLFiles = [ ] ; if ( ! empty ( $ MLFiles ) ) foreach ( $ MLFiles as $ file ) { $ removeExtension = $ this -> removeExtension ( $ file ) ; $ allMLFiles [ $ removeExtension ] = $ this -> all ( $ removeExtension ) ; } return $ allMLFiles ; } else { if ( is_file ( $ createFile = $ this -> _langFile ( $ app ) ) ) { $ read = file_get_contents ( $ createFile ) ; return json_decode ( $ read , true ) ; } return [ ] ; } }
Select all languages
59,760
public function addToResponse ( \ Psr \ Http \ Message \ ResponseInterface $ p_response ) { foreach ( $ this -> cookies as $ idx => $ cookie ) { $ p_response = $ p_response -> withAddedHeader ( 'Set-Cookie' , ( string ) $ cookie ) ; } return $ p_response ; }
Add cookies to response
59,761
public static function attempt ( $ fields , $ remember = false ) { $ hashed = static :: hash ( $ fields ) ; $ data = static :: query ( $ hashed ) ; if ( count ( $ data ) > 0 ) { static :: $ user = static :: orm ( $ data [ 0 ] ) ; static :: save_session ( ) ; if ( $ remember ) { static :: save_cookie ( ) ; } return true ; } return false ; }
Try to authenticate .
59,762
protected static function hash ( $ fields ) { foreach ( $ fields as $ key => $ value ) { if ( in_array ( $ key , self :: $ fields ) ) { $ fields [ $ key ] = Hash :: make ( $ value ) ; } } return $ fields ; }
Hash the authentication data .
59,763
protected static function query ( $ fields ) { $ result = Query :: from ( static :: $ table ) ; $ result = $ result -> where ( ) ; foreach ( $ fields as $ key => $ value ) { $ result = $ result -> andWhere ( $ key , '=' , $ value ) ; } return $ result -> get ( ) ; }
Get the user authenticate .
59,764
protected static function save_session ( ) { $ saved = [ ] ; $ user = ( array ) static :: $ user ; foreach ( $ user as $ key => $ value ) { if ( in_array ( $ key , static :: $ saved ) ) { $ saved [ $ key ] = $ value ; } } $ name = static :: resource ( 'session' ) ; Session :: put ( $ name , $ saved , config ( 'auth.cookie_lifetime' ) ) ; return true ; }
Save the user in the session .
59,765
public static function logout ( ) { Session :: forget ( static :: resource ( 'session' ) ) ; Cookie :: forget ( static :: resource ( 'cookie' ) ) ; static :: $ user = null ; return true ; }
Logout the user from the app .
59,766
public static function check ( ) { if ( Session :: exists ( static :: resource ( 'session' ) ) ) { return true ; } elseif ( Cookie :: existe ( static :: resource ( 'cookie' ) ) ) { $ token = Cookie :: get ( static :: resource ( 'cookie' ) ) ; $ result = Query :: from ( config ( 'auth.table' ) ) -> where ( 'rememberToken' , '=' , $ token ) -> get ( ) ; if ( count ( $ result ) > 0 ) { return true ; } return false ; } return false ; }
Check if user logged in .
59,767
public static function user ( ) { if ( self :: check ( ) ) { if ( is_null ( static :: $ user ) ) { $ data = Session :: get ( static :: resource ( 'session' ) ) ; $ data = static :: query ( $ data ) ; static :: $ user = static :: orm ( $ data [ 0 ] ) ; } return static :: $ user ; } }
Get the user logged in .
59,768
public static function login ( ) { if ( Cookie :: existe ( static :: resource ( 'cookie' ) ) ) { $ token = Cookie :: get ( static :: resource ( 'cookie' ) ) ; $ result = Query :: from ( config ( 'auth.table' ) ) -> where ( 'rememberToken' , '=' , $ token ) -> get ( ) ; if ( count ( $ result ) > 0 ) { static :: $ user = static :: orm ( $ result [ 0 ] ) ; static :: save_session ( ) ; return static :: $ user ; } return false ; } return false ; }
Login the user if session or cookie saved .
59,769
private static function orm ( Row $ data ) { $ data = ( array ) $ data ; $ id = array_shift ( $ data ) ; $ model = config ( 'auth.model' ) ; exception_if ( ! class_exists ( $ model ) , AMNFE :: class ) ; return new $ model ( $ id ) ; }
Convert data from array of Vinala \ Kernel \ Database \ Row to Vinala \ Kernel \ MVC \ ORM .
59,770
private static function resource ( $ resource ) { exception_if ( ( $ resource != 'session' && $ resource != 'cookie' ) , LogicException :: class , 'The resource name of \'' . $ resource . '\' is not supported by Vinala, only session or cookie' ) ; return Hash :: make ( config ( 'auth.' . $ resource ) ) ; return Hash :: make ( config ( 'auth.' . $ resource ) . static :: $ user -> rememberToken ) ; }
Get the resources hashed name .
59,771
protected function setStatus ( $ code , $ reasonPhrase = '' ) { if ( ! is_string ( $ reasonPhrase ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid reason phrase provided; must be a string, "%s" ' . 'received.' , is_object ( $ reasonPhrase ) ? get_class ( $ reasonPhrase ) : gettype ( $ reasonPhrase ) ) ) ; } if ( ! preg_match ( '#\A\d{3}\Z#' , $ code ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid status code provided; must be a 3-digit integer result' . ' code, "%s" received.' , is_scalar ( $ code ) ? $ code : gettype ( $ code ) ) ) ; } if ( $ code < 100 || $ code > 599 ) { throw new InvalidArgumentException ( 'Invalid status code provided; must be between 100 and 599.' ) ; } $ this -> statusCode = ( int ) $ code ; $ this -> reasonPhrase = $ reasonPhrase ; return $ this ; }
Sets the status code and optionally the reason phrase .
59,772
public function newAction ( ) { $ entity = new Strategy ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new Strategy entity .
59,773
public function init ( ) { if ( ! Director :: is_cli ( ) && ! Director :: isDev ( ) && ! Permission :: check ( 'ADMIN' ) ) { return Security :: permissionFailure ( ) ; } parent :: init ( ) ; }
Check that the user has appropriate permissions to execute this task
59,774
public function run ( $ request ) { $ failedFiles = 0 ; $ Videos = VideoFile :: get ( ) -> filter ( array ( 'ProcessingStatus' => 'error' ) ) -> sort ( 'ID' ) ; foreach ( $ Videos as $ vid ) { $ failedFiles ++ ; $ vid -> ProcessingStatus = 'new' ; $ vid -> write ( ) ; $ vid -> onAfterLoad ( ) ; sleep ( 5 ) ; } echo "$failedFiles failed VideoFile objects have reinitiated the processing." ; }
Clear out the image manipulation cache
59,775
public function add ( ElementInterface $ element ) { $ id = $ element -> id ; if ( $ id === null ) $ id = $ this -> generateId ( ) ; $ this -> checkId ( $ id ) ; $ this -> objects [ $ id ] = $ element ; }
Add an element to the collection
59,776
public function getListStyleFields ( ) { $ fields = parent :: getListStyleFields ( ) ; $ fields -> merge ( [ FieldSection :: create ( 'MasonryStyle' , $ this -> fieldLabel ( 'MasonryStyle' ) , [ SelectionGroup :: create ( 'ColumnUnit' , [ SelectionGroup_Item :: create ( self :: UNIT_PERCENT , ViewportsField :: create ( 'PercentWidth' , '' ) -> setUseTextInput ( true ) , $ this -> owner -> fieldLabel ( 'Percentages' ) ) , SelectionGroup_Item :: create ( self :: UNIT_PIXEL , ViewportsField :: create ( 'PixelWidth' , '' ) -> setUseTextInput ( true ) , $ this -> owner -> fieldLabel ( 'Pixels' ) ) ] ) -> setTitle ( $ this -> owner -> fieldLabel ( 'ColumnWidths' ) ) , TextField :: create ( 'Gutter' , $ this -> fieldLabel ( 'Gutter' ) ) ] ) ] ) ; return $ fields ; }
Answers the list style fields for the receiver .
59,777
public function getListOptionFields ( ) { $ fields = parent :: getListOptionFields ( ) ; $ fields -> merge ( [ FieldSection :: create ( 'MasonryOptions' , $ this -> fieldLabel ( 'MasonryOptions' ) , [ CheckboxField :: create ( 'HorizontalOrder' , $ this -> fieldLabel ( 'HorizontalOrder' ) ) ] ) ] ) ; return $ fields ; }
Answers the list option fields for the receiver .
59,778
public function getMasonryConfig ( ) { $ config = [ 'columnWidth' => '.masonry-grid-sizer' , 'itemSelector' => '.masonry-grid-item' , 'percentPosition' => $ this -> isPercentPosition ( ) , 'horizontalOrder' => $ this -> isHorizontalOrder ( ) ] ; if ( $ gutter = $ this -> Gutter ) { $ config [ 'gutter' ] = ( int ) $ this -> Gutter ; } return $ config ; }
Answers the configuration for Masonry as an array .
59,779
public function getColumnWidths ( ) { $ data = ArrayList :: create ( ) ; $ widths = $ this -> getColumnWidthData ( ) ; foreach ( $ widths -> getViewports ( ) as $ viewport ) { if ( $ value = $ widths -> getField ( $ viewport ) ) { $ gutter = ( int ) $ this -> Gutter ; if ( $ this -> ColumnUnitCSS == '%' ) { $ gutter = $ gutter - ( $ gutter * ( $ value / 100 ) ) ; } $ data -> push ( ArrayData :: create ( [ 'Unit' => $ this -> ColumnUnitCSS , 'Width' => sprintf ( '%F%s' , $ value , $ this -> ColumnUnitCSS ) , 'Gutter' => $ gutter , 'Breakpoint' => $ widths -> getBreakpoint ( $ viewport ) ] ) ) ; } } return $ data ; }
Answers a list of column width data for the custom CSS template .
59,780
public function serializeNodes ( array $ nodes , $ language , TokenInterface $ token ) { $ return = [ ] ; foreach ( $ nodes as $ node ) { $ nodeData = $ this -> serializeNode ( $ node , $ language , $ token ) ; if ( $ nodeData ) { $ return [ ] = $ nodeData ; } } return $ return ; }
Serialize nodes .
59,781
public static function upperCaseTitle ( $ string ) { if ( strpos ( $ string , ' ' ) !== false ) { if ( strtoupper ( $ string ) == $ string ) $ string = strtolower ( $ string ) ; } $ string = ucwords ( $ string ) ; $ string = str_replace ( self :: _getAdpositions ( ) , self :: _getAdpositions ( true ) , $ string ) ; return ucfirst ( $ string ) ; }
Format a string in title - case .
59,782
public static function generatePassphrase ( $ length = 10 ) { $ recursion = 0 ; $ generate = function ( $ length ) { for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ key = rand ( 0 , count ( self :: $ _passphrase_chars ) - 1 ) ; $ passphrase .= self :: $ _passphrase_chars [ $ key ] ; } return $ passphrase ; } ; $ passphrase = $ generate ( $ length ) ; $ secure_pattern = "/^(?=.\{$length\})(?=(.*[A-Za-z].*){2,})(?=(.*[0-9].*){2,})(?=(.*\W.*){1,}).*$/" ; while ( ! preg_match ( $ secure_pattern , $ passphrase ) ) { $ passphrase = $ generate ( $ length ) ; if ( $ recursion > 10 ) { ExceptionHandler :: notice ( 'Text::generatePassphrase() seems to be stuck, aborting' ) ; break ; } } return $ passphrase ; }
Generate a secure passphrase .
59,783
public static function purify ( $ keywords ) { $ keywords = filter_var ( $ keywords , FILTER_SANITIZE_STRING , FILTER_FLAG_NO_ENCODE_QUOTES ) ; $ keywords = preg_replace ( '/\s\s+/' , ' ' , $ keywords ) ; $ keywords = trim ( $ keywords ) ; $ dirty_tokens = explode ( ' ' , $ keywords ) ; $ clean_tokens = [ ] ; foreach ( $ dirty_tokens as $ token ) { $ pattern = "/[\w'\"`-]{3,}/i" ; if ( preg_match ( $ pattern , $ token ) ) { if ( strlen ( $ token ) < 64 ) { $ clean_tokens [ ] = $ token ; } } } return [ 'dirty' => $ dirty_tokens , 'clean' => $ clean_tokens , 'stems' => $ clean_tokens ] ; }
Clean up a search string .
59,784
public function assign ( $ property , $ value ) { if ( null === $ this -> object ) { $ this -> object = new Object ; } $ this -> object -> assign ( $ property , $ value ) ; return $ this ; }
Set value of an object property .
59,785
public function unassign ( $ property ) { if ( null === $ this -> object ) { $ this -> object = new Object ; } $ this -> object -> unassign ( $ property ) ; return $ this ; }
Unassign an object property .
59,786
private function _hasJoinMany ( ) { foreach ( $ this -> getJoins ( ) as $ join ) { $ element = $ this -> getBaseFace ( ) -> getElement ( $ join -> getPath ( ) ) ; if ( $ element -> hasManyRelationship ( ) || $ element -> hasManyThroughRelationship ( ) ) { return true ; } else { return false ; } } return false ; }
check if it contains at least 1 hasMany relationship .
59,787
public function getReachableGroups ( array $ groups ) { $ reachableGroups = $ groups ; foreach ( $ groups as $ group ) { if ( ! isset ( $ this -> map [ $ group ] ) ) { continue ; } $ reachableGroups = array_merge ( $ reachableGroups , $ this -> map [ $ group ] ) ; } return array_unique ( array_merge ( $ reachableGroups , $ this -> groupAlwaysPresent ) ) ; }
Return the list of groups this does refer to
59,788
public function select ( $ cols = array ( '*' ) ) { if ( ! is_array ( $ cols ) ) { $ cols = func_get_args ( ) ; } return new Query ( "SELECT" , $ cols , $ this -> connectionName ) ; }
Returns a select query builder object .
59,789
public static function install ( ) { update_option ( 'search-statistics-db-version' , 0 ) ; $ charsetCollation = self :: $ wpdb -> get_charset_collate ( ) ; $ tableName = self :: $ dbTable ; if ( ! empty ( get_site_option ( 'search-statistics-db-version' ) ) && self :: $ wpdb -> get_var ( "SHOW TABLES LIKE '$tableName'" ) == $ tableName ) { return ; } $ sql = "CREATE TABLE $tableName ( id bigint(20) NOT NULL AUTO_INCREMENT, query varchar(255) DEFAULT NULL, results bigint(20) DEFAULT 0 NOT NULL, site_id bigint(20) DEFAULT NULL, logged_in tinyint(1) DEFAULT 0 NOT NULL, date_searched timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, UNIQUE KEY id (id) ) $charsetCollation;" ; require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' ) ; dbDelta ( $ sql ) ; update_option ( 'search-statistics-db-version' , 2 ) ; }
Creates the search log db table
59,790
public function write ( string $ string ) : StreamInterface { if ( ! is_resource ( $ this -> stream ) ) { throw new StreamException ( 'Stream is not longer available' ) ; } if ( ! $ this -> writable ) { throw new StreamException ( 'Stream is not writable' ) ; } $ this -> size = null ; $ result = fwrite ( $ this -> stream , $ string ) ; if ( $ result === false ) { throw new StreamException ( 'Unable to write to stream' ) ; } return $ this ; }
writes the provided string to the current stream position .
59,791
public function type ( string $ type ) : ResolverInterface { $ this -> type = DataType :: make ( $ type ) ; return $ this ; }
Asigna un tipo a este resolver
59,792
public function value ( callable $ callback , $ value , $ key = null ) : void { $ input = $ this -> resolve ( $ value ) ; if ( ! $ input -> isValid ( ) ) { return ; } call_user_func ( $ callback , $ input -> value ( ) , $ key ) ; }
Resuelve un valor
59,793
public function values ( callable $ callback , iterable $ values ) : void { $ listOfValues = ResolvedValuesList :: make ( ) ; foreach ( $ values as $ key => $ value ) { $ input = $ this -> resolve ( $ value ) ; $ listOfValues -> set ( $ key , $ input ) ; } if ( $ listOfValues -> isEmpty ( ) ) { return ; } call_user_func ( $ callback , $ listOfValues -> getValues ( ) ) ; }
Resuelve un conjunto de valores
59,794
private function resolve ( $ value ) : Input { $ rules = $ this -> queueOfRules -> toArray ( ) ; $ input = Input :: make ( $ value ) ; foreach ( $ rules as $ rule ) { $ input = $ rule -> execute ( $ input ) ; } $ input = $ this -> applyTypeValidation ( $ input ) ; return $ input ; }
Evalua un valor capturando las excepciones
59,795
private function isValidType ( $ value ) : bool { if ( $ this -> type instanceof DataType ) { return $ this -> type -> isTheTypeOf ( $ value ) ; } return true ; }
Indica si un valor es del tipo correcto
59,796
protected function getFieldsetHelper ( ) { if ( $ this -> fieldsetHelper ) { return $ this -> fieldsetHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> fieldsetHelper = $ this -> view -> plugin ( $ this -> defaultFieldsetHelper ) ; } if ( ! $ this -> fieldsetHelper instanceof AbstractHelper ) { throw InvalidHelperException :: invalidHelperInstance ( $ this -> fieldsetHelper ) ; } return $ this -> fieldsetHelper ; }
Retrieve the fieldset helper
59,797
protected function getFormMessagesHelper ( ) { if ( $ this -> formMessagesHelper ) { return $ this -> formMessagesHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> formMessagesHelper = $ this -> view -> plugin ( $ this -> defaultFormMessagesHelper ) ; } if ( ! $ this -> formMessagesHelper instanceof AbstractHelper ) { throw InvalidHelperException :: invalidHelperInstance ( $ this -> formMessagesHelper ) ; } return $ this -> formMessagesHelper ; }
Retrieve the form messages helper
59,798
public function getFeedLink ( $ rel = null ) { if ( $ rel == null ) { return $ this -> _feedLink ; } else { foreach ( $ this -> _feedLink as $ feedLink ) { if ( $ feedLink -> rel == $ rel ) { return $ feedLink ; } } return null ; } }
Get the feed link property for this entry .
59,799
public static function PrepareUserObject ( $ data_sent , $ object ) { foreach ( $ data_sent as $ key => $ value ) { $ method = "set" . ucfirst ( $ key ) ; $ object -> $ method ( ! array_key_exists ( $ key , $ data_sent ) ? null : $ value ) ; } return $ object ; }
Prepare an object Object before calling the DB .