idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
22,100
public function getParams ( $ filename = "" ) { if ( empty ( $ filename ) ) { return $ this -> namespace ; } elseif ( ! empty ( $ filename ) && isset ( $ this -> namespace [ $ filename ] ) ) { return $ this -> namespace [ $ filename ] ; } else { return array ( ) ; } }
Returns the read ini file parameters
22,101
public static function toIniString ( $ params = array ( ) , $ section = NULL ) { $ _br = "\n" ; $ _tab = NULL ; $ _globals = ! empty ( $ section ) ? "\n[" . $ section . "]\n" : '' ; foreach ( $ params as $ param => $ value ) { if ( ! is_array ( $ value ) ) { $ value = static :: normalizeValue ( $ value ) ; $ _globals .= $ _tab . $ param . ' = ' . ( Validate :: isAlphaNumeric ( $ value ) ? $ value : '"' . $ value . '"' ) . $ _br ; } } return $ _globals ; }
Converts a config array of elements to an ini string
22,102
protected static function normalizeValue ( $ value ) { if ( is_bool ( $ value ) ) { $ value = ( bool ) $ value ; return $ value ; } elseif ( is_numeric ( $ value ) ) { return ( int ) $ value ; } return $ value ; }
normalize a Value by determining the Type
22,103
public function select ( $ columns = "*" ) { $ this -> start = $ columns ; $ this -> queryType = self :: QUERY_SELECT ; return $ this ; }
Fake select method used to maximize compatibility
22,104
public function insert ( $ table = "" ) { $ this -> start = "" ; $ this -> queryType = self :: QUERY_INSERT ; $ this -> into ( $ table ) ; return $ this ; }
Start insert mode
22,105
public function into ( $ table = "" ) { if ( empty ( $ table ) ) { $ table = $ this -> structure -> tableName ; } $ this -> table = $ table ; $ this -> queryType = self :: QUERY_INSERT ; $ this -> columnOrder = array ( ) ; foreach ( $ this -> structure -> columns as $ column ) { $ this -> columnOrder [ ] = $ column ; } return $ this ; }
Insert into table
22,106
public function delete ( $ table = "" ) { if ( empty ( $ table ) ) { $ table = $ this -> structure -> tableName ; } $ this -> table = $ table ; $ this -> queryType = self :: QUERY_DELETE ; return $ this ; }
Set mode to Delete
22,107
public function custom ( $ sql , $ bind = array ( ) ) { $ query = ConnectionManager :: getConnection ( ) -> prepare ( $ sql ) ; if ( count ( $ bind ) > 0 ) { $ numericBinding = true ; foreach ( $ bind as $ key => $ value ) { if ( is_int ( $ key ) ) { continue ; } else { $ numericBinding = false ; if ( substr ( $ key , 0 , 1 ) !== ':' ) { throw new QueryException ( "When binding, you should use numeric keys or keys with : before each key to identify the binding place in the query!" ) ; } } } $ idx = 1 ; foreach ( $ bind as $ key => $ value ) { if ( $ numericBinding ) { if ( is_int ( $ value ) ) { $ type = \ PDO :: PARAM_INT ; } elseif ( is_bool ( $ value ) ) { $ type = \ PDO :: PARAM_BOOL ; } else { $ type = \ PDO :: PARAM_STR ; } $ query -> bindValue ( $ idx , $ value , $ type ) ; } else { $ query -> bindValue ( $ key , $ value ) ; } } } $ query -> setFetchMode ( \ PDO :: FETCH_CLASS , $ this -> class ) ; $ query -> execute ( ) ; return $ this -> injectState ( $ query -> fetchAll ( ) ) ; }
Execute custom query .
22,108
public function set ( $ data ) { if ( $ this -> queryType !== self :: QUERY_INSERT && $ this -> queryType !== self :: QUERY_UPDATE ) { $ this -> exception = new QueryException ( "When using set/data you must do a insert into or update first! Query is not in UPDATE or INSERT mode!" , 0 , $ this -> exception ) ; return $ this ; } if ( ! is_array ( $ data ) ) { $ this -> exception = new QueryException ( "set()/data() must have an array data parameter!" , 0 , $ this -> exception ) ; return $ this ; } $ this -> data = "" ; $ this -> changeData = array ( ) ; foreach ( $ this -> columnOrder as $ currentColumn ) { if ( $ this -> queryType === self :: QUERY_INSERT ) { if ( ! $ currentColumn -> null && ! $ currentColumn -> autoIncrement ) { if ( ! isset ( $ data [ $ currentColumn -> name ] ) ) { $ this -> exception = new QueryException ( "Inserting data failed, data must contain all non-null columns defined in the entity!" , 0 , $ this -> exception ) ; return $ this ; } } } if ( $ this -> queryType === self :: QUERY_UPDATE && $ currentColumn -> primary ) { continue ; } if ( isset ( $ data [ $ currentColumn -> name ] ) ) { $ value = $ data [ $ currentColumn -> name ] ; $ this -> changeData [ $ currentColumn -> name ] = $ value ; } else { $ this -> changeData [ $ currentColumn -> name ] = null ; } } return $ this ; }
Set data for inserting or updating
22,109
public function offset ( $ offset ) { if ( $ this -> queryType !== self :: QUERY_SELECT ) { $ this -> exception = new QueryException ( "Offset can only be applied on SELECT mode!" , 0 , $ this -> exception ) ; return $ this ; } if ( ! is_int ( $ offset ) || $ offset < 0 ) { $ this -> exception = new QueryException ( "Offset value should be an positive integer!" , 0 , $ this -> exception ) ; return $ this ; } $ this -> limitOffset = intval ( $ offset ) ; return $ this ; }
Offset the results
22,110
public function sort ( $ column , $ type = 'ASC' ) { if ( $ this -> queryType !== self :: QUERY_SELECT ) { $ this -> exception = new QueryException ( "Sorting can only be applied on SELECT mode!" , 0 , $ this -> exception ) ; return $ this ; } $ type = strtoupper ( $ type ) ; if ( ! is_string ( $ column ) ) { $ this -> exception = new QueryException ( "Sorting column must be an string!" , 0 , $ this -> exception ) ; } if ( ! $ this -> validOrderType ( $ type ) ) { $ this -> exception = new QueryException ( "Sorting requires a type that is either 'ASC' or 'DESC'!" , 0 , $ this -> exception ) ; return $ this ; } if ( in_array ( $ column , $ this -> structure -> columnNames ) ) { $ this -> sortBy = $ column ; $ this -> sortOrder = $ type ; } return $ this ; }
Sort by column value Ascending or descending
22,111
public function all ( ) { if ( $ this -> exception !== null ) { throw $ this -> exception ; } return $ this -> fetch ( true , $ this -> fetchAssoc ) ; }
Execute Query and fetch all records as entities
22,112
public function one ( ) { if ( $ this -> exception !== null ) { throw $ this -> exception ; } return $ this -> fetch ( false , $ this -> fetchAssoc ) ; }
Execute Query and fetch a single record as entity
22,113
private function validValue ( $ value , $ operator ) { if ( ! $ this -> validOperator ( $ operator ) ) { return false ; } if ( $ operator === "IN" ) { return is_array ( $ value ) ; } if ( $ operator === "IS NOT" ) { return is_null ( $ value ) ; } return ! is_array ( $ value ) ; }
Validate value for given operator
22,114
public function __isset ( $ name ) { if ( ! in_array ( $ name , $ this -> allowedFields ) ) { throw new \ InvalidArgumentException ( "The field '$name' is not allowed for this entity." ) ; } return isset ( $ this -> values [ $ name ] ) ; }
Check if the specified field has been assigned to the entity
22,115
public function send ( $ value = null ) { if ( ! $ this -> generator ) { $ this -> rewind ( ) ; } return $ this -> generator -> send ( $ value ) ; }
Sends a value to the generator
22,116
public function build ( ) { $ tokenParsers = [ ] ; $ executionStrategies = [ ] ; $ functions = [ ] ; foreach ( $ this -> extensions as $ extension ) { $ tokenParsers = array_merge ( $ tokenParsers , $ extension -> getTokenParsers ( ) ) ; $ executionStrategies = array_merge ( $ executionStrategies , $ extension -> getExecutionStrategies ( ) ) ; $ functions = array_merge ( $ functions , $ extension -> getFunctions ( ) ) ; } $ registry = new Registry ( $ tokenParsers , [ ] , [ ] , '<{' , '}>' ) ; $ this -> syntax = new Syntax ( new Lexer ( new TemplateLexer ( $ registry ) ) , new Parser ( new TemplateParser ( $ registry ) ) ) ; $ this -> executionStrategies = new ExecutionStrategyCollection ( $ executionStrategies ) ; $ this -> environment = new Environment ( $ functions ) ; $ this -> isLocked = true ; }
Builds the Engine .
22,117
private function loadLayerAndCheck ( $ path , array $ stack ) { if ( in_array ( $ path , $ stack ) ) { throw new LogicException ( sprintf ( 'Circular reference detected:' . PHP_EOL . ' - file: %s' . PHP_EOL . ' - load: %s then crash' , implode ( PHP_EOL . ' - load: ' , $ stack ) , $ path ) ) ; } $ metadata = unserialize ( file_get_contents ( $ this -> getMetaFilename ( $ path ) ) ) ; $ pgVersion = $ this -> connection -> getVersion ( ) ; $ cmpVersion = $ metadata -> getSupport ( ) ; if ( version_compare ( $ pgVersion , $ cmpVersion , '<' ) ) { throw new LogicException ( sprintf ( 'The current version of PostgreSQL is "%s" and the DAL "%s" requires a minimum version of "%s"' , $ pgVersion , $ path , $ cmpVersion ) ) ; } $ stack [ ] = $ path ; $ this -> graphNodes [ $ path ] = $ graphNode = new GraphNode ( ) ; $ mapper = new HierarchicalMapper ( $ graphNode ) ; $ mapper -> setType ( '#' , new FragmentConverter ( ) ) ; $ blueprint = new HierarchicalBlueprint ( $ graphNode , $ this -> connection , $ mapper , $ this -> executionStrategies , $ this -> environment ) ; foreach ( $ metadata -> getImports ( ) as $ import => $ map ) { $ this -> doLoad ( $ import , $ stack ) ; $ graphNode -> import ( $ this -> graphNodes [ $ import ] , $ map ) ; } return $ this -> loadLayer ( $ this -> getFilename ( $ path ) , $ mapper , $ blueprint ) ; }
Loads the DAL for the given path and do some check about the supported version of the loaded files and that there is no circular references between them .
22,118
public function on ( $ class ) { $ this -> instance = is_string ( $ class ) ? $ this -> container !== null ? $ this -> container -> make ( $ class ) : new $ class : $ class ; return $ this ; }
Specify Class or Class Instance to chain methods on .
22,119
public function run ( ) { if ( $ this -> requires !== null && ! $ this -> instance instanceof $ this -> requires ) { throw new WrongClassException ( get_class ( $ this -> instance ) , $ this -> requires ) ; } return array_reduce ( $ this -> methods , function ( $ results , $ method ) { if ( ! method_exists ( $ this -> instance , $ method ) && ! $ this -> forgiving ) { throw new InvalidMethodException ( get_class ( $ this -> instance ) , $ method ) ; } $ results -> addResult ( $ method , call_user_func_array ( [ $ this -> instance , $ method ] , $ this -> parameters ) ) ; return $ results ; } , new Results ( ) ) -> done ( ) ; }
Run the Chain of methods on the Class .
22,120
public static function isRoman ( string $ str ) : bool { $ str = strtoupper ( Parser :: replaceRoman ( $ str ) ) ; $ ary = Parser :: strToArray ( $ str ) ; $ result = true ; foreach ( $ ary as $ key => $ value ) { $ code = Mbstring :: mb_ord ( $ value ) ; if ( $ code >= 97 && 122 ) { $ value = strtoupper ( $ value ) ; } if ( array_key_exists ( $ value , self :: $ romans ) ) { continue ; } else { $ result = false ; break ; } } if ( $ result ) { foreach ( self :: $ romans as $ key => $ value ) { while ( mb_strpos ( $ str , $ key ) === 0 ) { $ str = mb_substr ( $ str , strlen ( $ key ) ) ; } } $ result = mb_strlen ( $ str ) === 0 ; } return $ result ; }
validate that string is roman numerals
22,121
public function setLifetime ( $ lifetime , $ overrideLifetime = null ) { if ( $ lifetime < 0 ) { throw new \ Zend_Session_SaveHandler_Exception ( '$lifetime must be greater than 0.' ) ; } else if ( empty ( $ lifetime ) ) { $ this -> lifetime = ( int ) ini_get ( 'session.gc_maxlifetime' ) ; } else { $ this -> lifetime = ( int ) $ lifetime ; } if ( $ overrideLifetime != null ) { $ this -> setOverrideLifetime ( $ overrideLifetime ) ; } return $ this ; }
Set session lifetime and optional whether or not the lifetime of an existing session should be overridden
22,122
static public function connect ( \ Memcache $ Memcache , $ host , $ port = 11211 , $ persistent = true ) { $ host = ( string ) $ host ; $ port = ( int ) $ port ; if ( $ persistent ) { $ result = @ $ Memcache -> pconnect ( $ host , $ port ) ; } else { $ result = @ $ Memcache -> connect ( $ host , $ port ) ; } if ( $ result && self :: COMPRESS_THRESHOLD > 0 ) { $ compress = @ $ Memcache -> setcompressthreshold ( self :: COMPRESS_THRESHOLD , self :: COMPRESS_SAVINGS ) ; assert ( '$compress !== false' ) ; } return $ result ; }
Connect a Memcache - instance .
22,123
static public function isConnected ( \ Memcache $ Memcache ) { $ version = @ $ Memcache -> getVersion ( ) ; if ( $ version === false ) { return false ; } return true ; }
Check if the provided Memcache - instance is connected .
22,124
protected function setTarget ( $ target ) { if ( '*' == $ target ) { $ this -> target = $ target ; return $ this ; } if ( is_string ( $ target ) ) { $ target = new Uri ( $ target ) ; } if ( ! $ target instanceof UriInterface ) { throw new InvalidArgumentException ( sprintf ( 'Invalid target provided; must be an string or instance of ' . '"%s", "%s" received.' , 'Psr\\Http\\Message\\UriInterface' , is_object ( $ target ) ? get_class ( $ target ) : gettype ( $ target ) ) ) ; } $ this -> target = ( string ) $ target -> withFragment ( '' ) ; return $ this ; }
Sets the request HTTP target .
22,125
protected function setUri ( $ uri , $ preserveHost = false ) { if ( is_string ( $ uri ) ) { $ uri = new Uri ( $ uri ) ; } if ( ! $ uri instanceof UriInterface ) { throw new InvalidArgumentException ( sprintf ( 'Invalid URI provided. Must be null, a string, or ' . 'Psr\Http\Message\UriInterface; received "%s".' , is_object ( $ uri ) ? get_class ( $ uri ) : gettype ( $ uri ) ) ) ; } $ this -> uri = $ uri ; if ( $ preserveHost && $ this -> hasHeader ( 'Host' ) ) { return $ this ; } if ( ! $ uri -> getHost ( ) ) { return $ this ; } $ host = $ uri -> getHost ( ) ; if ( $ uri -> getPort ( ) ) { $ host .= ':' . $ uri -> getPort ( ) ; } $ this -> setHeader ( 'Host' , $ host ) ; return $ this ; }
Sets the URI .
22,126
public static function parse ( $ value ) { if ( preg_match ( Name :: PATTERN , $ value ) ) return new Name ( $ value ) ; if ( preg_match ( Text :: PATTERN , $ value ) ) return new Text ( $ value ) ; if ( preg_match ( Color :: PATTERN , $ value ) ) return new Color ( $ value ) ; if ( preg_match ( Measurement :: PATTERN , $ value ) ) return new Measurement ( $ value ) ; throw new \ Exception ( "Invalid Value '$value'" ) ; }
Parses a string into the correct value
22,127
public function receiveToken ( $ consumer_key , $ request_token ) { $ pocketData = $ this -> convertRequestToken ( $ consumer_key , $ request_token ) ; $ access_token = $ pocketData -> access_token ; return $ access_token ; }
Grab an access token from the pocket API after sending it the consumer key and request token from earlier
22,128
public function receiveTokenAndUsername ( $ consumer_key , $ request_token ) { $ pocketData = $ this -> convertRequestToken ( $ consumer_key , $ request_token ) ; $ returnData [ 'access_token' ] = $ pocketData -> access_token ; $ returnData [ 'username' ] = $ pocketData -> username ; return $ returnData ; }
Grab an access token and the username from the pocket API after sending it the consumer key and request token from earlier
22,129
private function convertRequestToken ( $ consumer_key , $ request_token ) { $ params = array ( 'consumer_key' => $ consumer_key , 'code' => $ request_token ) ; $ request = $ this -> getClient ( ) -> post ( '/v3/oauth/authorize' ) ; $ request -> getParams ( ) -> set ( 'redirect.strict' , true ) ; $ request -> setHeader ( 'Content-Type' , 'application/json; charset=UTF8' ) ; $ request -> setHeader ( 'X-Accept' , 'application/json' ) ; $ request -> setBody ( json_encode ( $ params ) ) ; $ response = $ request -> send ( ) ; $ data = json_decode ( $ response -> getBody ( ) ) ; return $ data ; }
Convert a request token into a Pocket access token . We also get the username in the same response from Pocket .
22,130
public function getJson ( $ asArray = false ) { if ( $ this -> isJson ( ) ) return json_decode ( $ this -> getBody ( ) , $ asArray ) ; return null ; }
return json Response
22,131
public function setCreated ( $ val ) { if ( ( $ val instanceof \ DateTime ) ) { $ this -> created = $ val ; } else if ( is_string ( $ val ) && ! empty ( $ val ) ) { try { $ this -> created = new \ DateTime ( $ val ) ; } catch ( \ Exception $ e ) { $ this -> created = null ; } } else { $ this -> created = null ; } return $ this ; }
Set date time when was the project created .
22,132
public function setLogLevel ( $ logLevel ) { if ( is_int ( $ logLevel ) && $ logLevel <= count ( $ this -> loggerTypes ) ) { $ this -> logLevel = $ logLevel ; $ this -> debug ( "Log level was set to: {$this->loggerTypes[$logLevel]->getName()}" ) ; } else { $ this -> warn ( "Invalid Log Level was requested" ) ; } }
Sets the threshold for which log entries should actually get written to the log
22,133
public function join ( $ path , $ select = null ) { $ path = $ this -> getNameInContext ( $ path ) ; $ face = $ this -> getBaseFace ( ) -> getElement ( $ path ) -> getFace ( ) ; $ sqlPath = $ this -> _doFQLTableName ( $ path , "." ) ; $ qJoin = new JoinQueryFace ( $ sqlPath , $ face ) ; if ( null !== $ select ) { $ qJoin -> setColumns ( $ select ) ; } $ this -> addJoin ( $ qJoin ) ; return $ this ; }
add a join clause to the query
22,134
public function where ( $ whereString ) { $ where = new Where \ WhereString ( $ whereString ) ; $ where -> context ( $ this -> getContext ( ) ) ; $ this -> addWhere ( $ where ) ; return $ this ; }
set the where clause
22,135
public function getSessionDriver ( ) { if ( null == $ this -> sessionDriver ) { $ this -> setSessionDriver ( Application :: container ( ) -> get ( 'session' ) ) ; } return $ this -> sessionDriver ; }
Gets Session driver
22,136
public static function autoload ( $ class ) { $ self = self :: getInstance ( ) ; foreach ( $ self -> getClassAutoloaders ( $ class ) as $ autoloader ) { if ( $ autoloader instanceof Zend_Loader_Autoloader_Interface ) { if ( $ autoloader -> autoload ( $ class ) ) { return true ; } } elseif ( is_array ( $ autoloader ) ) { if ( call_user_func ( $ autoloader , $ class ) ) { return true ; } } elseif ( is_string ( $ autoloader ) || is_callable ( $ autoloader ) ) { if ( $ autoloader ( $ class ) ) { return true ; } } } return false ; }
Autoload a class
22,137
public function registerNamespace ( $ namespace ) { if ( is_string ( $ namespace ) ) { $ namespace = ( array ) $ namespace ; } elseif ( ! is_array ( $ namespace ) ) { throw new Zend_Loader_Exception ( 'Invalid namespace provided' ) ; } foreach ( $ namespace as $ ns ) { if ( ! isset ( $ this -> _namespaces [ $ ns ] ) ) { $ this -> _namespaces [ $ ns ] = true ; } } return $ this ; }
Register a namespace to autoload
22,138
public function unregisterNamespace ( $ namespace ) { if ( is_string ( $ namespace ) ) { $ namespace = ( array ) $ namespace ; } elseif ( ! is_array ( $ namespace ) ) { throw new Zend_Loader_Exception ( 'Invalid namespace provided' ) ; } foreach ( $ namespace as $ ns ) { if ( isset ( $ this -> _namespaces [ $ ns ] ) ) { unset ( $ this -> _namespaces [ $ ns ] ) ; } } return $ this ; }
Unload a registered autoload namespace
22,139
public function suppressNotFoundWarnings ( $ flag = null ) { if ( null === $ flag ) { return $ this -> _suppressNotFoundWarnings ; } $ this -> _suppressNotFoundWarnings = ( bool ) $ flag ; return $ this ; }
Get or set the value of the suppress not found warnings flag
22,140
public function getClassAutoloaders ( $ class ) { $ namespace = false ; $ autoloaders = array ( ) ; foreach ( array_keys ( $ this -> _namespaceAutoloaders ) as $ ns ) { if ( '' == $ ns ) { continue ; } if ( 0 === strpos ( $ class , $ ns ) ) { if ( ( false === $ namespace ) || ( strlen ( $ ns ) > strlen ( $ namespace ) ) ) { $ namespace = $ ns ; $ autoloaders = $ this -> getNamespaceAutoloaders ( $ ns ) ; } } } foreach ( $ this -> getRegisteredNamespaces ( ) as $ ns ) { if ( 0 === strpos ( $ class , $ ns ) ) { $ namespace = $ ns ; $ autoloaders [ ] = $ this -> _internalAutoloader ; break ; } } $ autoloadersNonNamespace = $ this -> getNamespaceAutoloaders ( '' ) ; if ( count ( $ autoloadersNonNamespace ) ) { foreach ( $ autoloadersNonNamespace as $ ns ) { $ autoloaders [ ] = $ ns ; } unset ( $ autoloadersNonNamespace ) ; } if ( ! $ namespace && $ this -> isFallbackAutoloader ( ) ) { $ autoloaders [ ] = $ this -> _internalAutoloader ; } return $ autoloaders ; }
Get autoloaders to use when matching class
22,141
public function unshiftAutoloader ( $ callback , $ namespace = '' ) { $ autoloaders = $ this -> getAutoloaders ( ) ; array_unshift ( $ autoloaders , $ callback ) ; $ this -> setAutoloaders ( $ autoloaders ) ; $ namespace = ( array ) $ namespace ; foreach ( $ namespace as $ ns ) { $ autoloaders = $ this -> getNamespaceAutoloaders ( $ ns ) ; array_unshift ( $ autoloaders , $ callback ) ; $ this -> _setNamespaceAutoloaders ( $ autoloaders , $ ns ) ; } return $ this ; }
Add an autoloader to the beginning of the stack
22,142
public function pushAutoloader ( $ callback , $ namespace = '' ) { $ autoloaders = $ this -> getAutoloaders ( ) ; array_push ( $ autoloaders , $ callback ) ; $ this -> setAutoloaders ( $ autoloaders ) ; $ namespace = ( array ) $ namespace ; foreach ( $ namespace as $ ns ) { $ autoloaders = $ this -> getNamespaceAutoloaders ( $ ns ) ; array_push ( $ autoloaders , $ callback ) ; $ this -> _setNamespaceAutoloaders ( $ autoloaders , $ ns ) ; } return $ this ; }
Append an autoloader to the autoloader stack
22,143
public function removeAutoloader ( $ callback , $ namespace = null ) { if ( null === $ namespace ) { $ autoloaders = $ this -> getAutoloaders ( ) ; if ( false !== ( $ index = array_search ( $ callback , $ autoloaders , true ) ) ) { unset ( $ autoloaders [ $ index ] ) ; $ this -> setAutoloaders ( $ autoloaders ) ; } foreach ( $ this -> _namespaceAutoloaders as $ ns => $ autoloaders ) { if ( false !== ( $ index = array_search ( $ callback , $ autoloaders , true ) ) ) { unset ( $ autoloaders [ $ index ] ) ; $ this -> _setNamespaceAutoloaders ( $ autoloaders , $ ns ) ; } } } else { $ namespace = ( array ) $ namespace ; foreach ( $ namespace as $ ns ) { $ autoloaders = $ this -> getNamespaceAutoloaders ( $ ns ) ; if ( false !== ( $ index = array_search ( $ callback , $ autoloaders , true ) ) ) { unset ( $ autoloaders [ $ index ] ) ; $ this -> _setNamespaceAutoloaders ( $ autoloaders , $ ns ) ; } } } return $ this ; }
Remove an autoloader from the autoloader stack
22,144
protected function _autoload ( $ class ) { $ callback = $ this -> getDefaultAutoloader ( ) ; try { if ( $ this -> suppressNotFoundWarnings ( ) ) { @ call_user_func ( $ callback , $ class ) ; } else { call_user_func ( $ callback , $ class ) ; } return $ class ; } catch ( Zend_Exception $ e ) { return false ; } }
Internal autoloader implementation
22,145
protected function _getVersionPath ( $ path , $ version ) { $ type = $ this -> _getVersionType ( $ version ) ; if ( $ type == 'latest' ) { $ version = 'latest' ; } $ availableVersions = $ this -> _getAvailableVersions ( $ path , $ version ) ; if ( empty ( $ availableVersions ) ) { throw new Zend_Loader_Exception ( 'No valid ZF installations discovered' ) ; } $ matchedVersion = array_pop ( $ availableVersions ) ; return $ matchedVersion ; }
Retrieve the filesystem path for the requested ZF version
22,146
protected function _getVersionType ( $ version ) { if ( strtolower ( $ version ) == 'latest' ) { return 'latest' ; } $ parts = explode ( '.' , $ version ) ; $ count = count ( $ parts ) ; if ( 1 == $ count ) { return 'major' ; } if ( 2 == $ count ) { return 'minor' ; } if ( 3 < $ count ) { throw new Zend_Loader_Exception ( 'Invalid version string provided' ) ; } return 'specific' ; }
Retrieve the ZF version type
22,147
protected function _getAvailableVersions ( $ path , $ version ) { if ( ! is_dir ( $ path ) ) { throw new Zend_Loader_Exception ( 'Invalid ZF path provided' ) ; } $ path = rtrim ( $ path , '/' ) ; $ path = rtrim ( $ path , '\\' ) ; $ versionLen = strlen ( $ version ) ; $ versions = array ( ) ; $ dirs = glob ( "$path/*" , GLOB_ONLYDIR ) ; foreach ( ( array ) $ dirs as $ dir ) { $ dirName = substr ( $ dir , strlen ( $ path ) + 1 ) ; if ( ! preg_match ( '/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i' , $ dirName , $ matches ) ) { continue ; } $ matchedVersion = $ matches [ 1 ] ; if ( ( 'latest' == $ version ) || ( ( strlen ( $ matchedVersion ) >= $ versionLen ) && ( 0 === strpos ( $ matchedVersion , $ version ) ) ) ) { $ versions [ $ matchedVersion ] = $ dir . '/library' ; } } uksort ( $ versions , 'version_compare' ) ; return $ versions ; }
Get available versions for the version type requested
22,148
public function create ( EntityFactoryConfig $ config , ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) : ResponseInterface { $ entityRequest = $ config -> createEntityRequest ( $ request , $ this -> container ) ; $ obj = $ entityRequest -> instantiateActiveRecord ( ) ; $ entityRequest -> beforeCreate ( $ obj , $ request ) ; if ( $ config -> isHydrateEntityFromRequest ( ) ) { $ requestParams = $ request -> getQueryParams ( ) ; $ postParams = $ request -> getParsedBody ( ) ; if ( $ postParams ) { $ requestParams = array_merge ( $ requestParams , ( array ) $ postParams ) ; } $ obj -> fromArray ( $ entityRequest -> getAllowedDataFromRequest ( $ requestParams , $ request -> getMethod ( ) ) ) ; } $ entityRequest -> afterCreate ( $ obj , $ request ) ; $ request = $ request -> withAttribute ( $ config -> getParameterToInjectInto ( ) , $ obj ) ; return $ next ( $ request , $ response ) ; }
Create a new instance of activeRecord and add it to Request attributes
22,149
public function fetch ( EntityFactoryConfig $ config , ServerRequestInterface $ request , ResponseInterface $ response , callable $ next ) : ResponseInterface { $ entityRequest = $ config -> createEntityRequest ( $ request , $ this -> container ) ; if ( isset ( $ request -> getAttribute ( 'routeInfo' ) [ 2 ] [ $ config -> getRequestParameterName ( ) ] ) ) { $ entityRequest -> setPrimaryKey ( $ request -> getAttribute ( 'routeInfo' ) [ 2 ] [ $ config -> getRequestParameterName ( ) ] ) ; } $ query = $ this -> getQueryFromActiveRecordRequest ( $ entityRequest ) ; $ query = $ entityRequest -> beforeFetch ( $ query , $ request ) ; $ pk = $ entityRequest -> getPrimaryKey ( ) ; if ( null === $ pk ) { $ handler = $ entityRequest -> getContainer ( ) -> getEntityRequestErrorHandler ( ) ; return $ handler -> primaryKeyNotFound ( $ entityRequest , $ request , $ response ) ; } $ obj = $ query -> findPk ( $ pk ) ; if ( $ obj === null ) { $ handler = $ entityRequest -> getContainer ( ) -> getEntityRequestErrorHandler ( ) ; return $ handler -> entityNotFound ( $ entityRequest , $ request , $ response ) ; } if ( $ config -> isHydrateEntityFromRequest ( ) ) { $ params = $ request -> getQueryParams ( ) ; $ postParams = $ request -> getParsedBody ( ) ; if ( $ postParams ) { $ params = array_merge ( $ params , ( array ) $ postParams ) ; } $ obj -> fromArray ( $ entityRequest -> getAllowedDataFromRequest ( $ params , $ request -> getMethod ( ) ) ) ; } $ entityRequest -> afterFetch ( $ obj , $ request ) ; $ request = $ request -> withAttribute ( $ config -> getParameterToInjectInto ( ) , $ obj ) ; return $ next ( $ request , $ response ) ; }
Fetch an existing instance of activeRecord and add it to Request attributes
22,150
public function fetchCollection ( EntityRequestInterface $ entityRequest , ServerRequestInterface $ request , ResponseInterface $ response , callable $ next , $ nameOfParameterToAdd = null ) : ResponseInterface { $ pks = [ ] ; if ( $ request -> getMethod ( ) === 'GET' ) { $ params = $ request -> getQueryParams ( ) ; if ( array_key_exists ( 'id' , $ params ) ) { $ pks = $ params [ 'id' ] ; } } else { if ( is_array ( $ request -> getParsedBody ( ) ) ) { $ finder = new PksFinder ( [ 'id' ] ) ; $ pks = $ finder -> find ( $ request -> getParsedBody ( ) ) ; } } $ query = $ this -> getQueryFromActiveRecordRequest ( $ entityRequest ) ; if ( empty ( $ pks ) ) { $ handler = $ entityRequest -> getContainer ( ) -> getEntityRequestErrorHandler ( ) ; return $ handler -> primaryKeyNotFound ( $ entityRequest , $ request , $ response ) ; } $ col = $ query -> findPks ( $ pks ) ; if ( $ col === null ) { $ handler = $ entityRequest -> getContainer ( ) -> getEntityRequestErrorHandler ( ) ; return $ handler -> entityNotFound ( $ entityRequest , $ request , $ response ) ; } if ( $ nameOfParameterToAdd === null ) { $ nameOfParameterToAdd = $ entityRequest -> getNameOfParameterToAdd ( true ) ; } $ request = $ request -> withAttribute ( $ nameOfParameterToAdd , $ col ) ; return $ next ( $ request , $ response ) ; }
Fetch an existing collection of activeRecords and add it to Request attributes
22,151
public function addElement ( Element $ element ) : Element { if ( $ element instanceof FormStatus ) { if ( $ this -> hasStatus === true ) { throw new InvalidArgumentException ( 'Form can contain only one FormStatus element' ) ; } $ this -> hasStatus = true ; } return parent :: addElement ( $ element ) ; }
Adds element to composite . Throws InvalidArgumentException if more than one FormStatus element is added .
22,152
public function generate ( ) : string { $ elements = [ ] ; foreach ( $ this -> hiddens as $ hidden ) { $ elements [ ] = $ hidden ; } foreach ( $ this -> elements as $ element ) { $ elements [ ] = $ element -> generate ( ) ; } return Tags :: form ( $ elements , $ this -> attributes ) ; }
Generates from and returns it
22,153
protected function getDataObjectBackend ( $ dataFileName ) { $ path = $ this -> framework -> getRootDirectory ( ) . '/data/' . $ dataFileName ; $ objectBackend = new \ Zepi \ Turbo \ Backend \ FileObjectBackend ( $ path ) ; return $ objectBackend ; }
Returns a data object backend for the given file name
22,154
public function getRawDocuments ( $ returnType ) { if ( $ returnType == DOC_TYPE_ARRAY ) { $ res = array ( ) ; foreach ( $ this -> _documents as $ key => $ value ) { $ res [ $ key ] = CPS_Response :: simpleXmlToArray ( $ value ) ; } return $ res ; } else if ( $ returnType == DOC_TYPE_STDCLASS ) { $ res = array ( ) ; foreach ( $ this -> _documents as $ key => $ value ) { $ res [ $ key ] = CPS_Response :: simpleXmlToStdClass ( $ value ) ; } return $ res ; } return $ this -> _documents ; }
Returns the documents from the response
22,155
public function getRawAggregate ( $ returnType ) { if ( $ returnType == DOC_TYPE_ARRAY ) { $ res = array ( ) ; foreach ( $ this -> _aggregate as $ key => $ value ) { if ( $ value ) { $ tmp = CPS_Response :: simpleXmlToArray ( $ value ) ; if ( isset ( $ tmp [ 'data' ] [ 0 ] ) ) { $ res [ $ key ] = $ tmp [ 'data' ] ; } else { $ res [ $ key ] [ ] = $ tmp [ 'data' ] ; } unset ( $ tmp ) ; } else { $ res [ $ key ] = array ( ) ; } } return $ res ; } else if ( $ returnType == DOC_TYPE_STDCLASS ) { $ res = array ( ) ; foreach ( $ this -> _aggregate as $ key => $ value ) { if ( $ value ) { $ tmp = CPS_Response :: simpleXmlToStdClass ( $ value ) ; $ res [ $ key ] = $ tmp -> data ; unset ( $ tmp ) ; } else { $ res [ $ key ] = new stdClass ( ) ; } } return $ res ; } return $ this -> _aggregate ; }
Returns the aggregate data from the response
22,156
public function getParam ( $ name ) { if ( in_array ( $ name , $ this -> _textParamNames ) ) { return $ this -> _textParams [ $ name ] ; } else { throw new CPS_Exception ( array ( array ( 'long_message' => 'Invalid response parameter' , 'code' => ERROR_CODE_INVALID_PARAMETER , 'level' => 'REJECTED' , 'source' => 'CPS_API' ) ) ) ; } }
Returns a response parameter
22,157
static function simpleXmlToArrayHelper ( & $ res , & $ key , & $ value , & $ children ) { if ( isset ( $ res [ $ key ] ) ) { if ( is_string ( $ res [ $ key ] ) || ( is_array ( $ res [ $ key ] ) && is_assoc ( $ res [ $ key ] ) ) ) { $ res [ $ key ] = array ( $ res [ $ key ] ) ; } $ res [ $ key ] [ ] = CPS_Response :: simpleXmlToArray ( $ value ) ; } else { $ res [ $ key ] = CPS_Response :: simpleXmlToArray ( $ value ) ; } $ children = true ; }
Helper function for conversions . Used internally .
22,158
static function simpleXmlToArray ( SimpleXMLElement & $ source ) { $ res = array ( ) ; $ children = false ; foreach ( $ source as $ key => $ value ) { CPS_Response :: simpleXmlToArrayHelper ( $ res , $ key , $ value , $ children ) ; } if ( $ source ) { foreach ( $ source -> children ( 'www.clusterpoint.com' ) as $ key => $ value ) { $ newkey = 'cps:' . $ key ; CPS_Response :: simpleXmlToArrayHelper ( $ res , $ newkey , $ value , $ children ) ; } } if ( ! $ children ) return ( string ) $ source ; return $ res ; }
Converts SimpleXMLElement to an array
22,159
static function simpleXmlToStdClass ( SimpleXMLElement & $ source ) { $ res = new StdClass ; $ children = false ; foreach ( $ source as $ key => $ value ) { if ( isset ( $ res -> $ key ) ) { if ( ! is_array ( $ res -> $ key ) ) { $ res -> $ key = array ( $ res -> $ key ) ; } $ ref = & $ res -> $ key ; $ ref [ ] = CPS_Response :: simpleXmlToStdClass ( $ value ) ; } else { $ res -> $ key = CPS_Response :: simpleXmlToStdClass ( $ value ) ; } $ children = true ; } if ( ! $ children ) return ( string ) $ source ; return $ res ; }
Converts SimpleXMLElement to stdClass
22,160
public function append ( $ element ) { $ this -> elements [ ] = $ element ; $ this -> fire ( new ListCreateEvent ( $ element , $ this -> count ( ) - 1 ) ) ; return $ this ; }
Adds element to end of list .
22,161
public function unshift ( $ element ) { $ this -> insert ( $ element , 0 ) ; $ this -> fire ( new ListCreateEvent ( $ element , 0 ) ) ; return $ this ; }
Inserts the given element to the beginning of the list .
22,162
public function remove ( $ index ) { $ e = $ this -> elements [ $ index ] ; unset ( $ this -> elements [ $ index ] ) ; $ this -> clean ( ) ; $ this -> fire ( new ListDeleteEvent ( $ e , $ index ) ) ; return $ e ; }
Removes and returns the element at given index from list .
22,163
public function pop ( ) { $ e = array_pop ( $ this -> elements ) ; $ this -> fire ( new ListDeleteEvent ( $ e , $ this -> count ( ) ) ) ; return $ e ; }
Removes and returns the last element of the list .
22,164
public function shift ( ) { $ e = array_shift ( $ this -> elements ) ; $ this -> clean ( ) ; $ this -> fire ( new ListDeleteEvent ( $ e , 0 ) ) ; return $ e ; }
Removes and returns the first element of the list .
22,165
public static function forge ( $ config = array ( ) , $ filename = null ) { ! is_array ( $ config ) and $ config = array ( ) ; $ config = array_merge ( \ Config :: get ( 'image' , array ( ) ) , $ config ) ; $ protocol = ucfirst ( ! empty ( $ config [ 'driver' ] ) ? $ config [ 'driver' ] : 'gd' ) ; $ class = 'Image_' . $ protocol ; if ( $ protocol == 'Driver' || ! class_exists ( $ class ) ) { throw new \ FuelException ( 'Driver ' . $ protocol . ' is not a valid driver for image manipulation.' ) ; } $ return = new $ class ( $ config ) ; if ( $ filename !== null ) { $ return -> load ( $ filename ) ; } return $ return ; }
Creates a new instance of the image driver
22,166
public static function config ( $ index = array ( ) , $ value = null ) { if ( static :: $ _instance === null ) { if ( $ value !== null ) $ index = array ( $ index => $ value ) ; if ( is_array ( $ index ) ) static :: $ _config = array_merge ( static :: $ _config , $ index ) ; static :: instance ( ) ; return static :: instance ( ) ; } else { return static :: instance ( ) -> config ( $ index , $ value ) ; } }
Used to set configuration options .
22,167
public static function load ( $ filename , $ return_data = false , $ force_extension = false ) { return static :: instance ( ) -> load ( $ filename , $ return_data , $ force_extension ) ; }
Loads the image and checks if its compatable .
22,168
public static function crop ( $ x1 , $ y1 , $ x2 , $ y2 ) { return static :: instance ( ) -> crop ( $ x1 , $ y1 , $ x2 , $ y2 ) ; }
Crops the image using coordinates or percentages .
22,169
public static function resize ( $ width , $ height , $ keepar = true , $ pad = false ) { return static :: instance ( ) -> resize ( $ width , $ height , $ keepar , $ pad ) ; }
Resizes the image . If the width or height is null it will resize retaining the original aspect ratio .
22,170
public static function rounded ( $ radius , $ sides = null , $ antialias = null ) { return static :: instance ( ) -> rounded ( $ radius , $ sides , $ antialias ) ; }
Adds rounded corners to the image .
22,171
public static function save_pa ( $ prepend , $ append = null , $ permissions = null ) { return static :: instance ( ) -> save_pa ( $ prepend , $ append , $ permissions ) ; }
Saves the image and optionally attempts to set permissions
22,172
public static function apply ( $ file , $ filters ) { if ( ! empty ( $ filters ) ) { $ gd = self :: getSingletonGDClass ( ) ; $ gd -> canvas ( $ file ) ; foreach ( $ filters as $ filter ) { $ method = $ filter [ 0 ] ; $ parameters = $ filter [ 1 ] ?? [ ] ; $ gd -> $ method ( ... ( array ) $ parameters ) ; } $ gd -> generate ( MimeTypeFinder :: get ( $ file ) , $ file ) ; } }
Applies the used filters belonging to the GD class .
22,173
public function execute ( ) { $ success = true ; foreach ( $ this -> commandList as $ command ) { if ( ! $ this -> runSingleCommand ( $ command ) ) { $ success = false ; break ; } } return $ success ; }
Executes Symfony2 commands
22,174
public function runSingleCommand ( $ command ) { $ cmd = 'php ' . $ this -> directory . 'app/console ' ; return $ this -> phpci -> executeCommand ( $ cmd . $ command , $ this -> directory ) ; }
Run one command
22,175
public function extractMantissa ( $ data ) { $ signAndExponent = $ this -> extractSignAndExponentFromData ( $ data ) ; $ mask = ~ $ signAndExponent ; $ mantissa = $ data & $ mask ; return $ mantissa ; }
Public for unit test
22,176
public function makeFrontSideMask ( $ maskLength , $ byteLength ) { $ maskValue = 0 ; $ bitLength = $ byteLength * 8 ; $ maskString = "" ; $ valueStore = 0 ; for ( $ i = 0 ; $ i < $ bitLength ; $ i ++ ) { $ maskValue <<= 1 ; if ( $ i < $ maskLength ) { $ maskValue += 1 ; } $ valueStore ++ ; $ binRep = BinaryStringAtom :: createHumanReadableBinaryRepresentation ( $ maskValue ) ; if ( $ valueStore == 8 ) { $ char = chr ( $ maskValue ) ; $ maskString .= $ char ; $ maskValue = 0 ; $ valueStore = 0 ; } } return $ maskString ; }
This function makes a mask that has one s in the highest bit - values and 0 s in the lower bit - values .
22,177
public function convertBinaryFractionToDecimalFraction ( $ mantissaByteString , $ integerExponent ) { $ bits = $ this -> mantissaBitLength ; $ value = pow ( 2 , $ integerExponent ) ; for ( $ i = 0 ; $ i < $ bits ; $ i ++ ) { $ curExponent = $ integerExponent - 1 - $ i ; $ bitPosition = $ bits - $ i - 1 ; $ bitValue = $ this -> readBit ( $ mantissaByteString , $ bitPosition ) ; $ decValue = pow ( 2 , $ curExponent ) * $ bitValue ; $ value += $ decValue ; } return $ value ; }
Pubic for unit testing only .
22,178
public function readBit ( $ byteString , $ bitPosition ) { $ byteNumber = $ this -> findByteNumberForBitPosition ( $ bitPosition ) ; $ bitPositionInByte = $ bitPosition % 8 ; $ pos = strlen ( $ byteString ) - 1 - $ byteNumber ; $ targetByte = $ byteString [ $ pos ] ; $ mask = chr ( 1 << $ bitPositionInByte ) ; $ filteredByte = $ mask & $ targetByte ; $ bitValue = 0 ; if ( ord ( $ filteredByte ) > 0 ) { $ bitValue = 1 ; } return $ bitValue ; }
Public for testing
22,179
public static function spaceToCamelCase ( $ string , $ type = '_' , $ first_char_caps = false ) { if ( $ first_char_caps === true ) { $ string [ 0 ] = strtoupper ( $ string [ 0 ] ) ; } $ func = create_function ( '$c' , 'return strtoupper($c[1]);' ) ; return preg_replace_callback ( '/' . $ type . '([a-z])/' , $ func , $ string ) ; }
Convert strings with an arbitrary deliminator into CamelCase .
22,180
public function get_config_value ( $ config_name , $ default_value = false ) { $ value = false ; if ( array_key_exists ( $ config_name , $ this -> _config ) ) { $ value = $ this -> _config [ $ config_name ] ; } else if ( ! $ default_value ) { $ value = $ default_value ; } return $ value ; }
Recupere la valeur de l option demander .
22,181
public function log ( $ service_name , $ log_name , $ level , $ message , $ context = array ( ) ) { $ ok = false ; $ tmp_log_path = $ this -> get_config_value ( 'log_path' ) ; $ log_path = ( $ this -> get_config_value ( 'log_path' ) ) ? $ this -> get_config_value ( 'log_path' ) . '/' . $ service_name . '/' : sys_get_temp_dir ( ) . '/' . $ service_name . '/' ; if ( ! file_exists ( $ log_path ) ) { mkdir ( $ log_path , 0755 ) ; } $ log_path .= $ log_name . ".log" ; $ append = false ; if ( file_exists ( $ log_path ) && filesize ( $ log_path ) >= 1024 ) { $ append = FILE_APPEND ; } $ context_string = ( ( bool ) $ context ) ? print_r ( $ context , true ) : '' ; $ formated_message = $ level . ': ' . $ message . ' ( ' . $ context_string . ' )' ; $ ok = file_put_contents ( $ log_path , $ formated_message , $ append ) ; return ( $ ok === false ) ? false : true ; }
Ecriture de log basique .
22,182
protected function when ( DomainEvent $ event ) { $ method = 'when' . ClassToString :: short ( $ event ) ; if ( is_callable ( [ $ this , $ method ] ) ) { $ this -> { $ method } ( $ event ) ; } }
Handle a single domain event
22,183
protected function _setServiceCache ( $ serviceCache ) { if ( $ serviceCache !== null && ! ( $ serviceCache instanceof ContainerInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid cache' ) , null , null , $ serviceCache ) ; } $ this -> serviceCache = $ serviceCache ; }
Assigns a service cache to this instance .
22,184
public function hasGroup ( $ name ) { $ group = App :: make ( 'group_repository' ) -> findByName ( $ name ) ; $ user = $ this -> getLoggedUser ( ) ; if ( ! $ user ) { return false ; } return $ user -> inGroup ( $ group ) ; }
Check if the current user has the given group
22,185
private function createKeys ( ) { shuffle ( Devbr \ Can :: $ base ) ; shuffle ( Devbr \ Can :: $ extra_base ) ; file_put_contents ( $ this -> configKeyPath . 'can.key' , implode ( Devbr \ Can :: $ base ) . "\n" . implode ( Devbr \ Can :: $ extra_base ) ) ; $ SSLcnf = [ ] ; $ dn = [ ] ; include $ this -> configKeyPath . 'openssl.config.php' ; $ privkey = openssl_pkey_new ( $ SSLcnf ) ; $ csr = openssl_csr_new ( $ dn , $ privkey , $ SSLcnf ) ; $ sscert = openssl_csr_sign ( $ csr , null , $ privkey , 365 , $ SSLcnf ) ; openssl_csr_export_to_file ( $ csr , $ this -> configKeyPath . 'certificate.crt' , false ) ; openssl_x509_export_to_file ( $ sscert , $ this -> configKeyPath . 'self_signed_certificate.cer' , false ) ; openssl_pkey_export_to_file ( $ privkey , $ this -> configKeyPath . 'private.key' , null , $ SSLcnf ) ; file_put_contents ( $ this -> configKeyPath . 'public.key' , openssl_pkey_get_details ( $ privkey ) [ 'key' ] ) ; }
Create Can anda SSL keys
22,186
public function Export ( $ Export ) { switch ( $ Export ) { case 'Environment' : return $ this -> _Environment ; case 'Arguments' : return $ this -> _RequestArguments ; case 'Parsed' : return $ this -> _ParsedRequest ; default : return NULL ; } }
This method allows requests to export their internal data .
22,187
public function FromEnvironment ( ) { $ this -> WithURI ( ) -> WithArgs ( self :: INPUT_GET , self :: INPUT_POST , self :: INPUT_SERVER , self :: INPUT_FILES , self :: INPUT_COOKIES ) ; return $ this ; }
Chainable lazy Environment Bootstrap
22,188
public function FromImport ( $ NewRequest ) { $ this -> _Environment = $ NewRequest -> Export ( 'Environment' ) ; $ this -> _RequestArguments = $ NewRequest -> Export ( 'Arguments' ) ; $ this -> _HaveParsedRequest = FALSE ; $ this -> _Parsing = FALSE ; return $ this ; }
Chainable Request Importer
22,189
public function Get ( $ Key = NULL , $ Default = NULL ) { if ( $ Key === NULL ) return $ this -> GetRequestArguments ( self :: INPUT_GET ) ; else return $ this -> GetValueFrom ( self :: INPUT_GET , $ Key , $ Default ) ; }
Get a value from the GET array or return the entire GET array .
22,190
public function HostAndPort ( ) { $ Host = $ this -> Host ( ) ; $ Port = $ this -> Port ( ) ; if ( ! in_array ( $ Port , array ( 80 , 443 ) ) ) return $ Host . ':' . $ Port ; else return $ Host ; }
Return the host and port together if the port isn t standard .
22,191
protected function _ParseRequest ( ) { $ this -> _Parsing = TRUE ; $ Path = $ this -> _EnvironmentElement ( 'URI' ) ; if ( $ Path !== FALSE ) { $ this -> Path ( trim ( $ Path , '/' ) ) ; } else { $ Expression = '/^(?:\/?' . str_replace ( '/' , '\/' , $ this -> _EnvironmentElement ( 'Folder' ) ) . ')?(?:' . $ this -> _EnvironmentElement ( 'Script' ) . ')?\/?(.*?)\/?(?:[#?].*)?$/i' ; if ( preg_match ( $ Expression , $ this -> _EnvironmentElement ( 'URI' ) , $ Match ) ) $ this -> Path ( $ Match [ 1 ] ) ; else $ this -> Path ( '' ) ; } $ UrlParts = explode ( '/' , $ this -> Path ( ) ) ; $ Last = array_slice ( $ UrlParts , - 1 , 1 ) ; $ LastParam = array_pop ( $ Last ) ; $ Match = array ( ) ; if ( preg_match ( '/^(.+)\.([^.]{1,4})$/' , $ LastParam , $ Match ) ) { $ this -> OutputFormat ( $ Match [ 2 ] ) ; $ this -> Filename ( $ Match [ 0 ] ) ; } $ WebRoot = FALSE ; if ( ! $ WebRoot ) { $ WebRoot = explode ( '/' , GetValue ( 'PHP_SELF' , $ _SERVER , '' ) ) ; $ Key = array_search ( 'index.php' , $ WebRoot ) ; if ( $ Key !== FALSE ) { $ WebRoot = implode ( '/' , array_slice ( $ WebRoot , 0 , $ Key ) ) ; } else { $ WebRoot = '' ; } } $ ParsedWebRoot = trim ( $ WebRoot , '/' ) ; $ this -> WebRoot ( $ ParsedWebRoot ) ; $ Domain = FALSE ; if ( $ Domain === FALSE || $ Domain == '' ) $ Domain = $ this -> Host ( ) ; if ( $ Domain != '' && $ Domain !== FALSE ) { if ( ! stristr ( $ Domain , '://' ) ) $ Domain = $ this -> Scheme ( ) . '://' . $ Domain ; $ Domain = trim ( $ Domain , '/' ) ; } $ this -> Domain ( $ Domain ) ; $ this -> _Parsing = FALSE ; $ this -> _HaveParsedRequest = TRUE ; }
Parse the Environment data into the ParsedRequest array .
22,192
public function Post ( $ Key = NULL , $ Default = NULL ) { if ( $ Key === NULL ) return $ this -> GetRequestArguments ( self :: INPUT_POST ) ; else return $ this -> GetValueFrom ( self :: INPUT_POST , $ Key , $ Default ) ; }
Get a value from the post array or return the entire POST array .
22,193
public function Merged ( $ Key = NULL , $ Default = NULL ) { $ Merged = array ( ) ; $ QueryOrder = array ( self :: INPUT_CUSTOM , self :: INPUT_GET , self :: INPUT_POST , self :: INPUT_FILES , self :: INPUT_SERVER , self :: INPUT_ENV , self :: INPUT_COOKIES ) ; $ NumDataTypes = sizeof ( $ QueryOrder ) ; for ( $ i = $ NumDataTypes ; $ i > 0 ; $ i -- ) { $ DataType = $ QueryOrder [ $ i - 1 ] ; if ( ! array_key_exists ( $ DataType , $ this -> _RequestArguments ) ) continue ; $ Merged = array_merge ( $ Merged , $ this -> _RequestArguments [ $ DataType ] ) ; } return ( is_null ( $ Key ) ) ? $ Merged : GetValue ( $ Key , $ Merged , $ Default ) ; }
Get a value from the merged param array or return the entire merged array
22,194
protected function _SetRequestArguments ( $ ParamsType , $ ParamsData = NULL ) { switch ( $ ParamsType ) { case self :: INPUT_GET : $ ArgumentData = $ _GET ; break ; case self :: INPUT_POST : $ ArgumentData = $ _POST ; break ; case self :: INPUT_SERVER : $ ArgumentData = $ _SERVER ; break ; case self :: INPUT_FILES : $ ArgumentData = $ _FILES ; break ; case self :: INPUT_ENV : $ ArgumentData = $ _ENV ; break ; case self :: INPUT_COOKIES : $ ArgumentData = $ _COOKIE ; break ; case self :: INPUT_CUSTOM : $ ArgumentData = is_array ( $ ParamsData ) ? $ ParamsData : array ( ) ; break ; } $ this -> _RequestArguments [ $ ParamsType ] = $ ArgumentData ; }
Attach an array of request arguments to the request .
22,195
public function WithArgs ( ) { $ ArgAliasList = func_get_args ( ) ; if ( count ( $ ArgAliasList ) ) foreach ( $ ArgAliasList as $ ArgAlias ) { $ this -> _SetRequestArguments ( strtolower ( $ ArgAlias ) ) ; } return $ this ; }
Chainable Superglobal arguments setter
22,196
public function WithControllerMethod ( $ Controller , $ Method = NULL , $ Args = array ( ) ) { if ( is_a ( $ Controller , 'Gdn_Controller' ) ) { $ Matches = array ( ) ; preg_match ( '/^(.*)Controller$/' , get_class ( $ Controller ) , $ Matches ) ; $ Controller = $ Matches [ 1 ] ; } $ Method = is_null ( $ Method ) ? 'index' : $ Method ; $ Path = trim ( implode ( '/' , array_merge ( array ( $ Controller , $ Method ) , $ Args ) ) , '/' ) ; $ this -> _EnvironmentElement ( 'URI' , $ Path ) ; return $ this ; }
Chainable URI Setter source is a controller + method + args list
22,197
static function load ( $ filename ) { if ( isset ( self :: $ stack [ $ filename ] ) ) return self :: $ stack [ $ filename ] ; $ path = self :: get ( "apppath" ) . "config" . DS . $ filename ; if ( ! file_exists ( $ path ) ) throw new \ Exception ( "Config file '$filename' not found'" ) ; $ config_data = include ( $ path ) ; self :: set ( $ filename , $ config_data ) ; return $ config_data ; }
Loads a php file which returns an array of config data
22,198
public function generate ( ) : string { $ status = Tags :: NBSP ; if ( $ this -> statusData [ 'status-type' ] !== '' && $ this -> statusData [ 'status-text' ] !== '' ) { $ status = [ Tags :: div ( $ this -> getConstant ( $ this -> statusData [ 'status-text' ] ) , [ 'class' => $ this -> getConstant ( $ this -> statusData [ 'status-type' ] ) ] ) ] ; } return Tags :: div ( $ status , [ 'class' => 'status' ] ) ; }
Generates FormStatus and returns it
22,199
protected function determineWeekIndex ( DateLexerResult $ parts ) { if ( null === $ w = $ parts -> get ( 'W' ) ) { return null ; } return intval ( $ w ) - 1 ; }
Determine ISO week index from iso week number .