idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
53,500
public function findAllExcept ( array $ excludedUser ) { $ dql = ' SELECT u FROM Claroline\CoreBundle\Entity\User u WHERE u NOT IN (:userIds) AND u.isRemoved = false ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'userIds' , $ excludedUser ) ; return $ query -> getResult ( ) ; }
Returns all the users except a given one .
53,501
public function findByWorkspaceWithUsersFromGroup ( Workspace $ workspace , $ executeQuery = true ) { $ dql = ' SELECT u FROM Claroline\CoreBundle\Entity\User u JOIN u.roles ur LEFT JOIN u.groups g LEFT JOIN g.roles gr LEFT JOIN gr.workspace grws LEFT JOIN ur.workspace uws WHERE (uws.id = :wsId OR grws.id = :wsId) AND u.isRemoved = false ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'wsId' , $ workspace -> getId ( ) ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; }
Returns the users who are members of one of the given workspaces . Users s groups ARE taken into account .
53,502
public function updateProgressionAction ( Step $ step , User $ user , Request $ request ) { $ node = $ step -> getPath ( ) -> getResourceNode ( ) ; if ( ! $ this -> authorization -> isGranted ( 'OPEN' , new ResourceCollection ( [ $ node ] ) ) ) { throw new AccessDeniedException ( 'Operation "OPEN" cannot be done on object' . get_class ( $ node ) ) ; } $ status = $ this -> decodeRequest ( $ request ) [ 'status' ] ; $ this -> userProgressionManager -> update ( $ step , $ user , $ status , true ) ; $ this -> userProgressionManager -> generateResourceEvaluation ( $ step , $ user , $ status ) ; $ resourceUserEvaluation = $ this -> userProgressionManager -> getResourceUserEvaluation ( $ step -> getPath ( ) , $ user ) ; return new JsonResponse ( [ 'userEvaluation' => $ this -> serializer -> serialize ( $ resourceUserEvaluation ) , 'userProgression' => [ 'stepId' => $ step -> getUuid ( ) , 'status' => $ status , ] , ] ) ; }
Update step progression for an user .
53,503
public function getSelection ( $ uuid ) { foreach ( $ this -> selections as $ selection ) { if ( $ selection -> getUuid ( ) === $ uuid ) { return $ selection ; } } }
Retrieves a selection by its uuid .
53,504
public function addSelection ( Selection $ selection ) { if ( ! $ this -> selections -> contains ( $ selection ) ) { $ this -> selections -> add ( $ selection ) ; $ selection -> setInteractionSelection ( $ this ) ; } }
Adds a selection .
53,505
public function removeSelection ( Selection $ selection ) { if ( $ this -> selections -> contains ( $ selection ) ) { $ this -> selections -> removeElement ( $ selection ) ; } }
Removes a selection .
53,506
public function getColor ( $ uuid ) { foreach ( $ this -> colors as $ color ) { if ( $ color -> getUuid ( ) === $ uuid ) { return $ color ; } } }
Retrieves a color by its uuid .
53,507
public function addColor ( Color $ color ) { if ( ! $ this -> colors -> contains ( $ color ) ) { $ this -> colors -> add ( $ color ) ; $ color -> setInteractionSelection ( $ this ) ; } }
Adds a color .
53,508
public function removeColor ( Color $ color ) { if ( $ this -> colors -> contains ( $ color ) ) { $ this -> colors -> removeElement ( $ color ) ; } }
Removes a color .
53,509
public function findDisplayedByRolesAndWorkspace ( array $ roles , Workspace $ workspace , $ orderedToolType = 0 ) { if ( count ( $ roles ) === 0 ) { return array ( ) ; } else { $ isAdmin = false ; foreach ( $ roles as $ role ) { if ( $ role === 'ROLE_ADMIN' || $ role === 'ROLE_WS_MANAGER_' . $ workspace -> getGuid ( ) ) { $ isAdmin = true ; } } if ( ! $ isAdmin ) { $ dql = ' SELECT t FROM Claroline\CoreBundle\Entity\Tool\Tool t JOIN t.orderedTools ot JOIN ot.rights r JOIN r.role rr LEFT JOIN t.plugin p WHERE ot.workspace = :workspace AND ot.type = :type AND rr.name IN (:roleNames) AND BIT_AND(r.mask, 1) = 1 AND ( CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR p.id is NULL ) ORDER BY ot.order ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspace' , $ workspace ) ; $ query -> setParameter ( 'roleNames' , $ roles ) ; $ query -> setParameter ( 'type' , $ orderedToolType ) ; $ query -> setParameter ( 'bundles' , $ this -> bundles ) ; } else { $ dql = ' SELECT tool FROM Claroline\CoreBundle\Entity\Tool\Tool tool JOIN tool.orderedTools ot LEFT JOIN tool.plugin p WHERE ot.workspace = :workspace AND tool.isDisplayableInWorkspace = true AND ( CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR tool.plugin is NULL ) ORDER BY ot.order ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspace' , $ workspace ) ; $ query -> setParameter ( 'bundles' , $ this -> bundles ) ; } return $ query -> getResult ( ) ; } }
Returns the workspace tools visible by a set of roles .
53,510
public function findDisplayedToolsByWorkspace ( Workspace $ workspace , $ orderedToolType = 0 ) { $ dql = ' SELECT tool FROM Claroline\CoreBundle\Entity\Tool\Tool tool LEFT JOIN tool.plugin p JOIN tool.orderedTools ot JOIN ot.workspace ws WHERE ws = :workspace AND ot.type = :type AND ( CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR tool.plugin is NULL ) ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'workspace' , $ workspace ) ; $ query -> setParameter ( 'type' , $ orderedToolType ) ; $ query -> setParameter ( 'bundles' , $ this -> bundles ) ; return $ query -> getResult ( ) ; }
Returns the visible tools in a workspace .
53,511
public function countDisplayedToolsByWorkspace ( Workspace $ workspace , $ orderedToolType = 0 ) { $ dql = " SELECT count(tool) FROM Claroline\CoreBundle\Entity\Tool\Tool tool JOIN tool.orderedTools ot JOIN ot.workspace ws LEFT JOIN tool.plugin p WHERE ws.id = {$workspace->getId()} AND ot.type = :type AND ( CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR tool.plugin is NULL ) " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'type' , $ orderedToolType ) ; $ query -> setParameter ( 'bundles' , $ this -> bundles ) ; return $ query -> getSingleScalarResult ( ) ; }
Returns the number of tools visible in a workspace .
53,512
public function setValue ( $ value ) { if ( ! $ this -> isValid ( $ value ) ) { throw new \ UnexpectedValueException ( "Value '$value' is not part of the enum " . get_called_class ( ) ) ; } $ this -> value = $ value ; }
Tries to set the value of this enum .
53,513
public function InSection ( $ sectionName ) { $ page = Director :: get_current_page ( ) ; while ( $ page ) { if ( $ sectionName == $ page -> URLSegment ) return true ; $ page = $ page -> Parent ; } return false ; }
Check if this page is in the given current section .
53,514
protected function sameFilesystemAction ( $ from , $ to , $ action = 'copy' ) { $ obj = $ this -> path ( $ from ) ; $ res = $ obj -> { $ action } ( $ this -> path ( $ to ) -> getPath ( ) ) ; $ this -> copyError ( $ obj ) ; return $ res ; }
Copy or rename
53,515
protected function diffFilesystemCopy ( $ from , $ to ) { $ content = $ this -> get ( $ from ) ; if ( is_null ( $ content ) ) { return false ; } elseif ( is_array ( $ content ) ) { return $ this -> copyDir ( $ content , $ to ) ; } else { if ( $ this -> path ( $ to ) -> isDir ( ) ) { $ to = $ this -> mergePath ( $ to , basename ( $ from ) ) ; } return $ this -> put ( $ to , $ content ) ; } }
Copy between different filesystem
53,516
protected function isSameFilesystem ( $ path1 , $ path2 ) { return $ this -> path ( $ path1 ) -> getFilesystem ( ) === $ this -> path ( $ path2 ) -> getFilesystem ( ) ; }
Exists on same filesystem ?
53,517
protected function copyDir ( array $ paths , $ destination ) { foreach ( $ paths as $ path ) { $ dest = $ this -> mergePath ( $ destination , basename ( $ path ) ) ; if ( ! $ this -> copy ( $ path , $ dest ) ) { return false ; } } return true ; }
Copy an array of paths to destination
53,518
protected function prependMountPoint ( array $ paths , $ mountPoint ) { $ res = [ ] ; foreach ( $ paths as $ p ) { $ res [ ] = $ this -> mergePath ( $ mountPoint , $ p ) ; } return $ res ; }
Prepend mount point prefix to the array of paths
53,519
public function setFailConnectionFailed ( bool $ fail_connection_failed = true ) : void { $ this -> is_connected = false ; $ this -> fail_connection_failed = $ fail_connection_failed ; }
Testing method - set that the connection failed to test error handling . Set this before attempting the query .
53,520
public function setFailQueryFailed ( bool $ fail_query_failed = true ) : void { $ this -> query_succeeded = false ; $ this -> fail_query_failed = $ fail_query_failed ; }
Testing method - set that the query failed to test error handling . Set this before attempting the query .
53,521
public function isValid ( ) : bool { if ( false === $ this -> validated ) { $ this -> validate ( ) ; } return ( count ( $ this -> validation_errors ) === 0 ) ; }
This is the opposite of the hasErrors method
53,522
public function hasErrors ( ) : bool { if ( false === $ this -> validated ) { $ this -> validate ( ) ; } return ( count ( $ this -> validation_errors ) > 0 ) ; }
This is the opposite of the isValid method
53,523
public function getErrorMessages ( ) : array { $ errors = $ this -> getErrors ( true ) ; $ return = array ( ) ; foreach ( $ errors as $ error ) { $ return [ ] = 'Field: ' . $ error -> getFieldName ( ) . '| Message: ' . $ error -> getErrorMessage ( ) ; } return $ return ; }
Returns an array of error messages intended to be displayed in a list .
53,524
public function isFieldValid ( string $ field_name ) : bool { if ( false === $ this -> validated ) { $ this -> validate ( ) ; } return ( false === $ this -> getErrorByFieldName ( $ field_name ) ) ; }
Check if a specific field is valid .
53,525
public function getFieldValue ( string $ field_name ) { if ( false === $ this -> validated ) { $ this -> validate ( ) ; } foreach ( $ this -> validators as $ validator ) { if ( $ validator -> getFieldName ( ) == $ field_name ) { return $ validator -> getValue ( ) ; } } throw new InvalidInputException ( 'A field called ' . $ field_name . ' was not defined.' ) ; }
Get the value associated with the field . If the field was not valid returns null .
53,526
private function parseRequestValueExpression ( string $ expression , RequestInterface $ request ) : string { $ expression = preg_replace_callback ( '/(\$\w+)/' , function ( $ matches ) use ( $ request ) { $ variable = $ request -> get ( substr ( $ matches [ 1 ] , 1 ) ) ; if ( is_array ( $ variable ) || is_object ( $ variable ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot use %s ($%s) as parameter in expression.' , gettype ( $ variable ) , $ matches [ 1 ] ) ) ; } return is_string ( $ variable ) ? sprintf ( '"%s"' , $ variable ) : $ variable ; } , $ expression ) ; return $ this -> expression -> evaluate ( $ expression , [ 'container' => $ this -> container ] ) ; }
Parse request value with expression .
53,527
public function add ( $ files , $ string = false ) { if ( true === $ this -> _enabled ) { if ( Arrays :: is ( $ files ) ) { foreach ( $ files as $ file ) { $ this -> _addFile ( ( string ) $ file ) ; } } else { if ( ! empty ( $ string ) && is_string ( $ string ) ) { return $ this -> _zip -> addFromString ( $ files , $ string ) ; } else { return $ this -> _addFile ( $ files ) ; } } } return false ; }
Add file to the archive
53,528
public function contents ( ) { if ( true === $ this -> _enabled ) { for ( $ i = 0 ; $ i < $ this -> _zip -> numFiles ; ++ $ i ) { $ this -> _contents [ $ i ] = $ this -> _zip -> statIndex ( $ i ) ; $ comment = $ this -> _zip -> getCommentIndex ( $ i ) ; if ( $ comment ) { $ this -> _contents [ $ i ] [ 'comment' ] = $ comment ; } } return ( ! is_null ( $ this -> _contents ) ) ? $ this -> _contents : false ; } return false ; }
Get archive contents
53,529
public function delete ( $ filename ) { if ( true === $ this -> _enabled && ! empty ( $ filename ) ) { $ index = $ this -> _zip -> locateName ( $ filename , \ ZipArchive :: FL_NODIR ) ; if ( $ index ) { return $ this -> deleteIndex ( ( int ) $ index ) ; } } return false ; }
Delete file from archive
53,530
protected function saveRules ( ) { $ rules = [ ] ; foreach ( $ this -> rules as $ name => $ rule ) { $ rules [ $ name ] = serialize ( $ rule ) ; } DiscHelper :: saveToFile ( $ rules , $ this -> ruleFile ) ; $ this -> domain -> const -> generateAll ( ) ; }
Saves rules data into persistent storage .
53,531
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( ! $ this -> getOwner ( ) -> Contact ( ) -> exists ( ) ) { $ sync = Config :: inst ( ) -> get ( Contact :: class , 'sync_fields' ) ; $ contact = Contact :: create ( ) ; foreach ( $ sync as $ field ) { $ contact -> $ field = $ this -> getOwner ( ) -> $ field ; } $ contact -> MemberID = $ this -> getOwner ( ) -> ID ; $ contact -> write ( ) ; } else { $ this -> getOwner ( ) -> syncToContact ( ) ; } }
If no contact exists for this account then create one
53,532
public function getLog ( $ index = null ) { if ( is_null ( $ index ) ) { return $ this -> log ; } return $ this -> log [ $ index ] ; }
Return the log array .
53,533
public function client ( $ alias ) { if ( is_int ( $ alias ) && isset ( $ this -> clients [ $ alias ] ) ) { return $ this -> clients [ $ alias ] ; } elseif ( isset ( $ this -> aliases [ $ alias ] ) ) { return $ this -> aliases [ $ alias ] ; } throw new Exception ( "Client $alias does not exist." ) ; }
Get a client by index or alias .
53,534
public function all ( ) { $ args = func_get_args ( ) ; $ name = array_shift ( $ args ) ; $ results = array ( ) ; foreach ( $ this -> clients as $ client ) { $ results [ ] = call_user_func_array ( [ $ client , $ name ] , $ args ) ; } return $ results ; }
Execute a command on all clients
53,535
public function hash ( $ key ) { $ needle = hexdec ( substr ( md5 ( $ key ) , 0 , 7 ) ) ; $ server = $ min = 0 ; $ max = count ( $ this -> nodes ) - 1 ; while ( $ max >= $ min ) { $ position = ( int ) ( ( $ min + $ max ) / 2 ) ; $ server = $ this -> nodes [ $ position ] ; if ( $ needle < $ server ) { $ max = $ position - 1 ; } elseif ( $ needle > $ server ) { $ min = $ position + 1 ; } else { break ; } } return $ this -> ring [ $ server ] ; }
Get client index for a key by searching ring with binary search
53,536
public static function instance ( ) : StringSyntax { if ( self :: $ instance === null ) self :: $ instance = new StringSyntax ; return self :: $ instance ; }
Returns the StringSyntax instance .
53,537
public static function prepare ( ) { $ orgArgs = func_get_args ( ) ; if ( count ( $ orgArgs ) < 2 ) { throw new \ BadMethodCallException ( 'Func::prepare requires at least two arguments. First should be the function to prepare followed by arguments for that function' ) ; } $ func = array_shift ( $ orgArgs ) ; return function ( ) use ( $ func , $ orgArgs ) { $ additionalArgs = func_get_args ( ) ; foreach ( $ orgArgs as $ index => $ arg ) { if ( is_null ( $ arg ) ) { $ additionalArg = array_shift ( $ additionalArgs ) ; if ( is_null ( $ additionalArg ) ) { throw new \ BadMethodCallException ( 'Parameter mismatch detected for prepared function: ' . ( string ) $ func ) ; } $ orgArgs [ $ index ] = $ additionalArg ; } } return Func :: call ( $ func , $ orgArgs ) ; } ; }
Initializes method of Func passed as first argument with provided arguments . Pass null for arguments that you wanna skip even when you wanna skip the last argument!
53,538
public static function call ( $ func , array $ args ) { switch ( $ func ) { case 'map' : if ( count ( $ args ) != 2 ) throw new \ BadMethodCallException ( "Wrong parameter count for method Func::map" ) ; return self :: map ( $ args [ 0 ] , $ args [ 1 ] ) ; case 'premap' : if ( count ( $ args ) != 2 ) throw new \ BadMethodCallException ( "Wrong parameter count for method Func::premap" ) ; return self :: premap ( $ args [ 0 ] , $ args [ 1 ] ) ; case 'to_data' : if ( count ( $ args ) != 1 ) throw new \ BadMethodCallException ( "Wrong parameter count for method Func::to_data" ) ; return self :: to_data ( $ args [ 0 ] ) ; case 'manipulate' : if ( count ( $ args ) != 2 ) throw new \ BadMethodCallException ( "Wrong parameter count for method Func::manipulate" ) ; return self :: manipulate ( $ args [ 0 ] , $ args [ 1 ] ) ; default : throw new \ InvalidArgumentException ( sprintf ( 'Unknown function name provided: %s' , ( string ) $ func ) ) ; } }
Calls a method of Func with arguments provided as array
53,539
public static function manipulate ( Payload $ payload , $ callback ) { self :: assert_callable ( $ callback ) ; $ payload -> replaceData ( $ callback ( $ payload -> extractTypeData ( ) ) ) ; return $ payload ; }
Extracts data from payload passes it to callback and overrides payload data with result
53,540
public static function isKeyWithElements ( $ array , $ key ) { if ( false === is_array ( $ array ) || false === isset ( $ array [ $ key ] ) ) { return false ; } if ( false === is_array ( $ array [ $ key ] ) ) { return false ; } if ( 0 === count ( $ array [ $ key ] ) ) { return false ; } return true ; }
Does given array has array with elements for key?
53,541
public static function getFlat ( $ input , $ glue = ',' ) { if ( false === is_array ( $ input ) ) { return $ input ; } $ result = [ ] ; foreach ( $ input as $ inputKey => $ inputText ) { if ( true === is_numeric ( $ inputKey ) ) { $ result [ ] = self :: getFlat ( $ inputText , $ glue ) ; } $ result [ ] = sprintf ( '%s: %s' , $ inputKey , self :: getFlat ( $ inputText , $ glue ) ) ; } return implode ( $ glue , $ result ) ; }
Get Multidimensional - Array as string
53,542
protected function getLogAsObject ( $ level , $ message ) { $ log = new Entity ; $ log -> level = $ level ; $ log -> datetime = date ( 'Y-m-d H:i:s' ) ; if ( preg_match ( '/^(\[([^\]]+)\]\s)?(.+)/' , $ message , $ matches ) ) { if ( ! empty ( $ matches [ 2 ] ) ) { $ log -> exception = $ matches [ 2 ] ; } $ log -> message = $ matches [ 3 ] ; } if ( preg_match ( '/Exception Attributes:\s((.(?!Request URL|Referer URL|Client IP|Stack Trace|Trace))+)/is' , $ message , $ matches ) ) { $ log -> attributes = $ matches [ 1 ] ; } if ( preg_match ( '/^Request URL:\s(.+)$/mi' , $ message , $ matches ) ) { $ log -> request = $ matches [ 1 ] ; } if ( preg_match ( '/^Referer URL:\s(.+)$/mi' , $ message , $ matches ) ) { $ log -> referer = $ matches [ 1 ] ; } if ( preg_match ( '/^Client IP:\s(.+)$/mi' , $ message , $ matches ) ) { $ log -> ip = $ matches [ 1 ] ; } if ( preg_match ( '/(Stack )?Trace:\n(.+)$/is' , $ message , $ matches ) ) { $ log -> trace = trim ( $ matches [ 2 ] ) ; } $ log -> full = trim ( sprintf ( '%s %s: %s' , date ( 'Y-m-d H:i:s' ) , ucfirst ( $ level ) , $ message ) ) ; return $ log ; }
Gets the log as an object . It splits the log information from the message using regex
53,543
protected function checkPermissionMask ( $ selfError , $ exists , $ pathname , $ mask ) { return ! ( ! $ selfError && ! $ exists && ! chmod ( $ pathname , ( int ) $ mask ) ) ; }
Internal method to check the permission mask . Useful only for obtaining a stub method
53,544
public function is_valid ( ) { $ ret = false ; if ( is_null ( $ this -> maxRecipients ) === false && is_null ( $ this -> priority ) === false && is_null ( $ this -> compileBeforeDeliveryStart ) === false && is_null ( $ this -> allowMultipleDeliveries ) === false && is_null ( $ this -> deliverImmediately ) === false && is_null ( $ this -> obeyDeliveryLimits ) === false ) { if ( $ this -> deliverImmediately === true || is_null ( $ this -> deliveryStartDateTime ) === false ) { if ( $ this -> compileBeforeDeliveryStart === false || ( is_null ( $ this -> compileStartDateTime ) === false && is_null ( $ this -> deliveryStartDateTime ) === false && $ this -> compileStartDateTime <= $ this -> deliveryStartDateTime ) ) { $ ret = true ; } } } return $ ret ; }
Validates a scheduling
53,545
protected function dnsResolutionIsOk ( $ domain = null , $ ip = null ) { if ( $ this -> dnsAlreadyResolved ) { return true ; } $ domain = $ domain ? $ domain : $ this -> obtainDomain ( ) ; $ ip = $ ip ? $ ip : $ this -> obtainIp ( ) ; if ( $ domain != null && $ ip != null ) { $ resolved_ip = gethostbyname ( $ domain ) ; if ( $ resolved_ip != $ domain && $ resolved_ip == $ ip ) { $ this -> dnsAlreadyResolved = true ; return true ; } } return false ; }
Check if DNS is already configured .
53,546
public static function toBytes ( String $ data ) : Float { $ number = substr ( $ data , 0 , - 2 ) ; switch ( strtoupper ( substr ( $ data , - 2 ) ) ) { case 'KB' : return $ number * 1024 ; case 'MB' : return $ number * pow ( 1024 , 2 ) ; case 'GB' : return $ number * pow ( 1024 , 3 ) ; case 'TB' : return $ number * pow ( 1024 , 4 ) ; case 'PB' : return $ number * pow ( 1024 , 5 ) ; default : return $ data ; } }
Convert string to bytes .
53,547
public static function highLight ( String $ str , Array $ settings = [ ] ) : String { return Helper :: highLight ( $ str , $ settings ) ; }
Convert high lightin
53,548
public static function accent ( String $ str ) : String { $ accent = array_merge ( Config :: get ( 'Expressions' , 'accentChars' ) ? : [ ] , self :: $ accentChars ) ; $ accent = Datatype :: multikey ( $ accent ) ; return str_replace ( array_keys ( $ accent ) , array_values ( $ accent ) , $ str ) ; }
Converter Accent Char
53,549
public static function toConstant ( String $ var , String $ prefix = NULL , String $ suffix = NULL ) { return Helper :: toConstant ( $ var , $ prefix , $ suffix ) ; }
Convert to constant
53,550
protected static function objectRecursive ( Array $ array , stdClass & $ std ) : stdClass { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ std -> $ key = new stdClass ; self :: objectRecursive ( $ value , $ std -> $ key ) ; } else { $ std -> $ key = $ value ; } } return $ std ; }
Protected Object Recursive
53,551
public function doViewContent ( ) { $ this -> setDefaultResponseGroups ( array ( self :: VIEWCONTENT_RESPONSEGROUP_METADATA ) ) ; $ isNodeRequested = false ; if ( isset ( $ this -> nodeId ) ) { $ content = ezpContent :: fromNodeId ( $ this -> nodeId ) ; $ isNodeRequested = true ; } else if ( isset ( $ this -> objectId ) ) { $ content = ezpContent :: fromObjectId ( $ this -> objectId ) ; } $ result = new ezpRestMvcResult ( ) ; if ( $ this -> hasContentVariable ( 'Translation' ) ) $ content -> setActiveLanguage ( $ this -> getContentVariable ( 'Translation' ) ) ; if ( $ this -> hasResponseGroup ( self :: VIEWCONTENT_RESPONSEGROUP_METADATA ) ) { $ objectMetadata = ezpRestContentModel :: getMetadataByContent ( $ content ) ; if ( $ isNodeRequested ) { $ nodeMetadata = ezpRestContentModel :: getMetadataByLocation ( ezpContentLocation :: fetchByNodeId ( $ this -> nodeId ) ) ; $ objectMetadata = array_merge ( $ objectMetadata , $ nodeMetadata ) ; } $ result -> variables [ 'metadata' ] = $ objectMetadata ; } if ( $ this -> hasResponseGroup ( self :: VIEWCONTENT_RESPONSEGROUP_LOCATIONS ) ) { $ result -> variables [ 'locations' ] = ezpRestContentModel :: getLocationsByContent ( $ content ) ; } if ( $ this -> hasResponseGroup ( self :: VIEWCONTENT_RESPONSEGROUP_FIELDS ) ) { $ result -> variables [ 'fields' ] = ezpRestContentModel :: getFieldsByContent ( $ content ) ; } $ result -> variables [ 'links' ] = ezpRestContentModel :: getFieldsLinksByContent ( $ content , $ this -> request ) ; if ( $ outputFormat = $ this -> getContentVariable ( 'OutputFormat' ) ) { $ renderer = ezpRestContentRenderer :: getRenderer ( $ outputFormat , $ content , $ this ) ; $ result -> variables [ 'renderedOutput' ] = $ renderer -> render ( ) ; } return $ result ; }
Handles content requests per node or object ID
53,552
public function loadProperty ( $ prop ) { if ( $ prop -> isPrimaryKey ( ) ) { $ this -> setPrimaryKey ( $ prop ) ; } else if ( $ prop -> isProperty ( ) ) { $ this -> properties [ ] = $ prop ; if ( $ prop -> isIndexed ( ) ) { $ this -> indexedProperties [ ] = $ prop ; } } }
Loads a property into this graph element .
53,553
function findProperty ( $ name ) { $ property = Reflection :: getProperty ( $ name ) ; foreach ( $ this -> properties as $ p ) { if ( $ p -> matches ( $ property ) ) { return $ p ; } } return null ; }
Finds property by method name .
53,554
public function provides ( $ consumer ) { $ file = $ this -> getConfigFilePath ( ) ; $ routes = $ this -> config -> get ( 'routes' ) ; if ( is_null ( $ routes ) ) { return ; } foreach ( $ routes as $ name => $ route ) { if ( ! isset ( $ route [ 'path' ] ) ) { throw new RuntimeException ( 'no "path" in route "' . $ name . '" defined in ' . $ file ) ; } if ( ! isset ( $ route [ 'action' ] ) ) { throw new RuntimeException ( 'no "action" in route "' . $ name . '" defined in ' . $ file ) ; } $ path = $ route [ 'path' ] ; $ action = $ route [ 'action' ] ; $ method = null ; $ headers = [ ] ; $ defaults = [ ] ; if ( isset ( $ route [ 'method' ] ) ) { if ( ! is_string ( $ route [ 'method' ] ) ) { throw new RuntimeException ( 'invalid "method", expecting string in route "' . $ name . '" defined in ' . $ file ) ; } $ method = $ route [ 'method' ] ; } if ( isset ( $ route [ 'headers' ] ) ) { if ( ! is_array ( $ route [ 'headers' ] ) ) { throw new RuntimeException ( 'invalid "headers", expecting array in route "' . $ name . '" defined in ' . $ file ) ; } $ headers = $ route [ 'headers' ] ; } if ( isset ( $ route [ 'defaults' ] ) ) { if ( ! is_array ( $ route [ 'defaults' ] ) ) { throw new RuntimeException ( 'invalid "defaults", expecting array in route "' . $ name . '" defined in ' . $ file ) ; } $ defaults = $ route [ 'defaults' ] ; } $ consumer -> route ( $ path , $ action , $ method , $ headers , $ defaults , $ name ) ; } }
Configure the http dispatcher with routes defined in a config file .
53,555
function getCounterKey ( $ username ) { $ k = $ this -> app [ 'config' ] -> get ( 'cache.namespace' ) ; $ k .= ':failed_login_counter.' ; $ k .= $ username ; return $ k ; }
Gets the key of the failed login counter in Redis for a given username .
53,556
protected function bootstrapColumn ( $ content , $ match ) { $ parts = $ this -> getGridsystemColumMethodParts ( $ match ) ; $ this -> bootstrapGridsystemCol .= $ this -> class ( $ this -> getGridsytemColumnClass ( $ parts ) ) -> div ( $ content ) ; $ this -> bootstrapGridsystemColumnCount += ( int ) $ parts [ 'number' ] ; if ( $ this -> bootstrapGridsystemColumnCount === 12 ) { $ this -> bootstrapGridsystemRow .= $ this -> class ( 'row' ) -> div ( $ this -> bootstrapGridsystemCol ? : '' ) ; $ this -> bootstrapGridsystemCol = '' ; $ this -> bootstrapGridsystemColumnCount = 0 ; } }
Protected bootstrap column
53,557
public function getRemoteAddr ( $ ipToLong = false ) { if ( is_null ( $ this -> _remoteAddr ) ) { $ headers = $ this -> getRemoteAddrHeaders ( ) ; foreach ( $ headers as $ var ) { if ( $ this -> _getRequest ( ) -> getServer ( $ var , false ) ) { $ ip_array = explode ( ',' , $ this -> _getRequest ( ) -> getServer ( $ var , false ) ) ; foreach ( $ ip_array as $ ipAddress ) { preg_match_all ( '/\d{1,3}/' , $ ipAddress , $ r ) ; $ this -> _remoteAddr = $ r [ 0 ] [ 0 ] . '.' . $ r [ 0 ] [ 1 ] . '.' . $ r [ 0 ] [ 2 ] . '.' . $ r [ 0 ] [ 3 ] ; if ( $ this -> _remoteAddr ) { if ( ! $ this -> ip_is_private ( $ this -> _remoteAddr ) ) { break ; } else { $ this -> _remoteAddr = '' ; } } } } if ( $ this -> _remoteAddr ) { break ; } } if ( ! $ this -> _remoteAddr ) { $ this -> _remoteAddr = $ this -> _getRequest ( ) -> getServer ( 'REMOTE_ADDR' ) ; } } if ( ! $ this -> _remoteAddr ) { return false ; } return $ ipToLong ? inet_pton ( $ this -> _remoteAddr ) : $ this -> _remoteAddr ; }
Retrieve Client Remote Address
53,558
private function ip_is_private ( $ ip ) { $ privateAddresses = [ '10.0.0.0|10.255.255.255' , '172.16.0.0|172.31.255.255' , '192.168.0.0|192.168.255.255' , '169.254.0.0|169.254.255.255' , '127.0.0.0|127.255.255.255' ] ; $ long_ip = ip2long ( $ ip ) ; if ( $ long_ip != - 1 ) { foreach ( $ privateAddresses as $ pri_addr ) { list ( $ start , $ end ) = explode ( '|' , $ pri_addr ) ; if ( $ long_ip >= ip2long ( $ start ) && $ long_ip <= ip2long ( $ end ) ) { return true ; } } } return false ; }
Determine if IP Address is of a private subnet
53,559
public function attributes ( array $ attr ) { $ attr_string = '' ; foreach ( $ attr as $ name => $ value ) { if ( is_array ( $ value ) ) { $ attr_string .= ' ' . $ name . '="' . implode ( ' ' , $ value ) . '"' ; } else { $ attr_string .= ' ' . $ name . '="' . $ value . '"' ; } } return $ attr_string ; }
This function builds attributes for html elements ex . id = name .
53,560
public function getInputType ( $ input , $ old_input = null , $ edit = false ) { $ input = ! empty ( $ old_input ) ? $ old_input : $ input ; if ( ( stripos ( $ input , 'id' ) !== false | stripos ( $ input , '_id' ) !== false ) & stripos ( $ input , 'uuid' ) === false ) { return 'relationship' ; } elseif ( ( stripos ( $ input , 'number' ) !== false & ( stripos ( $ input , 'home_' ) === false & stripos ( $ input , 'fax_' ) === false & stripos ( $ input , 'recorder_' ) === false & stripos ( $ input , 'direct_' ) === false & stripos ( $ input , 'cell_' ) === false & stripos ( $ input , 'model' ) === false & stripos ( $ input , 'phone' ) === false ) ) | ( stripos ( $ input , 'count' ) !== false & stripos ( $ input , 'county' ) === false ) | stripos ( $ input , 'percent' ) !== false ) { return 'number' ; } elseif ( stripos ( $ input , 'date' ) !== false | stripos ( $ input , '_date' ) !== false | stripos ( $ input , 'start' ) !== false | stripos ( $ input , 'finish' ) !== false ) { return 'date' ; } elseif ( stripos ( $ input , 'is_' ) !== false || stripos ( $ input , 'can_' ) !== false || stripos ( $ input , 'has_' ) !== false ) { return 'select' ; } elseif ( stripos ( $ input , 'password' ) !== false ) { return 'password' ; } elseif ( stripos ( $ input , 'email' ) !== false & stripos ( $ input , 'list' ) === false ) { return 'email' ; } elseif ( stripos ( $ input , 'path' ) !== false ) { return 'file' ; } else { return 'text' ; } }
This function uses naming conventions to determine what a fillable attribute might be .
53,561
public function getRelationalDataAndModels ( $ model , $ desired_relation ) { $ relation = $ this -> trimCommonRelationEndings ( $ desired_relation ) ; if ( method_exists ( $ model , $ relation ) ) { return $ this -> getResolvedRelationship ( $ model , $ relation ) ; } elseif ( method_exists ( $ model , $ relation . 's' ) ) { return $ this -> getResolvedRelationship ( $ model , $ relation . 's' ) ; } elseif ( method_exists ( $ model , $ relation . 's' ) ) { return $ this -> getResolvedRelationship ( $ model , $ relation . 's' ) ; } }
This should get the realtions of the given model and .
53,562
protected function getResolvedRelationship ( $ model , $ desired_relation , $ singleRelations = [ BelongsTo :: class , HasOne :: class , MorphTo :: class , MorphOne :: class , ] , $ multiRelations = [ HasMany :: class , BelongsToMany :: class , MorphMany :: class , MorphToMany :: class , ] ) { $ relation_class = get_class ( $ model -> $ desired_relation ( ) ) ; if ( $ this -> in_array ( $ relation_class , $ singleRelations ) ) { return collect ( [ $ model -> $ desired_relation ] ) ; } elseif ( $ this -> in_array ( $ relation_class , $ multiRelations ) ) { return $ model -> $ desired_relation ; } elseif ( method_exists ( $ model -> $ desired_relation ( ) , 'getRelated' ) ) { $ desired_class = get_class ( $ model -> $ desired_relation ( ) -> getRelated ( ) ) ; $ closure = config ( 'kregel.formmodel.resolved_relationship' ) ; if ( ! empty ( $ desired_class ) ) { return $ closure ( $ desired_class ) ; } } return collect ( [ ] ) ; }
This will see if the desired relation is a relation .
53,563
protected function in_array ( $ needle , $ haystack ) { return count ( array_filter ( $ haystack , function ( $ hay ) use ( $ needle ) { return $ hay === $ needle ; } ) ) > 0 ; }
Check if an item is actually in an array .
53,564
public function spitOutHtmlForModelInputToConsume ( $ type , $ input ) { if ( $ type === 'select' ) { return $ this -> select ( [ 'default_text' => 'Please select a ' . trim ( $ input , '_id' ) , 'type' => $ type , 'name' => $ input , ] , [ false => 'No' , true => 'Yes' , ] ) ; } elseif ( in_array ( $ type , [ 'text' , 'file' , 'password' , 'email' , 'date' , 'number' ] ) ) { return $ this -> input ( [ 'type' => $ type , 'name' => $ input , 'class' => 'form-control' , 'id' => $ this -> genId ( $ input ) , 'value' => ! method_exists ( $ this -> model , $ input ) && in_array ( $ input , $ this -> model -> getFillable ( ) ) ? $ this -> model -> $ input : '' ] ) ; } return $ this -> textarea ( [ 'type' => $ type , 'name' => $ input , 'id' => $ this -> genId ( $ input ) ] , ( ! empty ( $ this -> model -> $ input ) && ! ( stripos ( $ input , 'password' ) !== false ) ) ? $ this -> model -> $ input : '' ) ; }
This should ...
53,565
public function setName ( $ sName ) { if ( ! empty ( $ sName ) ) { if ( ! is_numeric ( $ sName ) ) { @ session_name ( $ sName ) ; } else { throw new Exception ( 'The session name can\'t consist only of digits, ' . 'at least one letter must be presented.' ) ; } } else { throw new Exception ( 'Empty session name value was passed.' ) ; } }
The method sets the name of current session .
53,566
public function start ( $ sSessName = null , $ iSess = null ) { if ( ! $ this -> isStarted ( ) ) { if ( ! is_null ( $ sSessName ) ) { $ this -> setName ( $ sSessName ) ; } @ session_start ( $ iSess ) ; } ; return $ this -> getId ( ) ; }
It inits the data of new session or continues the current session .
53,567
public function getAll ( ) { $ aRes = array ( ) ; foreach ( $ this -> getKeys ( ) as $ sKey ) { $ aRes [ $ sKey ] = $ this -> get ( $ sKey ) ; } return $ aRes ; }
It returns all session variables as associative array .
53,568
public function remove ( $ sKey ) { if ( $ this -> contains ( $ sKey ) ) { $ mRes = $ _SESSION [ $ sKey ] ; unset ( $ _SESSION [ $ sKey ] ) ; return $ mRes ; } else { return null ; } }
It removes the variable of session by passed key .
53,569
public function removeAll ( ) { $ aRes = array ( ) ; foreach ( $ this -> getKeys ( ) as $ sKey ) { $ aRes [ $ sKey ] = $ this -> remove ( $ sKey ) ; } return $ aRes ; }
It clears the session by removing all stored variables .
53,570
public function getStorePath ( ) { if ( is_null ( $ this -> _storePath ) ) { $ this -> _storePath = $ this -> _organizer -> getUploadStorePath ( ) ; } return $ this -> _storePath ; }
generate file path in time
53,571
public function getExtensions ( $ key ) { if ( $ this -> extensions -> has ( $ key ) ) { return $ this -> extensions -> get ( $ key ) ; } return [ ] ; }
Returns the extension for the given key
53,572
public function getExtensionsByPackage ( $ key , $ packageName ) { if ( $ this -> packages -> has ( $ packageName ) ) { $ pkg = $ this -> packages -> get ( $ packageName ) ; if ( $ pkg -> has ( $ key ) ) { return $ pkg -> get ( $ key ) ; } } return [ ] ; }
Returns the extension for the given key by a given packageName
53,573
public function optionExpectsValue ( $ key ) { $ spec_data = $ this -> getOptionDataByOptionKey ( ) ; if ( ! isset ( $ spec_data [ $ key ] ) ) { return false ; } return strlen ( $ spec_data [ $ key ] [ 'value_name' ] ) ? true : false ; }
returns true if the option expects a value
53,574
public function normalizeOptionName ( $ key ) { if ( $ key === null ) { return null ; } $ map = $ this -> getNormAlizedOptiOnnameMap ( ) ; return isset ( $ map [ $ key ] ) ? $ map [ $ key ] : null ; }
returns the normalized option name
53,575
protected function getOptionDataByOptionKey ( ) { if ( ! isset ( $ this -> option_data_by_name ) ) { $ this -> option_data_by_name = array ( ) ; foreach ( $ this -> argument_spec_data [ 'options' ] as $ argument_spec ) { if ( strlen ( $ argument_spec [ 'short' ] ) ) { $ this -> option_data_by_name [ $ argument_spec [ 'short' ] ] = $ argument_spec ; } if ( strlen ( $ argument_spec [ 'long' ] ) ) { $ this -> option_data_by_name [ $ argument_spec [ 'long' ] ] = $ argument_spec ; } } } return $ this -> option_data_by_name ; }
returns options data mapped to both the long and short option name
53,576
protected function getNormalizedOptionNameMap ( ) { if ( ! isset ( $ this -> normalized_option_name_map ) ) { $ this -> normalized_option_name_map = array ( ) ; foreach ( $ this -> argument_spec_data [ 'options' ] as $ argument_spec ) { $ long_name = $ argument_spec [ 'long' ] ; if ( strlen ( $ long_name ) ) { $ this -> normalized_option_name_map [ $ long_name ] = $ long_name ; } else { $ long_name = null ; } $ short_name = $ argument_spec [ 'short' ] ; if ( strlen ( $ short_name ) ) { $ this -> normalized_option_name_map [ $ short_name ] = ( strlen ( $ long_name ) ? $ long_name : $ short_name ) ; } } } return $ this -> normalized_option_name_map ; }
builds option names mapped to their normalized name
53,577
protected function maybeRender ( $ content ) { if ( $ content instanceof ViewModel ) { $ content = $ this -> getView ( ) -> render ( $ content ) ; } return ( string ) $ content ; }
Renders a given ViewModel or passes the argument verbatim
53,578
protected function getDataAttributes ( ) { $ ret = array ( ) ; $ properties = array ( 'backdrop' , 'keyboard' , 'show' , 'remote' , ) ; foreach ( $ properties as $ property ) { $ value = $ this -> { 'get' . $ property } ( ) ; if ( $ value ) { $ ret [ 'data-' . $ property ] = $ value ; } } return $ ret ; }
Returns data attributes from options
53,579
public function getPaginatedRoutes ( $ sort = 'name' , $ perPage = null ) { return $ this -> paginate ( $ this -> getAllRoutes ( $ sort ) , $ perPage ) ; }
Get paginated Routes .
53,580
public function paginate ( $ items , $ perPage = null , $ pageName = 'page' , $ page = null ) { if ( is_array ( $ items ) ) { $ items = collect ( $ items ) ; } $ page = $ page ? : Paginator :: resolveCurrentPage ( $ pageName ) ; $ perPage = $ perPage ? : $ items [ 0 ] -> getPerPage ( ) ; $ results = $ items -> forPage ( Paginator :: resolveCurrentPage ( ) , $ perPage ) ; $ total = $ items -> count ( ) ; return new LengthAwarePaginator ( $ results , $ total , $ perPage , $ page , [ 'path' => Paginator :: resolveCurrentPath ( ) , 'pageName' => $ pageName , ] ) ; }
Paginate a laravel colletion or array of items .
53,581
public function addOption ( string $ value , string $ text ) : FormElement { $ this -> options [ $ value ] = $ text ; return $ this ; }
Add a single value to the list .
53,582
public function addBlankOption ( bool $ disabled = false ) : Select { $ this -> addBlank = true ; if ( $ disabled ) $ this -> disabled [ ] = '' ; return $ this ; }
Force a blank option to be added at the top of the pulldown . Optionally pass true to cause that option to not be selectable .
53,583
public function validate ( ) : void { if ( null === $ this -> is_valid ) { if ( null === $ this -> user_value && null !== $ this -> default_value ) { $ this -> is_valid = true ; } elseif ( in_array ( $ this -> user_value , array_keys ( $ this -> options ) ) && ! in_array ( $ this -> user_value , $ this -> disabled ) ) { $ this -> is_valid = true ; } elseif ( '' == $ this -> user_value && $ this -> addBlank && ! in_array ( '' , $ this -> disabled ) ) { $ this -> is_valid = true ; } elseif ( false == $ this -> validator ) { $ this -> is_valid = true ; } else { $ this -> is_valid = false ; $ this -> error = 'The provided value is not valid. Please enter a valid value.' ; } } if ( $ this -> is_valid && null !== $ this -> user_value ) { $ this -> is_changed = ( $ this -> default_value != $ this -> user_value ) ; } }
Overrides the normal validation to instead make sure the value passed is a value that has been set and the value is not disabled .
53,584
public function outputValue ( ) : string { if ( isset ( $ this -> options [ $ this -> getValue ( ) ] ) ) { return '<span class="uneditable-field">' . $ this -> options [ $ this -> getValue ( ) ] . '</span>' ; } else { return '<span class="uneditable-field">' . $ this -> getValue ( ) . '</span>' ; } }
If the field is set to not be editable this will output the value of the form element instead of a form field .
53,585
public static function toCamelCase ( $ str , $ firstInLowerCase = false ) { $ str = str_replace ( " " , "" , ucwords ( str_replace ( "_" , " " , $ str ) ) ) ; return $ firstInLowerCase ? lcfirst ( $ str ) : $ str ; }
Converts a underscored string to CamelCase
53,586
public function addRouteProvider ( RouteProvider $ provider ) { foreach ( $ provider -> routes ( ) as $ route ) { $ this -> add ( $ route ) ; } }
Registers a new route provider to feed new routes
53,587
public function addPattern ( string $ name , string $ regexp ) { $ this -> regexp_map = [ '/\{(\w+):' . $ name . '\}/' => '(?<$1>' . $ regexp . ')' ] + $ this -> regexp_map ; }
Registers a matching pattern for URI parameters .
53,588
public function findURI ( string $ name , array $ parameters = [ ] ) { if ( array_key_exists ( $ name , $ this -> route_names ) ) { $ foundUri = $ this -> route_names [ $ name ] ; foreach ( $ parameters as $ parameter => $ value ) { $ foundUri = preg_replace ( "/\{(" . $ parameter . ")(\:\w+)?\}/i" , $ value , $ foundUri ) ; } return $ foundUri ; } return null ; }
Finds the uri associated with a given name .
53,589
public function parse ( string $ method , string $ uri , string $ prefix = "" ) : ParsedRoute { $ uri = trim ( explode ( "?" , $ uri ) [ 0 ] ) ; if ( $ prefix !== "" && substr ( $ prefix , 0 , 1 ) !== "/" ) { $ prefix = "/" . $ prefix ; } try { return $ this -> findMatches ( $ method , $ uri , $ prefix ) ; } catch ( RouteNotFoundException $ e ) { $ allowed_methods = [ ] ; foreach ( $ this -> routes as $ available_method => $ routes ) { try { $ this -> findMatches ( $ available_method , $ uri , $ prefix ) ; $ allowed_methods [ ] = $ available_method ; } catch ( RouteNotFoundException $ e ) { } } if ( count ( $ allowed_methods ) ) { throw new MethodNotAllowedException ( implode ( ", " , $ allowed_methods ) ) ; } throw new RouteNotFoundException ( "No route for '{$uri}' found" ) ; } }
Parses an incoming method and URI and returns a matching route .
53,590
private function findMatches ( string $ method , string $ uri , string $ prefix = "" ) : ParsedRoute { if ( isset ( $ this -> routes [ strtoupper ( $ method ) ] ) ) { foreach ( array_keys ( $ this -> routes [ strtoupper ( $ method ) ] ) as $ route ) { $ parsed_regexp = $ this -> prepareRouteRegexp ( $ prefix . $ route ) ; if ( preg_match_all ( "/^" . $ parsed_regexp . ( $ this -> trailing_slash_check ? "" : "\/?" ) . "$/i" , $ uri , $ matches , PREG_SET_ORDER ) ) { if ( count ( $ matches ) ) { $ matches = array_diff_key ( $ matches [ 0 ] , range ( 0 , count ( $ matches [ 0 ] ) ) ) ; } return new ParsedRoute ( $ this -> routes [ strtoupper ( $ method ) ] [ $ route ] , $ matches ) ; } } } throw new RouteNotFoundException ( "No route for '{$uri}' found" ) ; }
Finds the first matching route for a given method and URI .
53,591
private function prepareRouteRegexp ( string $ route ) : string { if ( ! array_key_exists ( $ route , self :: $ parsed_regexp ) ) { self :: $ parsed_regexp [ $ route ] = preg_replace ( array_keys ( $ this -> regexp_map ) , array_values ( $ this -> regexp_map ) , $ route ) ; } return self :: $ parsed_regexp [ $ route ] ; }
Applies standard regexp patterns to an incoming URI route .
53,592
public static function clean ( $ filename = null ) { static :: filename ( $ filename ) ; static :: $ description = static :: $ keywords = static :: $ title = static :: $ jsTextOnReady = '' ; static :: $ css = static :: $ js = static :: $ jsText = static :: $ jsMgr = [ ] ; }
Cleans up all layout variables & resets filename if specified .
53,593
public static function og ( string $ property , string $ value = null ) { return $ value !== null ? static :: $ openGraph [ $ property ] = $ value : ( static :: $ openGraph [ $ property ] ?? null ) ; }
Sets or gets layout OpenGraph property .
53,594
protected static function assembleTemplateVars ( $ content ) { $ layoutTplVars = [ 'content' => $ content , 'keywords' => static :: eWrap ( static :: $ keywords , "<meta name='keywords' content='%s' />\n" ) , 'title' => static :: eWrap ( static :: $ title , "<title>%s</title>\n" ) , 'description' => static :: eWrap ( static :: $ description , "<meta name='description' content='%s'/>\n" ) , 'opengraph' => static :: assembleOpenGraph ( ) , 'css' => static :: concatWrapped ( static :: $ css , '<link type="text/css" rel="stylesheet" href="%s"/>' . "\n\t" ) , 'javascript' => static :: concatWrapped ( static :: $ js , '<script type="text/javascript" src="%s"></script>' . "\n\t" ) , ] ; if ( count ( static :: $ jsMgr ) ) { static :: addJsTextOnReady ( static :: concatWrapped ( static :: $ jsMgr , " new %s_mgr();\n" ) ) ; } if ( static :: $ jsTextOnReady != '' ) { static :: addJsText ( "$(document).ready(function(){\n" . static :: $ jsTextOnReady . '});' ) ; } $ layoutTplVars [ 'javascript' ] .= static :: concatWrapped ( static :: $ jsText , "<script type=\"text/javascript\">%s</script>\n" ) ; return $ layoutTplVars + static :: $ userVars ; }
Prepare and assemble all variables for Layout PhpTemplate .
53,595
protected static function assembleOpenGraph ( ) { $ meta = [ ] ; foreach ( static :: $ openGraph as $ key => $ value ) { $ meta [ ] = "<meta property='og:$key' content='" . Html :: e ( $ value ) . "' />" ; } return implode ( "\n\t" , $ meta ) . "\n" ; }
Assemble OpenGraph properties into html meta tags .
53,596
protected static function compileWith ( array $ layoutTplVars ) { if ( static :: $ filename === null ) { throw new \ Exception ( 'Layout template file name does not set: use Layout::setFilename().' ) ; } $ tpl = new PhpTemplate ( VIEWS . static :: $ filename ) ; $ tpl -> vars = $ layoutTplVars ; $ compiledHtml = $ tpl -> compile ( ) ; foreach ( $ layoutTplVars as $ key => $ value ) { $ compiledHtml = str_replace ( '{' . $ key . '}' , $ value , $ compiledHtml ) ; } return $ compiledHtml ; }
Compiles layout template with given variables .
53,597
public function Connect ( ) { if ( $ this -> dev ) { $ this -> log [ ] = 'Connection Attempt' ; } if ( $ this -> _stream === FALSE ) { $ this -> _stream = stream_socket_client ( $ this -> url . ':' . $ this -> port , $ this -> errorCode , $ this -> errorMessage , $ this -> timeout ) ; if ( $ this -> _stream === FALSE ) { if ( $ this -> dev ) { $ this -> log [ ] = 'Cannot to connect to ' . $ this -> url . ':' . $ this -> port ; } $ this -> Error ( 'The stream could not connect: #' . $ this -> errorCode . ' - ' . $ this -> errorMessage ) ; return ; } else if ( $ this -> dev ) { $ this -> log [ ] = 'Connected to ' . $ this -> url . ':' . $ this -> port ; } stream_set_blocking ( $ this -> _stream , 1 ) ; } else { if ( $ this -> dev ) { $ this -> log [ ] = 'Cannot to connect to ' . $ this -> url . ':' . $ this -> port ; } $ this -> Error ( 'The stream is already connected!' ) ; } }
Connect to a stream
53,598
public function Send ( $ data , $ reply = FALSE ) { if ( $ this -> _stream === FALSE ) { $ this -> Error ( 'Cannot send data, the stream is not connected!' ) ; return FALSE ; } if ( is_array ( $ data ) ) { if ( $ this -> dev ) { $ this -> log [ ] = 'Send data array:' ; } foreach ( $ data as $ val ) { if ( $ this -> dev ) { $ this -> log [ ] = $ val ; } $ send = stream_socket_sendto ( $ this -> _stream , $ val . "\r\n" ) ; if ( $ send === FALSE ) { $ this -> Error ( 'Error sending data: #' . $ this -> errorCode . ' - ' . $ this -> errorMessage ) ; $ this -> Close ( ) ; return FALSE ; } } } else { if ( $ this -> dev ) { $ this -> log [ ] = 'Send: ' . $ data ; } $ send = stream_socket_sendto ( $ this -> _stream , $ data . "\r\n" ) ; if ( $ send === FALSE ) { $ this -> Error ( 'Error sending data: #' . $ this -> errorCode . ' - ' . $ this -> errorMessage ) ; $ this -> Close ( ) ; return FALSE ; } } if ( $ reply !== FALSE ) { return $ this -> Receive ( $ reply ) ; } return TRUE ; }
Send data through a stream
53,599
public function Receive ( $ reply = FALSE ) { if ( $ this -> _stream === FALSE ) { $ this -> Error ( 'Cannot receive data, the stream is not connected!' ) ; return FALSE ; } $ recv = NULL ; while ( TRUE ) { $ recv .= stream_socket_recvfrom ( $ this -> _stream , 4096 ) ; if ( strstr ( $ recv , "\r\n" ) ) { break ; } } if ( $ this -> dev ) { $ this -> log [ ] = 'Received data: ' . trim ( $ recv ) ; } if ( $ reply !== FALSE ) { $ replyCode = substr ( $ recv , 0 , 3 ) ; if ( is_array ( $ reply ) ) { if ( ! in_array ( $ replyCode , $ reply ) ) { $ this -> Error ( 'Invalid response: ' . $ replyCode ) ; return FALSE ; } } else { if ( $ replyCode != $ reply ) { $ this -> Error ( 'Invalid response: ' . $ replyCode ) ; return FALSE ; } } if ( $ this -> dev ) { $ this -> log [ ] = 'Expected Response: ' . $ replyCode ; } } return TRUE ; }
Receive data through a stream