idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
24,200
private function getPaginationIndex ( $ optionsPagination = array ( ) ) { $ nbResult = 0 ; $ nbPages = 0 ; $ currentPage = 0 ; $ nextPage = 0 ; $ previousPage = 0 ; $ nbResultPerPage = 10 ; $ offset = 4 ; $ indexToDisplay = array ( ) ; if ( isset ( $ optionsPagination [ 'nbResult' ] ) ) { $ nbResult = $ optionsPagination [ 'nbResult' ] ; } if ( isset ( $ optionsPagination [ 'nbPages' ] ) ) { $ nbPages = $ optionsPagination [ 'nbPages' ] ; } if ( isset ( $ optionsPagination [ 'currentPage' ] ) ) { $ currentPage = $ optionsPagination [ 'currentPage' ] ; } if ( isset ( $ optionsPagination [ 'nextPage' ] ) ) { $ nextPage = $ optionsPagination [ 'nextPage' ] ; } if ( isset ( $ optionsPagination [ 'previousPage' ] ) ) { $ previousPage = $ optionsPagination [ 'previousPage' ] ; } if ( isset ( $ optionsPagination [ 'nbResultPerPage' ] ) ) { $ nbResultPerPage = $ optionsPagination [ 'nbResultPerPage' ] ; } if ( isset ( $ optionsPagination [ 'offset' ] ) ) { $ offset = $ optionsPagination [ 'offset' ] ; } if ( $ nbPages <= ( 2 * $ offset + 1 ) ) { $ indexToDisplay [ 'firstPage' ] = 0 ; $ indexToDisplay [ 'lastPage' ] = $ nbPages - 1 ; } else { if ( ( $ currentPage - $ offset ) <= 0 ) { $ indexToDisplay [ 'firstPage' ] = 0 ; } else { $ indexToDisplay [ 'firstPage' ] = $ currentPage - $ offset - 1 ; } if ( ( $ currentPage + $ offset ) >= $ nbPages ) { $ indexToDisplay [ 'lastPage' ] = $ nbPages - 1 ; } else { $ indexToDisplay [ 'lastPage' ] = $ currentPage + $ offset - 1 ; } if ( ( 2 * $ offset + 1 ) > ( $ indexToDisplay [ 'lastPage' ] - $ indexToDisplay [ 'firstPage' ] ) ) { $ offsetAdd = ( 2 * $ offset + 1 ) - ( $ indexToDisplay [ 'lastPage' ] - $ indexToDisplay [ 'firstPage' ] ) ; if ( $ indexToDisplay [ 'firstPage' ] == 0 ) { $ indexToDisplay [ 'lastPage' ] += $ offsetAdd - 1 ; } else { $ indexToDisplay [ 'firstPage' ] -= $ offsetAdd - 1 ; } } } $ indexRange = array ( ) ; for ( $ i = $ indexToDisplay [ 'firstPage' ] ; $ i <= $ indexToDisplay [ 'lastPage' ] ; $ i ++ ) { $ indexRange [ ] = $ i ; } $ indexToDisplay [ 'range' ] = $ indexRange ; return $ indexRange ; }
Get pagination index
24,201
public function getTitre ( $ idAdresse ) { $ requete = "SELECT e2.titre FROM evenements e1, evenements e2 LEFT JOIN _adresseEvenement ae on ae.idEvenement = e1.idEvenement WHERE ae.idAdresse = $idAdresse AND e2.idEvenement = e1.`idEvenementRecuperationTitre` " ; $ result = $ this -> connexionBdd -> requete ( $ requete ) ; $ retValue = mysql_fetch_assoc ( $ result ) ; return $ retValue [ 'titre' ] ; }
Get titre of an adresse
24,202
public function getHtmlId ( ) { $ id = '' ; if ( is_object ( $ this -> parent ) ) { $ id = $ this -> parent -> getHtmlId ( ) ; } if ( $ this -> key !== '' ) { $ id .= '-' . $ this -> key ; } return $ id ; }
Returns the html id for the container . The id is built by the keys of this element and all parents .
24,203
public function getPath ( AbstractContainer $ startingFrom = null ) { $ id = '' ; if ( is_object ( $ this -> parent ) && $ startingFrom !== $ this -> parent ) { $ id = $ this -> parent -> getPath ( $ startingFrom ) ; } if ( $ id != '' && substr ( $ id , - 1 ) != '.' ) { $ id .= '.' ; } if ( $ this -> publicKey !== '' ) { $ id .= $ this -> publicKey ; } return $ id ; }
Returns the path for the element starting from the given AbstractContainer
24,204
public function getPart ( $ key ) { foreach ( $ this -> parts as $ part ) { if ( $ part -> getKey ( ) === $ key ) { return $ part ; } } return false ; }
Returns the part for the given key if there is no part with this key registred return false .
24,205
public function searchPartByKeyAndType ( $ key , $ type = '\\Zepi\\Web\\UserInterface\\Layout\\AbstractContainer' ) { foreach ( $ this -> parts as $ part ) { if ( ( is_a ( $ part , $ type ) || is_subclass_of ( $ part , $ type ) ) && $ part -> getKey ( ) === $ key ) { return $ part ; } $ result = $ part -> searchPartByKeyAndType ( $ key , $ type ) ; if ( $ result !== false ) { return $ result ; } } return false ; }
Returns the object for the given key and type or false if the object doesn t exists .
24,206
public function getParentOfType ( $ type ) { if ( is_a ( $ this , $ type ) ) { return $ this ; } if ( $ this -> parent !== null ) { return $ this -> parent -> getParentOfType ( $ type ) ; } return false ; }
Returns the next parent of this container for the given type If there is no type like that the function will return false
24,207
public function getChildrenByType ( $ type , $ recursive = true ) { $ results = array ( ) ; foreach ( $ this -> parts as $ part ) { if ( is_a ( $ part , $ type ) || is_subclass_of ( $ part , $ type ) ) { $ results [ ] = $ part ; } if ( $ recursive ) { $ results = array_merge ( $ results , $ part -> getChildrenByType ( $ type , $ recursive ) ) ; } } return $ results ; }
Returns all children with the given type .
24,208
public function getInstance ( ) : Router { if ( ! isset ( self :: $ instance ) ) { self :: $ instance = new self ( ) ; } return self :: $ instance ; }
Singleton instance factory
24,209
public function getParam ( string $ param ) { if ( ! empty ( $ this -> match [ 'params' ] [ $ param ] ) ) { return $ this -> match [ 'params' ] [ $ param ] ; } }
Returns a parameter value
24,210
public function match ( $ request_url = null , $ request_method = null ) { if ( $ request_url === null ) { $ request_url = isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '/' ; } $ this -> request_url = $ request_url ; if ( $ request_method === null ) { $ request_method = isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ? $ _SERVER [ 'REQUEST_METHOD' ] : 'GET' ; } if ( substr ( $ request_url , - 5 ) == '/ajax' ) { $ this -> ajax = true ; $ request_url = str_replace ( '/ajax' , '' , $ request_url ) ; } elseif ( isset ( $ _GET [ 'ajax' ] ) ) { $ this -> ajax = true ; } $ this -> match = parent :: match ( $ request_url , $ request_method ) ; if ( ! empty ( $ this -> match ) ) { $ controls = [ 'ajax' , 'format' ] ; foreach ( $ controls as $ key ) { if ( isset ( $ this -> match [ 'params' ] [ $ key ] ) ) { switch ( $ key ) { case 'ajax' : $ this -> ajax = true ; break ; case 'format' : $ this -> format = $ this -> match [ 'params' ] [ $ key ] ; break ; default : $ this -> { $ key } = $ this -> match [ 'params' ] [ $ key ] ; } break ; } unset ( $ this -> match [ 'params' ] [ $ key ] ) ; } } if ( ! empty ( $ this -> match [ 'params' ] ) ) { foreach ( $ this -> match [ 'params' ] as $ key => $ val ) { if ( empty ( $ val ) ) { unset ( $ this -> match [ 'params' ] [ $ key ] ) ; } if ( in_array ( $ key , $ this -> parameter_to_target ) ) { $ this -> match [ 'target' ] [ $ key ] = $ val ; } } } }
Match a given request url against stored routes
24,211
public function getStatus ( ) : array { return [ 'url' => $ this -> request_url , 'route' => $ this -> getCurrentRoute ( ) , 'ajax' => $ this -> ajax , 'method' => $ _SERVER [ 'REQUEST_METHOD' ] , 'format' => $ this -> format , 'match' => $ this -> match ] ; }
Returns all request related data in one array
24,212
public function getTarget ( string $ target ) { if ( ! empty ( $ this -> match [ 'target' ] [ $ target ] ) ) { return $ this -> match [ 'target' ] [ $ target ] ; } }
Returns a specific target
24,213
public static function parse_shortcode ( $ attributes , $ content , $ parser , $ shortcode ) { if ( isset ( $ attributes [ 'id' ] ) && $ gallery = HTMLBlock :: get ( ) -> byID ( $ attributes [ 'id' ] ) ) { return HTMLBlock :: get ( ) -> byID ( $ attributes [ 'id' ] ) -> forTemplate ( ) ; } }
Parse the shortcode and render as a string probably with a template
24,214
protected function _connect ( ) { if ( ! isset ( $ this -> _profile [ 'host' ] ) ) { throw new jException ( 'jelix~kvstore.error.no.host' , $ this -> _profileName ) ; } if ( ! isset ( $ this -> _profile [ 'port' ] ) ) { throw new jException ( 'jelix~kvstore.error.no.port' , $ this -> _profileName ) ; } if ( isset ( $ this -> _profile [ 'key_prefix' ] ) ) { $ this -> key_prefix = $ this -> _profile [ 'key_prefix' ] ; } if ( $ this -> key_prefix && isset ( $ this -> _profile [ 'key_prefix_flush_method' ] ) ) { if ( in_array ( $ this -> _profile [ 'key_prefix_flush_method' ] , array ( 'direct' , 'jkvdbredisworker' , 'event' ) ) ) { $ this -> key_prefix_flush_method = $ this -> _profile [ 'key_prefix_flush_method' ] ; } } $ cnx = new \ PhpRedis \ Redis ( $ this -> _profile [ 'host' ] , $ this -> _profile [ 'port' ] ) ; if ( isset ( $ this -> _profile [ 'db' ] ) && intval ( $ this -> _profile [ 'db' ] ) != 0 ) { $ cnx -> select_db ( $ this -> _profile [ 'db' ] ) ; } return $ cnx ; }
Connects to the redis server
24,215
public function createUrl ( ) { $ string_data = $ this -> dataToString ( ) ; $ data_to_send = array ( 'hash' => $ this -> doHash ( $ string_data ) , ) ; foreach ( $ this -> data as $ name => $ value ) { $ data_to_send [ $ name ] = $ value ; } $ data_to_send [ 'agent' ] = $ this -> agent ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> apiUrl ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_POST , TRUE ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data_to_send ) ; $ output = curl_exec ( $ ch ) ; $ info = curl_getinfo ( $ ch ) ; curl_close ( $ ch ) ; if ( $ info [ 'http_code' ] == 200 ) { return $ output ; } else { return FALSE ; } }
Metodo que solicita la generacion de la url
24,216
public static function getFileExtension ( $ name ) { if ( is_array ( $ name ) ) { $ name = array_pop ( $ name ) ; } $ extension = static :: splitFilename ( $ name ) [ 1 ] ; if ( is_string ( $ extension ) ) { $ extension = strtolower ( $ extension ) ; } return $ extension ; }
Parse the passed filename to get the extension only . If passed an array uses the last element of the array .
24,217
private static function splitFilename ( $ name ) { if ( is_array ( $ name ) ) { $ name = array_pop ( $ name ) ; } else { $ name = explode ( '/' , $ name ) ; $ name = array_pop ( $ name ) ; } if ( strrpos ( $ name , '.' ) !== false ) { return explode ( '.' , $ name ) ; } else { return array ( $ name , null ) ; } }
Splits the passed filename into a name and extension and returns an array . The first element is the name the second is the extension .
24,218
public function writeLog ( $ message , $ priority = 'LOG_INFO' ) { $ this -> logger -> addRecord ( self :: $ _mapping [ $ priority ] , $ this -> _transform ( $ message ) ) ; }
Writes log to file .
24,219
public function process ( ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( 'lag.repository.repository_pool' ) ) { return ; } $ repositoryTags = $ container -> findTaggedServiceIds ( 'doctrine.repository' ) ; $ poolDefinition = $ container -> findDefinition ( 'lag.repository.repository_pool' ) ; foreach ( $ repositoryTags as $ serviceId => $ tags ) { $ poolDefinition -> addMethodCall ( 'add' , [ new Reference ( $ serviceId ) , ] ) ; } }
Load tagged repositories and add it to the repository pool
24,220
protected function errorIfCompiledBlacklistIsEmpty ( Config $ config ) : ? Error { $ blacklist = $ config -> compileBlacklist ( ) ; return empty ( $ blacklist ) ? ResultFactory :: makeError ( $ this , 'Blacklist is empty.' ) : null ; }
Returns error if compiled blacklist is empty .
24,221
public function serialize ( ) { $ device = $ this -> getDevice ( ) ; $ spec = array ( 'browser_type' => $ this -> _browserType , 'config' => $ this -> _config , 'device_class' => get_class ( $ device ) , 'device' => $ device -> serialize ( ) , 'user_agent' => $ this -> getServerValue ( 'http_user_agent' ) , 'http_accept' => $ this -> getServerValue ( 'http_accept' ) , ) ; return serialize ( $ spec ) ; }
Serialized representation of the object
24,222
public function unserialize ( $ serialized ) { $ spec = unserialize ( $ serialized ) ; $ this -> setOptions ( $ spec ) ; $ deviceClass = $ spec [ 'device_class' ] ; if ( ! class_exists ( $ deviceClass ) ) { $ this -> _getUserAgentDevice ( $ this -> getBrowserType ( ) ) ; } $ deviceSpec = unserialize ( $ spec [ 'device' ] ) ; $ deviceSpec [ '_config' ] = $ this -> getConfig ( ) ; $ deviceSpec [ '_server' ] = $ this -> getServer ( ) ; $ this -> _device = new $ deviceClass ( $ deviceSpec ) ; }
Unserialize a previous representation of the object
24,223
protected function _match ( $ deviceClass ) { $ r = new ReflectionClass ( $ deviceClass ) ; if ( ! $ r -> implementsInterface ( 'Zend_Http_UserAgent_Device' ) ) { throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device' , $ deviceClass ) ) ; } $ userAgent = $ this -> getUserAgent ( ) ; return call_user_func ( array ( $ deviceClass , 'match' ) , $ userAgent , $ this -> getServer ( ) ) ; }
Comparison of the UserAgent chain and browser signatures .
24,224
protected function _getUserAgentDevice ( $ browserType ) { $ browserType = strtolower ( $ browserType ) ; if ( isset ( $ this -> _browserTypeClass [ $ browserType ] ) ) { return $ this -> _browserTypeClass [ $ browserType ] ; } if ( isset ( $ this -> _config [ $ browserType ] ) && isset ( $ this -> _config [ $ browserType ] [ 'device' ] ) ) { $ deviceConfig = $ this -> _config [ $ browserType ] [ 'device' ] ; if ( is_array ( $ deviceConfig ) && isset ( $ deviceConfig [ 'classname' ] ) ) { $ device = ( string ) $ deviceConfig [ 'classname' ] ; if ( ! class_exists ( $ device ) ) { throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Invalid classname "%s" provided in device configuration for browser type "%s"' , $ device , $ browserType ) ) ; } } elseif ( is_array ( $ deviceConfig ) && isset ( $ deviceConfig [ 'path' ] ) ) { $ loader = $ this -> getPluginLoader ( 'device' ) ; $ path = $ deviceConfig [ 'path' ] ; $ prefix = isset ( $ deviceConfig [ 'prefix' ] ) ? $ deviceConfig [ 'prefix' ] : 'Zend_Http_UserAgent' ; $ loader -> addPrefixPath ( $ prefix , $ path ) ; $ device = $ loader -> load ( $ browserType ) ; } else { $ loader = $ this -> getPluginLoader ( 'device' ) ; $ device = $ loader -> load ( $ browserType ) ; } } else { $ loader = $ this -> getPluginLoader ( 'device' ) ; $ device = $ loader -> load ( $ browserType ) ; } $ this -> _browserTypeClass [ $ browserType ] = $ device ; return $ device ; }
Loads class for a user agent device
24,225
public function getUserAgent ( ) { if ( null === ( $ ua = $ this -> getServerValue ( 'http_user_agent' ) ) ) { $ ua = self :: DEFAULT_HTTP_USER_AGENT ; $ this -> setUserAgent ( $ ua ) ; } return $ ua ; }
Returns the User Agent value
24,226
public function getHttpAccept ( $ httpAccept = null ) { if ( null === ( $ accept = $ this -> getServerValue ( 'http_accept' ) ) ) { $ accept = self :: DEFAULT_HTTP_ACCEPT ; $ this -> setHttpAccept ( $ accept ) ; } return $ accept ; }
Returns the HTTP Accept server param
24,227
public function setStorage ( Zend_Http_UserAgent_Storage $ storage ) { if ( $ this -> _immutable ) { throw new Zend_Http_UserAgent_Exception ( 'The User-Agent device object has already been retrieved; the storage object is now immutable' ) ; } $ this -> _storage = $ storage ; return $ this ; }
Sets the persistent storage handler
24,228
public function setConfig ( $ config = array ( ) ) { if ( $ config instanceof Zend_Config ) { $ config = $ config -> toArray ( ) ; } if ( ! is_array ( $ config ) && ! $ config instanceof Traversable ) { throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Config parameters must be in an array or a Traversable object; received "%s"' , ( is_object ( $ config ) ? get_class ( $ config ) : gettype ( $ config ) ) ) ) ; } if ( $ config instanceof Traversable ) { $ tmp = array ( ) ; foreach ( $ config as $ key => $ value ) { $ tmp [ $ key ] = $ value ; } $ config = $ tmp ; unset ( $ tmp ) ; } $ this -> _config = array_merge ( $ this -> _config , $ config ) ; return $ this ; }
Config parameters is an Array or a Zend_Config object
24,229
public function getDevice ( ) { if ( null !== $ this -> _device ) { return $ this -> _device ; } $ userAgent = $ this -> getUserAgent ( ) ; $ storage = $ this -> getStorage ( $ userAgent ) ; if ( ! $ storage -> isEmpty ( ) ) { $ object = $ storage -> read ( ) ; $ this -> unserialize ( $ object ) ; } else { $ this -> setBrowserType ( $ this -> _matchUserAgent ( ) ) ; $ this -> _createDevice ( ) ; $ this -> getStorage ( $ userAgent ) -> write ( $ this -> serialize ( ) ) ; } $ this -> _immutable = true ; return $ this -> _device ; }
Returns the device object
24,230
public function getServerValue ( $ key ) { $ key = strtolower ( $ key ) ; $ server = $ this -> getServer ( ) ; $ return = null ; if ( isset ( $ server [ $ key ] ) ) { $ return = $ server [ $ key ] ; } unset ( $ server ) ; return $ return ; }
Retrieve a server value
24,231
public function setServerValue ( $ key , $ value ) { if ( $ this -> _immutable ) { throw new Zend_Http_UserAgent_Exception ( 'The User-Agent device object has already been retrieved; the server array is now immutable' ) ; } $ server = $ this -> getServer ( ) ; $ key = strtolower ( $ key ) ; $ this -> _server [ $ key ] = $ value ; return $ this ; }
Set a server value
24,232
public function setPluginLoader ( $ type , $ loader ) { $ type = $ this -> _validateLoaderType ( $ type ) ; if ( is_string ( $ loader ) ) { if ( ! class_exists ( $ loader ) ) { Zend_Loader :: loadClass ( $ loader ) ; } $ loader = new $ loader ( ) ; } elseif ( ! is_object ( $ loader ) ) { throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Expected a plugin loader class or object; received %s' , gettype ( $ loader ) ) ) ; } if ( ! $ loader instanceof Zend_Loader_PluginLoader ) { throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Expected an object extending Zend_Loader_PluginLoader; received %s' , get_class ( $ loader ) ) ) ; } $ basePrefix = 'Zend_Http_UserAgent_' ; $ basePath = 'Zend/Http/UserAgent/' ; switch ( $ type ) { case 'storage' : $ prefix = $ basePrefix . 'Storage' ; $ path = $ basePath . 'Storage' ; break ; case 'device' : $ prefix = $ basePrefix ; $ path = $ basePath ; break ; } $ loader -> addPrefixPath ( $ prefix , $ path ) ; $ this -> _loaders [ $ type ] = $ loader ; return $ this ; }
Set plugin loader
24,233
public function getPluginLoader ( $ type ) { $ type = $ this -> _validateLoaderType ( $ type ) ; if ( ! isset ( $ this -> _loaders [ $ type ] ) ) { $ this -> setPluginLoader ( $ type , new Zend_Loader_PluginLoader ( ) ) ; } return $ this -> _loaders [ $ type ] ; }
Get a plugin loader
24,234
protected function _validateLoaderType ( $ type ) { $ type = strtolower ( $ type ) ; if ( ! in_array ( $ type , $ this -> _loaderTypes ) ) { $ types = implode ( ', ' , $ this -> _loaderTypes ) ; throw new Zend_Http_UserAgent_Exception ( sprintf ( 'Expected one of "%s" for plugin loader type; received "%s"' , $ types , ( string ) $ type ) ) ; } return $ type ; }
Validate a plugin loader type
24,235
protected function _matchUserAgent ( ) { $ type = self :: DEFAULT_BROWSER_TYPE ; if ( empty ( $ this -> _config [ 'identification_sequence' ] ) ) { return $ type ; } $ sequence = explode ( ',' , $ this -> _config [ 'identification_sequence' ] ) ; if ( null !== ( $ browserType = $ this -> getBrowserType ( ) ) ) { array_unshift ( $ sequence , $ browserType ) ; } if ( ! in_array ( $ type , $ sequence ) ) { $ sequence [ ] = $ type ; } foreach ( $ sequence as $ browserType ) { $ browserType = trim ( $ browserType ) ; $ className = $ this -> _getUserAgentDevice ( $ browserType ) ; if ( $ this -> _match ( $ className ) ) { $ type = $ browserType ; $ this -> _browserTypeClass [ $ type ] = $ className ; break ; } } return $ type ; }
Run the identification sequence to match the right browser type according to the user agent
24,236
protected function _createDevice ( ) { $ browserType = $ this -> getBrowserType ( ) ; $ classname = $ this -> _getUserAgentDevice ( $ browserType ) ; $ this -> _device = new $ classname ( $ this -> getUserAgent ( ) , $ this -> getServer ( ) , $ this -> getConfig ( ) ) ; }
Creates device object instance
24,237
function convertToHours ( ) { $ totalMinutes = $ this -> minutes ; $ Mins = ( $ totalMinutes % 60 ) ; $ Hours = floor ( abs ( $ totalMinutes ) / 60 ) ; if ( $ totalMinutes < 0 ) { $ Hours = '-' . $ Hours ; $ Mins = substr ( $ Mins , 1 ) ; } else { $ Hours = floor ( $ totalMinutes / 60 ) ; } $ Mins = str_pad ( $ Mins , 2 , '0' , STR_PAD_LEFT ) ; $ this -> HM = new HM ( $ Hours , $ Mins ) ; return $ this ; }
Umwandlung der Minuten in Stunden und Minuten . Z . B . 3170 Min . = 52 Std . und 50 Min .
24,238
public function innerXml ( ) { $ children = '' ; foreach ( $ this -> getChildren ( ) as $ child ) { $ children .= ( string ) $ child ; } return $ this -> getText ( ) . $ children ; }
Get xml without root element .
24,239
public function outerXml ( ) { $ attributes = '' ; foreach ( $ this -> getAttributes ( ) as $ name => $ value ) { if ( $ value === null ) { $ attributes .= " $name" ; } else { $ value = addslashes ( $ value ) ; $ attributes .= " $name=\"$value\"" ; } } if ( $ this -> getText ( ) === null && count ( $ this -> getChildren ( ) ) == 0 ) { return "<{$this->getName()}$attributes/>" ; } return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>" ; }
Get xml with root element .
24,240
private static function compareLogLevel ( $ a , $ b ) { static $ defs ; if ( ! $ defs ) { $ defs = array ( 'F' => LogLevel :: FATAL , 'E' => LogLevel :: ERROR , 'W' => LogLevel :: WARNING , 'I' => LogLevel :: INFO , 'D' => LogLevel :: DEBUG , 'T' => LogLevel :: TRACE , ) ; } $ a = $ defs [ $ a ] ?? LogLevel :: INFO ; $ b = $ defs [ $ b ] ?? LogLevel :: INFO ; return ( $ a - $ b ) ; }
compare log levels
24,241
public function onKernelException ( GetResponseForExceptionEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; if ( $ this -> kernelDebug && $ this -> debugParameter && $ request -> query -> has ( $ this -> debugParameter ) ) { return ; } $ exception = $ event -> getException ( ) ; $ errorPresentation = $ this -> errorPresentationFactory -> create ( $ exception ) ; if ( ! $ errorPresentation ) { return ; } if ( ! $ errorPresentation -> getResource ( ) ) { $ event -> setResponse ( new Response ( '' , $ errorPresentation -> getStatusCode ( ) ) ) ; return ; } $ acceptMediaType = null ; try { $ serializer = $ this -> serializerResolver -> resolveByMediaTypes ( get_class ( $ errorPresentation -> getResource ( ) ) , $ request -> getAcceptableContentTypes ( ) , $ acceptMediaType ) ; } catch ( ResourceSerializerNotFoundException $ e ) { return ; } $ context = $ this -> serializationContextCollector -> collect ( ) ; $ serializedData = $ serializer -> serialize ( $ errorPresentation -> getResource ( ) , $ context ) ; $ response = new Response ( $ serializedData , $ errorPresentation -> getStatusCode ( ) , [ 'Content-Type' => $ acceptMediaType , ] ) ; $ event -> setResponse ( $ response ) ; }
Render the exception for sending to client
24,242
public function help ( ) { $ style = new Style ( ' *** RUN - HELP ***' ) ; Out :: std ( $ style -> color ( 'fg' , Style :: COLOR_GREEN ) -> get ( ) ) ; Out :: std ( '' ) ; $ help = new Eurekon \ Help ( '...' , true ) ; $ help -> addArgument ( 'p' , 'password' , 'Password to hash. If empty, generate on' , true , false ) ; $ help -> addArgument ( 'l' , 'length' , 'Length for password generated (default 16 chars)' , true , false ) ; $ help -> display ( ) ; }
Help method . Must be overridden .
24,243
public function run ( ) { $ argument = Eurekon \ Argument :: getInstance ( ) ; $ passwordPlain = ( string ) $ argument -> get ( 'p' , 'password' ) ; $ length = ( int ) $ argument -> get ( 'l' , 'length' , 16 ) ; $ password = new Password ( $ passwordPlain ) ; if ( empty ( $ passwordPlain ) ) { $ password -> generate ( $ length ) ; } $ password -> hash ( ) ; $ green = ( new Style ( ) ) -> highlight ( 'fg' ) -> color ( 'fg' , Style :: COLOR_GREEN ) ; $ white = ( new Style ( ) ) -> highlight ( 'fg' ) -> color ( 'fg' , Style :: COLOR_WHITE ) ; Out :: std ( ( string ) $ green -> setText ( 'Password: ' ) . ( string ) $ white -> setText ( $ password -> getPlain ( ) ) ) ; Out :: std ( ( string ) $ green -> setText ( 'Hash: ' ) . ( string ) $ white -> setText ( $ password -> getHash ( ) ) ) ; }
Run method . Must be overridden .
24,244
final public static function set ( $ key , $ value ) { self :: _checkInstance ( ) ; self :: $ _instance -> offsetSet ( $ key , $ value ) ; }
Sets data to singleton instance .
24,245
protected function checkAccess ( $ permission ) : bool { return $ this -> app -> core -> user -> permissions [ $ this -> app -> getName ( ) ] -> allowedTo ( $ permission ) ; }
Checks the current users permissions against one or more permissions
24,246
public function setAction ( string $ action ) { $ string = new CamelCase ( $ action ) ; $ this -> action = $ string -> camelize ( ) ; }
Sets controller action
24,247
public function with ( string $ param , string $ regex ) : Route { $ this -> params [ $ param ] = str_replace ( '(' , '(?:' , $ regex ) ; return $ this ; }
Params match regex
24,248
public function run ( $ id ) { $ model = $ this -> getModel ( $ id ) ; return $ this -> controller -> render ( $ this -> view , [ $ this -> nameVariableModel => $ model , ] ) ; }
Views existing record .
24,249
public function getOption ( $ name ) { if ( ! $ this -> hasOption ( $ name ) ) { return null ; } $ getter = 'get' . ucfirst ( $ name ) ; return $ this -> options -> { $ getter } ( ) ; }
get an option by name
24,250
public function hasOption ( $ prop ) { $ prop = ( string ) $ prop ; if ( is_object ( $ this -> options ) ) { $ getter = 'get' . ucfirst ( $ prop ) ; return method_exists ( $ this -> options , $ getter ) ; } return false ; }
Check to see if option exists
24,251
public function get ( $ argument , $ alias = null , $ default = null ) { if ( isset ( $ this -> arguments [ $ argument ] ) ) { return $ this -> arguments [ $ argument ] ; } else if ( ! empty ( $ alias ) && isset ( $ this -> arguments [ $ alias ] ) ) { return $ this -> arguments [ $ alias ] ; } else { return $ default ; } }
Get specified argument value .
24,252
public function has ( $ argument , $ alias = null ) { if ( isset ( $ this -> arguments [ $ argument ] ) ) { return true ; } else if ( ! empty ( $ alias ) && isset ( $ this -> arguments [ $ alias ] ) ) { return true ; } else { return false ; } }
Check if argument exists .
24,253
public function parse ( Array $ arguments ) { $ this -> arguments = array ( ) ; $ arguments = new ArgumentIterator ( $ arguments ) ; foreach ( $ arguments as $ current ) { $ arguments -> next ( ) ; $ next = ( $ arguments -> valid ( ) ? $ arguments -> current ( ) : '' ) ; $ arguments -> prev ( ) ; $ arg1 = substr ( $ current , 0 , 1 ) ; $ arg2 = substr ( $ current , 0 , 2 ) ; if ( '--' == $ arg2 ) { $ arg = array ( ) ; $ match = preg_match ( '`--([0-9a-z_-]+)="?(.+)"?`' , $ current , $ arg ) ; if ( $ match > 0 ) { $ this -> arguments [ $ arg [ 1 ] ] = $ arg [ 2 ] ; } else if ( ! empty ( $ next ) && '-' !== substr ( $ next , 0 , 1 ) ) { $ this -> arguments [ substr ( $ current , 2 ) ] = $ next ; } else { $ this -> arguments [ substr ( $ current , 2 ) ] = true ; } } elseif ( '-' == $ arg1 ) { $ arg = substr ( $ current , 1 ) ; $ len = strlen ( $ arg ) ; if ( 1 == $ len && ! empty ( $ next ) && '-' != substr ( $ next , 0 , 1 ) ) { $ this -> arguments [ $ arg ] = $ next ; } else { for ( $ letter = 0 ; $ letter < $ len ; $ letter ++ ) { $ this -> arguments [ $ arg [ $ letter ] ] = true ; } } } } return $ this ; }
Parse argument from command lines .
24,254
private function getCommandNamespace ( ) { $ concrete_namespace = $ this -> getCommandDeclaredNamespace ( ) ; if ( $ this -> hasOption ( 'system-folder' ) ) { $ concrete_namespace = $ concrete_namespace . '\\' . $ this -> option ( 'system-folder' ) ; } if ( $ this -> hasOption ( 'folder' ) ) { if ( $ this -> option ( 'folder' ) ) { $ concrete_namespace = $ concrete_namespace . '\\' . $ this -> option ( 'folder' ) ; } } return $ this -> sanitizedPath ( $ concrete_namespace ) ; }
Get the namespace for the generator . This will set the system folder | folder of the module .
24,255
public function json ( $ file = null ) { if ( is_null ( $ file ) ) { $ file = 'component.json' ; } return new Json ( $ this -> getPath ( ) . '/' . $ file , $ this -> app [ 'files' ] ) ; }
Get json contents .
24,256
public function enable ( ) { $ this -> app [ 'events' ] -> fire ( 'component.enabling' , [ $ this ] ) ; $ this -> setActive ( 1 ) ; $ this -> app [ 'events' ] -> fire ( 'component.enabled' , [ $ this ] ) ; }
Enable the current component .
24,257
public static function setupHome ( $ home ) { if ( empty ( $ home ) ) { throw new \ InvalidArgumentException ( 'Empty home directory encountered.' ) ; } if ( false === getenv ( 'COMPOSER' ) ) { putenv ( 'COMPOSER=' . $ home . DIRECTORY_SEPARATOR . 'composer.json' ) ; } chdir ( $ home ) ; if ( ! getenv ( 'COMPOSER_HOME' ) && ! getenv ( 'HOME' ) ) { putenv ( 'COMPOSER_HOME=' . $ home ) ; } }
Detect the correct tenside home dir and set the environment variable .
24,258
protected function _useNode ( ) { $ current = $ this -> _states [ 'current' ] ; $ token = $ this -> _stream -> current ( true ) ; $ last = $ alias = $ use = '' ; $ as = false ; $ stop = ';' ; $ prefix = '' ; while ( $ token [ 1 ] !== $ stop ) { $ this -> _states [ 'body' ] .= $ token [ 1 ] ; if ( ! $ token = $ this -> _stream -> next ( true ) ) { break ; } switch ( $ token [ 0 ] ) { case ',' : $ as ? $ this -> _states [ 'uses' ] [ $ alias ] = $ prefix . $ use : $ this -> _states [ 'uses' ] [ $ last ] = $ prefix . $ use ; $ last = $ alias = $ use = '' ; $ as = false ; break ; case T_STRING : $ last = $ token [ 1 ] ; case T_NS_SEPARATOR : $ as ? $ alias .= $ token [ 1 ] : $ use .= $ token [ 1 ] ; break ; case T_AS : $ as = true ; break ; case '{' : $ prefix = $ use ; $ use = '' ; $ stop = $ current -> type === 'class' ? '}' : ';' ; break ; } } $ this -> _states [ 'body' ] .= $ token [ 0 ] ; $ as ? $ this -> _states [ 'uses' ] [ $ alias ] = $ prefix . $ use : $ this -> _states [ 'uses' ] [ $ last ] = $ prefix . $ use ; $ this -> _codeNode ( 'use' ) ; }
Manage use statement .
24,259
protected function _functionNode ( ) { $ node = new FunctionDef ( ) ; $ token = $ this -> _stream -> current ( true ) ; $ parent = $ this -> _states [ 'current' ] ; $ body = $ token [ 1 ] ; $ name = substr ( $ this -> _stream -> next ( '(' ) , 0 , - 1 ) ; $ body .= $ name ; $ node -> name = trim ( $ name ) ; $ args = $ this -> _parseArgs ( ) ; $ node -> args = $ args [ 'args' ] ; $ body .= $ args [ 'body' ] . $ this -> _stream -> next ( [ ';' , '{' ] ) ; if ( $ parent ) { $ isMethod = $ parent -> hasMethods ; if ( $ parent -> type === 'interface' ) { $ node -> type = 'signature' ; } } else { $ isMethod = false ; } $ node -> isMethod = $ isMethod ; $ node -> isClosure = ! $ node -> name ; if ( $ isMethod ) { $ node -> visibility = $ this -> _states [ 'visibility' ] ; $ this -> _states [ 'visibility' ] = [ ] ; } $ node -> body = $ body ; $ this -> _codeNode ( ) ; $ this -> _states [ 'body' ] = $ body ; $ this -> _contextualize ( $ node ) ; if ( $ this -> _stream -> current ( ) === '{' ) { $ this -> _states [ 'current' ] = $ node ; } return $ node -> function = $ node ; }
Build a function node .
24,260
public function getValidator ( $ alias ) { if ( array_key_exists ( $ alias , $ this -> validators ) ) { $ validator = $ this -> validators [ $ alias ] ; return new $ validator ( $ this -> translator , $ this -> presenceVerifier ) ; } throw new \ UnexpectedValueException ( "Unknown validator {$alias}" ) ; }
Returns validator by it s alias .
24,261
protected static function compileValidPattern ( ) { self :: compileUnencodedCharacters ( ) ; $ valid_characters = self :: $ unreserved_pattern . self :: $ sub_delims_pattern ; $ ip_v_future_pattern = '\[[\:' . $ valid_characters . ']+\]' ; $ reg_name_pattern = '([' . $ valid_characters . ']|' . self :: $ pct_encoded_pattern . ')*' ; self :: $ part_pattern = $ ip_v_future_pattern . '|' . $ reg_name_pattern ; self :: $ valid_pattern = '/^$|^' . $ ip_v_future_pattern . '$|^' . $ reg_name_pattern . '$/' ; }
Compiles validation patterns for a URI host .
24,262
public function connect ( $ type , $ host , $ dbname = '' , $ username = null , $ password = null , array $ options = array ( ) ) { if ( $ this -> PDO ) { return $ this ; } $ dsn = '' ; if ( $ type == 'sqlite' ) { $ dsn = "{$type}:{$host}" ; } else { $ dsn = "{$type}:host={$host};dbname={$dbname}" ; } $ PDO = new PDO ( $ dsn , $ username , $ password , $ options ) ; if ( ! $ PDO ) { return false ; } $ this -> PDO = $ PDO ; $ this -> setEscapeChar ( ) ; return $ this ; }
Connect to a database
24,263
public function load ( array $ configs , ContainerBuilder $ container ) { $ configs [ ] = $ this -> options ; $ configuration = $ this -> getConfiguration ( $ configs , $ container ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ container -> register ( 'templating' , 'Symfony\Component\Templating\DelegatingEngine' ) ; $ container -> register ( 'templating.template_name_parser' , 'Symfony\Component\Templating\TemplateNameParser' ) ; if ( true === $ config [ 'enable_php_engine' ] ) { $ container -> setParameter ( 'php.template_dir' , $ config [ 'template_dir' ] ) ; $ container -> register ( 'templating.engine.php.loader' , 'Symfony\Component\Templating\Loader\FilesystemLoader' ) -> setPublic ( false ) -> addArgument ( '%php.template_dir%/%%name%%' ) ; $ container -> register ( 'templating.engine.php.helper.slots' , 'Symfony\Component\Templating\Helper\SlotsHelper' ) ; $ container -> register ( 'templating.engine.php.helper.assets' , 'Nice\Templating\Helper\AssetsHelper' ) -> addArgument ( new Reference ( 'service_container' ) ) ; $ container -> register ( 'templating.engine.php.helper.router' , 'Nice\Templating\Helper\RouterHelper' ) -> addArgument ( new Reference ( 'service_container' ) ) ; $ container -> register ( 'templating.engine.php' , 'Symfony\Component\Templating\PhpEngine' ) -> addArgument ( new Reference ( 'templating.template_name_parser' ) ) -> addArgument ( new Reference ( 'templating.engine.php.loader' ) ) -> addMethodCall ( 'set' , array ( new Reference ( 'templating.engine.php.helper.slots' ) ) ) -> addMethodCall ( 'set' , array ( new Reference ( 'templating.engine.php.helper.assets' ) ) ) -> addMethodCall ( 'set' , array ( new Reference ( 'templating.engine.php.helper.router' ) ) ) -> addTag ( 'templating.engine' ) ; } }
Loads a specific configuration
24,264
protected function validateOtherAmount ( AmountInterface $ amount ) { if ( $ this -> getCurrency ( ) -> getCurrencyCode ( ) !== $ amount -> getCurrency ( ) -> getCurrencyCode ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Both amounts must be in %s, but the other amount is in %s.' , $ this -> getCurrency ( ) -> getCurrencyCode ( ) , $ amount -> getCurrency ( ) -> getCurrencyCode ( ) ) ) ; } }
Validates another amount against this one .
24,265
protected function validateNumber ( $ number ) { if ( ! ( is_int ( $ number ) || is_string ( $ number ) && is_numeric ( $ number ) ) ) { $ type = is_object ( $ number ) ? get_class ( $ number ) : gettype ( $ number ) ; throw new \ InvalidArgumentException ( sprintf ( 'An integer or numeric string was expected, but %s was given.' , $ type ) ) ; } }
Checks that a value is a number .
24,266
protected function comparesTo ( AmountInterface $ amount ) { $ this -> validateOtherAmount ( $ amount ) ; return bccomp ( $ this -> getAmount ( ) , $ amount -> getAmount ( ) , static :: BC_MATH_SCALE ) ; }
Compares this amount to another .
24,267
public function showPage ( $ pageName = 'index' ) { if ( ! $ this -> page -> exists ( $ pageName ) ) { return \ Response :: view ( $ this -> theme . '.404' , array ( 'global' => $ this -> global ) , 404 ) ; } $ page = $ this -> page -> get ( $ pageName ) ; $ viewParamaters = array ( 'global' => $ this -> global , 'page' => $ page ) ; if ( \ View :: exists ( $ this -> theme . '.' . $ pageName ) ) { return \ View :: make ( $ this -> theme . '.' . $ pageName , $ viewParamaters ) ; } else { return \ View :: make ( $ this -> theme . '.page' , $ viewParamaters ) ; } }
Show a single requested page .
24,268
protected function addAttachments ( ) { if ( class_exists ( 'Finfo' , false ) ) { $ finfo = new \ Finfo ( FILEINFO_MIME_TYPE ) ; } else { $ finfo = null ; } foreach ( $ this -> mail -> attachments as $ filename => $ attachment ) { if ( ! is_array ( $ attachment ) ) { throw new Exception \ RuntimeException ( sprintf ( "Attachments must be array, %s passed" , gettype ( $ attachment ) ) ) ; } elseif ( ! is_string ( $ attachment [ 'content' ] ) && ( ! is_resource ( $ attachment [ 'content' ] ) || ! get_resource_type ( $ attachment [ 'content' ] ) == 'stream' ) ) { throw new Exception \ RuntimeException ( sprintf ( "Attachment content must be string or stream, %s passed" , gettype ( $ attachment [ 'content' ] ) ) ) ; } $ type = null ; if ( empty ( $ attachment [ 'mime_type' ] ) && $ finfo ) { if ( is_resource ( $ attachment [ 'content' ] ) ) { $ type = $ finfo -> buffer ( stream_get_contents ( $ attachment [ 'content' ] ) ) ; rewind ( $ attachment [ 'content' ] ) ; } else { $ type = $ finfo -> buffer ( $ attachment [ 'content' ] ) ; } } $ part = new Mime \ Part ( $ attachment [ 'content' ] ) ; if ( empty ( $ attachment [ 'encoding' ] ) ) { $ attachment [ 'encoding' ] = Mime \ Mime :: ENCODING_BASE64 ; } $ part -> encoding = $ attachment [ 'encoding' ] ; if ( $ type ) { $ part -> type = $ type ; } if ( ! empty ( $ attachment [ 'inline' ] ) ) { $ part -> disposition = Mime \ Mime :: DISPOSITION_INLINE ; } else { $ part -> disposition = Mime \ Mime :: DISPOSITION_ATTACHMENT ; } $ this -> body -> addPart ( $ part ) ; } }
Requires Fileinfo .
24,269
public function setMode ( $ mode ) { $ mode = strtolower ( $ mode ) ; if ( ( $ mode != 'bz2' ) && ( $ mode != 'gz' ) ) { throw new Exception \ InvalidArgumentException ( "The mode '$mode' is unknown" ) ; } if ( ( $ mode == 'bz2' ) && ( ! extension_loaded ( 'bz2' ) ) ) { throw new Exception \ ExtensionNotLoadedException ( 'This mode needs the bz2 extension' ) ; } if ( ( $ mode == 'gz' ) && ( ! extension_loaded ( 'zlib' ) ) ) { throw new Exception \ ExtensionNotLoadedException ( 'This mode needs the zlib extension' ) ; } $ this -> options [ 'mode' ] = $ mode ; return $ this ; }
Compression mode to use
24,270
public function ajaxGetQueues ( ) { $ data = Base :: getJobsRepository ( ) -> orderBy ( 'created_at' , 'desc' ) -> take ( 300 ) -> get ( [ 'queue' , 'payload' , 'attempts' , 'reserved' , 'reserved_at' , 'created_at' ] ) ; foreach ( $ data as $ d ) { $ obj = json_decode ( $ d -> payload ) ; $ d -> payload = $ obj -> job ; $ d -> data = json_encode ( $ obj -> data -> data ) ; } return \ Response :: json ( array ( 'data' => $ data ) ) ; }
Ajax call to get all the queues
24,271
public function ajaxGetVisits ( ) { $ data = Base :: getVisitsRepository ( ) -> orderBy ( 'created_at' , 'desc' ) -> take ( 300 ) -> get ( [ 'url' , 'browser' , 'ip' , 'created_at' , 'country' ] ) ; return \ Response :: json ( array ( 'data' => $ data ) ) ; }
Ajax call to get all the visits
24,272
public function getReflectionClass ( ) { if ( $ this -> reflectionClass === null ) { $ this -> reflectionClass = new ReflectionClass ( $ this -> getName ( ) ) ; } return $ this -> reflectionClass ; }
Gets the reflection class for this object type .
24,273
public function getMethods ( ) { $ result = array ( ) ; foreach ( $ this -> getReflectionClass ( ) -> getMethods ( ) as $ m ) { $ result [ ] = MethodInfo :: __internal_create ( $ this , $ m ) ; } return $ result ; }
Gets a list of all defined methods .
24,274
public function getMethod ( $ name ) { $ m = $ this -> getReflectionClass ( ) -> getMethod ( $ name ) ; return MethodInfo :: __internal_create ( $ this , $ m ) ; }
Gets as method by its name .
24,275
protected function GetInvitationCode ( ) { $ Code = RandomString ( 8 ) ; $ CodeData = $ this -> GetWhere ( array ( 'Code' => $ Code ) ) ; if ( $ CodeData -> NumRows ( ) > 0 ) { return $ this -> GetInvitationCode ( ) ; } else { return $ Code ; } }
Returns a unique 8 character invitation code
24,276
public function addFace ( EntityFace $ face ) { $ this -> facesByName [ $ face -> getName ( ) ] = $ face ; $ this -> facesByClass [ $ face -> getClass ( ) ] = $ face -> getName ( ) ; }
Add a face to the list of available faces
24,277
public function withAuthority ( $ authority ) { $ with_authority = new Authority ( $ authority ) ; $ new_authority_uri = clone $ this ; $ new_authority_uri -> authority = $ with_authority ; $ new_authority_uri -> user_info = $ with_authority -> getUserInfo ( ) ; $ new_authority_uri -> host = $ with_authority -> getHost ( ) ; $ new_authority_uri -> port = $ with_authority -> getPort ( ) ; return $ new_authority_uri ; }
Return an instance with the specified authority .
24,278
private function explodeUri ( $ uri ) { $ uri_parts = array ( "scheme" => "" , "hier_part" => "" , "authority" => "" , "path" => "" , "query" => "" , "fragment" => "" , ) ; $ uri_syntax = $ this -> compileUriRegEx ( ) ; $ uri_valid = preg_match ( $ uri_syntax , $ uri , $ parts ) ; $ uri_parts = array_merge ( $ uri_parts , $ parts ) ; $ this -> parseExplosions ( $ uri_parts ) ; return ( bool ) $ uri_valid ; }
Splits a string URI into its component parts returning true if the URI string matches a valid URI s syntax and false if the URI string does not
24,279
private function compileUriRegEx ( ) { $ reg_start = '/^' ; $ scheme_part = '(?:(?\'scheme\'[A-Za-z0-9][^\/\?#:]+):)?' ; $ authority_part = '(?:(?:\/\/)(?\'authority\'[^\/]*))?' ; $ path_part = '(?\'path\'[^\?#]*)?' ; $ query_part = '(?:\?(?\'query\'[^#]*))?' ; $ fragment_part = '(?:#(?\'fragment\'.*))?' ; $ reg_end = '/' ; return $ reg_start . $ scheme_part . $ authority_part . $ path_part . $ query_part . $ fragment_part . $ reg_end ; }
Compiles a regular expression to match URI component parts
24,280
private function parseExplosions ( $ uri_parts ) { $ this -> scheme = new Scheme ( $ uri_parts [ "scheme" ] ) ; $ this -> query = new Query ( $ uri_parts [ "query" ] ) ; $ this -> fragment = new Fragment ( $ uri_parts [ "fragment" ] ) ; $ this -> authority = new Authority ( $ uri_parts [ "authority" ] ) ; $ this -> user_info = $ this -> authority -> getUserInfo ( ) ; $ this -> host = $ this -> authority -> getHost ( ) ; $ this -> port = $ this -> authority -> getPort ( ) ; $ this -> path = new Path ( $ uri_parts [ "path" ] ) ; }
Parses the results of exploding URI parts . Creates component objects .
24,281
protected function _setFirewall ( ) { $ csrf = explode ( '.' , $ this -> _configFirewall [ 'csrf' ] [ 'name' ] ) ; $ logged = explode ( '.' , $ this -> _configFirewall [ 'logged' ] [ 'name' ] ) ; $ role = explode ( '.' , $ this -> _configFirewall [ 'roles' ] [ 'name' ] ) ; $ this -> _csrf [ 'POST' ] = $ this -> _setFirewallConfigArray ( $ _POST , $ csrf ) ; $ this -> _csrf [ 'GET' ] = $ this -> _setFirewallConfigArray ( $ _GET , $ csrf ) ; $ this -> _csrf [ 'SESSION' ] = $ this -> _setFirewallConfigArray ( $ _SESSION , $ csrf ) ; $ this -> _logged = $ this -> _setFirewallConfigArray ( $ _SESSION , $ logged ) ; $ this -> _role = $ this -> _setFirewallConfigArray ( $ _SESSION , $ role ) ; }
set firewall configuration
24,282
function lastday ( $ month , $ day , $ year ) { $ lastdayen = date ( "d" , mktime ( 0 , 0 , 0 , $ month + 1 , 0 , $ year ) ) ; list ( $ jyear , $ jmonth , $ jday ) = $ this -> gregorian_to_jalali ( $ year , $ month , $ day ) ; $ lastdatep = $ jday ; $ jday = $ jday2 ; while ( $ jday2 != "1" ) { if ( $ day < $ lastdayen ) { $ day ++ ; list ( $ jyear , $ jmonth , $ jday2 ) = $ this -> gregorian_to_jalali ( $ year , $ month , $ day ) ; if ( $ pdate2 == "1" ) break ; if ( $ pdate2 != "1" ) $ lastdatep ++ ; } else { $ day = 0 ; $ month ++ ; if ( $ month == 13 ) { $ month = "1" ; $ year ++ ; } } } return $ lastdatep - 1 ; }
Find Number Of Days In This Month
24,283
public function prepare ( ) { $ request = parent :: prepare ( ) ; $ url = $ request -> getUrl ( true ) ; $ query = $ url -> getQuery ( ) ; $ query -> merge ( $ this -> templateVariables ) ; $ request -> setUrl ( $ url ) ; return $ request ; }
add the template variables to the query part
24,284
protected function addKinesisConfiguration ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'kinesis' ) -> children ( ) -> scalarNode ( 'api_version' ) -> defaultValue ( '2013-12-02' ) -> end ( ) -> scalarNode ( 'region' ) -> isRequired ( ) -> end ( ) -> arrayNode ( 'consumer' ) -> children ( ) -> scalarNode ( 'recovery_file' ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'key' ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'secret' ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> arrayNode ( 'producer' ) -> children ( ) -> scalarNode ( 'key' ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'secret' ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; }
Adds Kinesis configuration .
24,285
protected function addDynamoDBConfiguration ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'dynamodb' ) -> children ( ) -> scalarNode ( 'api_version' ) -> defaultValue ( '2012-08-10' ) -> end ( ) -> scalarNode ( 'region' ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; }
Adds DynamoDb configuration .
24,286
public function crop ( $ startX , $ startY , $ cropWidth , $ cropHeight ) { if ( ! is_numeric ( $ startX ) ) { throw new InvalidArgumentException ( '$startX must be numeric' ) ; } if ( ! is_numeric ( $ startY ) ) { throw new InvalidArgumentException ( '$startY must be numeric' ) ; } if ( ! is_numeric ( $ cropWidth ) ) { throw new InvalidArgumentException ( '$cropWidth must be numeric' ) ; } if ( ! is_numeric ( $ cropHeight ) ) { throw new InvalidArgumentException ( '$cropHeight must be numeric' ) ; } $ cropWidth = ( $ this -> currentDimensions [ 'width' ] < $ cropWidth ) ? $ this -> currentDimensions [ 'width' ] : $ cropWidth ; $ cropHeight = ( $ this -> currentDimensions [ 'height' ] < $ cropHeight ) ? $ this -> currentDimensions [ 'height' ] : $ cropHeight ; if ( ( $ startX + $ cropWidth ) > $ this -> currentDimensions [ 'width' ] ) { $ startX = ( $ this -> currentDimensions [ 'width' ] - $ cropWidth ) ; } if ( ( $ startY + $ cropHeight ) > $ this -> currentDimensions [ 'height' ] ) { $ startY = ( $ this -> currentDimensions [ 'height' ] - $ cropHeight ) ; } if ( $ startX < 0 ) { $ startX = 0 ; } if ( $ startY < 0 ) { $ startY = 0 ; } if ( function_exists ( 'imagecreatetruecolor' ) ) { $ this -> workingImage = imagecreatetruecolor ( $ cropWidth , $ cropHeight ) ; } else { $ this -> workingImage = imagecreate ( $ cropWidth , $ cropHeight ) ; } $ this -> preserveAlpha ( ) ; imagecopyresampled ( $ this -> workingImage , $ this -> oldImage , 0 , 0 , $ startX , $ startY , $ cropWidth , $ cropHeight , $ cropWidth , $ cropHeight ) ; $ this -> oldImage = $ this -> workingImage ; $ this -> currentDimensions [ 'width' ] = $ cropWidth ; $ this -> currentDimensions [ 'height' ] = $ cropHeight ; return $ this ; }
Vanilla Cropping - Crops from x y with specified width and height
24,287
public function rotateImageNDegrees ( $ degrees ) { if ( ! is_numeric ( $ degrees ) ) { throw new InvalidArgumentException ( '$degrees must be numeric' ) ; } if ( ! function_exists ( 'imagerotate' ) ) { throw new RuntimeException ( 'Your version of GD does not support image rotation.' ) ; } $ this -> workingImage = imagerotate ( $ this -> oldImage , $ degrees , 0 ) ; $ newWidth = $ this -> currentDimensions [ 'height' ] ; $ newHeight = $ this -> currentDimensions [ 'width' ] ; $ this -> oldImage = $ this -> workingImage ; $ this -> currentDimensions [ 'width' ] = $ newWidth ; $ this -> currentDimensions [ 'height' ] = $ newHeight ; return $ this ; }
Rotates image specified number of degrees
24,288
protected function verifyFormatCompatiblity ( ) { $ isCompatible = true ; $ gdInfo = gd_info ( ) ; switch ( $ this -> format ) { case 'GIF' : $ isCompatible = $ gdInfo [ 'GIF Create Support' ] ; break ; case 'JPG' : $ isCompatible = ( isset ( $ gdInfo [ 'JPG Support' ] ) || isset ( $ gdInfo [ 'JPEG Support' ] ) ) ? true : false ; break ; case 'PNG' : $ isCompatible = $ gdInfo [ $ this -> format . ' Support' ] ; break ; default : $ isCompatible = false ; } if ( ! $ isCompatible ) { $ isCompatible = $ gdInfo [ 'JPEG Support' ] ; if ( ! $ isCompatible ) { $ this -> triggerError ( 'Your GD installation does not support ' . $ this -> format . ' image types' ) ; } } }
Makes sure the correct GD implementation exists for the file type
24,289
public function save ( IUser $ user ) : bool { if ( $ user instanceof AnonymousUser ) { return false ; } if ( $ user -> isNew ( ) ) { $ roles = $ this -> filterRoles ( $ user -> getUserRoles ( ) ) ; $ user -> addRoles ( array_values ( $ roles ) ) ; return entityManager ( ) -> save ( $ user ) ; } if ( ! entityManager ( ) -> save ( $ user ) ) { return false ; } if ( null !== $ roles = $ user -> getUserRoles ( ) ) { $ toAdd = $ this -> filterRoles ( $ roles ) ; $ toRemove = [ ] ; foreach ( $ user -> roles ( ) as $ role ) { $ name = $ role -> name ( ) ; if ( ! isset ( $ toAdd [ $ name ] ) ) { $ toRemove [ ] = $ role ; } else { unset ( $ toAdd [ $ name ] ) ; } } if ( ! empty ( $ toRemove ) ) { $ user -> removeRoles ( $ toRemove ) ; } if ( ! empty ( $ toAdd ) ) { $ user -> addRoles ( array_values ( $ toAdd ) ) ; } } return true ; }
Save modified user
24,290
public static function createSerializer ( ) { $ encoders = array ( new XmlEncoder ( ) , new JsonEncoder ( ) , new LtsvEncoder ( ) ) ; $ normalizers = array ( new GetSetMethodNormalizer ( ) ) ; return new Serializer ( $ normalizers , $ encoders ) ; }
Create LTSV serializer .
24,291
public function addColumn ( $ columnName , $ type = null , $ options = [ ] ) { $ column = new Column ( ) ; $ column -> setName ( $ columnName ) ; $ column -> setType ( $ type ) ; $ column -> setOptions ( $ options ) ; $ column -> setTable ( $ this ) ; parent :: addColumn ( $ column ) ; return $ column ; }
addColumn wrapper .
24,292
public function changeColumn ( $ columnName , $ newColumnType , $ options = [ ] ) { if ( ! $ newColumnType instanceof Column ) { $ newColumn = new Column ( ) ; $ newColumn -> setType ( $ newColumnType ) ; $ newColumn -> setOptions ( $ options ) ; } else { $ newColumn = $ newColumnType ; } return parent :: changeColumn ( $ columnName , $ newColumn ) ; }
changeColumn wrapper .
24,293
public function column ( $ name , $ type = null , $ options = [ ] ) { return $ this -> addColumn ( $ name , $ type , $ options ) ; }
add column bridge
24,294
protected function sys_get_errors ( ) { $ errors = sqlsrv_errors ( SQLSRV_ERR_ERRORS ) ; if ( empty ( $ errors ) ) { return "" ; } $ message_array = [ ] ; foreach ( $ errors as $ error ) { $ message_array [ $ error [ 'message' ] ] = $ error [ 'message' ] ; } return implode ( "\n" , $ message_array ) ; }
Retrieves the last errors ocurend while execution of the query .
24,295
public function init ( $ parameters ) { if ( ! empty ( $ parameters [ "db_server" ] ) ) { $ this -> db_server = $ parameters [ "db_server" ] ; } if ( ! empty ( $ parameters [ "db_name" ] ) ) { $ this -> db_name = $ parameters [ "db_name" ] ; } if ( ! empty ( $ parameters [ "db_user" ] ) ) { $ this -> db_user = $ parameters [ "db_user" ] ; } if ( ! empty ( $ parameters [ "db_password" ] ) ) { $ this -> db_password = $ parameters [ "db_password" ] ; } return true ; }
Initializes the dbworker with connection paramters .
24,296
public function qualify_name_with_schema ( $ name ) { $ schema = $ this -> get_schema ( ) ; if ( ! empty ( $ schema ) ) { $ schema .= "." ; } return $ schema . $ name ; }
Completes the name of a database object with the schema name if applicable .
24,297
public function insert_id ( ) { if ( ! $ this -> connection ) { $ this -> last_error_id = "db_server_conn_error" ; return false ; } if ( $ this -> last_query_is_insert ) { if ( ! $ this -> statement ) { return null ; } if ( ! sqlsrv_next_result ( $ this -> statement ) ) { $ this -> last_error = $ this -> sys_get_errors ( ) ; $ this -> last_error_id = "db_query_error" ; trigger_error ( $ this -> last_error , E_USER_ERROR ) ; return false ; } $ id = null ; if ( @ sqlsrv_fetch ( $ this -> statement ) ) { $ id = sqlsrv_get_field ( $ this -> statement , 0 ) ; } return $ id ; } $ this -> statement = @ sqlsrv_query ( $ this -> connection , "SELECT SCOPE_IDENTITY() AS IID" ) ; if ( ! $ this -> statement ) { $ this -> last_error = $ this -> sys_get_errors ( ) ; $ this -> last_error_id = "db_query_error" ; trigger_error ( $ this -> last_error , E_USER_ERROR ) ; return false ; } if ( ! $ this -> fetch_row ( ) ) { $ this -> last_error_id = "db_query_error" ; return false ; } $ id = $ this -> field_by_name ( "IID" ) ; $ this -> free_result ( ) ; return $ id ; }
Returns the value of the auto increment field by the last insertion .
24,298
public function field_by_name ( $ name ) { if ( ! $ this -> row ) { return null ; } if ( ! array_key_exists ( $ name , $ this -> row ) ) { trigger_error ( "Field with the name '$name' does not exist in the result set!" , E_USER_ERROR ) ; return null ; } return $ this -> row [ $ name ] ; }
Returns the value of a field specified by name .
24,299
public function field_by_num ( $ num ) { if ( ! $ this -> row ) { return null ; } if ( ! array_key_exists ( $ num , $ this -> field_names ) ) { trigger_error ( "Field with the index $num does not exist in the result set!" , E_USER_ERROR ) ; return null ; } return $ this -> row [ $ this -> field_names [ $ num ] ] ; }
Returns the value of a field specified by number .