idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
7,100
|
public function save ( Query $ query , array $ options = [ ] ) { $ type = $ query -> getType ( ) ; if ( $ type === Query :: DELETE ) { return $ this -> _processDelete ( $ query , $ options ) ; } else if ( $ type === Query :: INSERT ) { return $ this -> _processCreate ( $ query , $ options ) ; } else if ( $ type === Query :: UPDATE ) { return $ this -> _processUpdate ( $ query , $ options ) ; } return $ this -> getDriver ( ) -> executeQuery ( $ query ) -> save ( ) ; }
|
Return a count of how many rows were affected by the query .
|
7,101
|
public function update ( $ id , $ data , array $ options = [ ] ) { return $ this -> query ( Query :: UPDATE ) -> where ( $ this -> getPrimaryKey ( ) , $ id ) -> save ( $ data , $ options ) ; }
|
Update a database record based on ID .
|
7,102
|
public function updateMany ( $ data , Closure $ conditions , array $ options = [ ] ) { return $ this -> query ( Query :: UPDATE ) -> bindCallback ( $ conditions ) -> save ( $ data , $ options ) ; }
|
Update multiple records with conditions .
|
7,103
|
public function upsert ( $ data , $ id = null , array $ options = [ ] ) { $ pk = $ this -> getPrimaryKey ( ) ; $ update = false ; if ( ! $ id && isset ( $ data [ $ pk ] ) ) { $ id = $ data [ $ pk ] ; } unset ( $ data [ $ pk ] ) ; if ( $ id ) { $ update = $ this -> exists ( $ id ) ; } if ( $ update ) { if ( $ this -> update ( $ id , $ data , $ options ) === false ) { return 0 ; } } else { $ id = $ this -> create ( $ data , $ options ) ; } return $ id ; }
|
Either update or insert a record by checking for ID and record existence .
|
7,104
|
protected function _processCreate ( Query $ query , array $ options = [ ] ) { $ data = $ query -> getData ( ) ; $ options = $ options + [ 'before' => true , 'after' => true ] ; if ( $ options [ 'before' ] ) { foreach ( [ 'db.preSave' , 'db.preCreate' ] as $ event ) { $ event = $ this -> emit ( $ event , [ $ query , null , & $ data ] ) ; if ( ! $ event -> getState ( ) ) { return 0 ; } } } $ query -> data ( $ data ) ; $ driver = $ this -> getDriver ( ) ; $ driver -> setContext ( 'write' ) ; $ count = $ driver -> executeQuery ( $ query ) -> save ( ) ; if ( $ count === false ) { return 0 ; } $ id = $ driver -> getLastInsertID ( $ this ) ; if ( $ options [ 'after' ] ) { $ this -> emit ( 'db.postSave db.postCreate' , [ $ id , $ count ] ) ; } return $ this -> id = $ id ; }
|
Primary method that handles the processing of insert queries .
|
7,105
|
protected function _processDelete ( Query $ query , array $ options = [ ] ) { $ options = $ options + [ 'before' => true , 'after' => true ] ; $ this -> id = $ id = $ this -> findID ( $ query ) ; if ( $ options [ 'before' ] ) { $ event = $ this -> emit ( 'db.preDelete' , [ $ query , $ id ] ) ; $ state = $ event -> getState ( ) ; if ( ! $ state ) { return 0 ; } else if ( is_numeric ( $ state ) ) { return ( int ) $ state ; } } $ count = $ this -> getDriver ( ) -> setContext ( 'delete' ) -> executeQuery ( $ query ) -> save ( ) ; if ( $ count && $ options [ 'after' ] ) { $ this -> emit ( 'db.postDelete' , [ $ id , $ count ] ) ; } return ( int ) $ count ; }
|
Primary method that handles the processing of delete queries .
|
7,106
|
protected function _processUpdate ( Query $ query , array $ options = [ ] ) { $ data = $ query -> getData ( ) ; $ options = $ options + [ 'before' => true , 'after' => true ] ; $ this -> id = $ id = $ this -> findID ( $ query ) ; if ( $ options [ 'before' ] ) { foreach ( [ 'db.preSave' , 'db.preUpdate' ] as $ event ) { $ event = $ this -> emit ( $ event , [ $ query , $ id , & $ data ] ) ; if ( ! $ event -> getState ( ) ) { return 0 ; } } } $ query -> data ( $ data ) ; $ count = $ this -> getDriver ( ) -> setContext ( 'write' ) -> executeQuery ( $ query ) -> save ( ) ; if ( $ count === false ) { return false ; } if ( $ options [ 'after' ] ) { $ this -> emit ( 'db.postSave db.postUpdate' , [ $ id , $ count ] ) ; } return $ count ; }
|
Primary method that handles the processing of update queries .
|
7,107
|
function clearLog ( ) : void { @ unlink ( $ this -> errLogger -> getFile ( ) ) ; @ unlink ( $ this -> logger -> getFile ( ) ) ; @ unlink ( $ this -> errLogger -> getFile ( ) . '.shell' ) ; @ unlink ( $ this -> logger -> getFile ( ) . '.shell' ) ; }
|
Cleans daemon log
|
7,108
|
public function getDefaultBlade ( ) : ? BladeCompiler { $ view = View :: getFacadeRoot ( ) ; if ( isset ( $ view ) ) { return Blade :: getFacadeRoot ( ) ; } return $ view ; }
|
Get a default blade value if any is available
|
7,109
|
public static function add ( $ key , $ path , $ url = null ) { static :: $ paths [ $ key ] = $ path ; if ( ! is_null ( $ url ) ) { static :: $ urls [ $ key ] = $ url ; } }
|
Adds a new storage directory
|
7,110
|
public static function file ( $ file ) { $ params = array_merge ( static :: $ params , array ( 'time' => time ( ) , 'fingerprint' => \ CCSession :: fingerprint ( ) , 'random' => CCStr :: random ( ) , ) ) ; foreach ( $ params as $ param => $ value ) { $ file = str_replace ( ':' . $ param , $ value , $ file ) ; } return $ file ; }
|
Prepares a file with the parameters
|
7,111
|
public static function url ( $ file = null , $ key = null ) { if ( is_null ( $ key ) ) { $ key = static :: $ default ; } if ( ! isset ( static :: $ urls [ $ key ] ) ) { throw new CCException ( 'CCStorage - use of undefined public url ' . $ key . '.' ) ; } return CCUrl :: to ( static :: $ urls [ $ key ] . $ file ) ; }
|
Get the public url to a file if available
|
7,112
|
public static function write ( $ file , $ content , $ key = null ) { return CCFile :: write ( static :: path ( $ file , $ key ) , $ content ) ; }
|
Write a file to the storage
|
7,113
|
public function setComment ( $ newComment = NULL ) { if ( $ this -> isFinalized ) { return FALSE ; } $ this -> zipComment = $ newComment ; return TRUE ; }
|
Set Zip archive comment .
|
7,114
|
public function addDirectory ( $ directoryPath , $ timestamp = 0 , $ fileComment = NULL , $ extFileAttr = self :: EXT_FILE_ATTR_DIR ) { if ( $ this -> isFinalized ) { return FALSE ; } $ directoryPath = str_replace ( "\\" , "/" , $ directoryPath ) ; $ directoryPath = rtrim ( $ directoryPath , "/" ) ; if ( strlen ( $ directoryPath ) > 0 ) { $ this -> buildZipEntry ( $ directoryPath . '/' , $ fileComment , "\x00\x00" , "\x00\x00" , $ timestamp , "\x00\x00\x00\x00" , 0 , 0 , $ extFileAttr ) ; return TRUE ; } return FALSE ; }
|
Add an empty directory entry to the zip archive . Basically this is only used if an empty directory is added .
|
7,115
|
public function addStreamData ( $ data ) { if ( $ this -> isFinalized || strlen ( $ this -> streamFilePath ) == 0 ) { return FALSE ; } $ length = fwrite ( $ this -> streamData , $ data , strlen ( $ data ) ) ; if ( $ length != strlen ( $ data ) ) { throw new Exception ( "File IO: Error writing; Length mismatch: Expected " . strlen ( $ data ) . " bytes, wrote " . ( $ length === FALSE ? "NONE!" : $ length ) ) ; } $ this -> streamFileLength += $ length ; return $ length ; }
|
Add data to the open stream .
|
7,116
|
public function closeStream ( ) { if ( $ this -> isFinalized || strlen ( $ this -> streamFilePath ) == 0 ) { return FALSE ; } fflush ( $ this -> streamData ) ; fclose ( $ this -> streamData ) ; $ this -> processFile ( $ this -> streamFile , $ this -> streamFilePath , $ this -> streamTimestamp , $ this -> streamFileComment , $ this -> streamExtFileAttr ) ; $ this -> streamData = null ; $ this -> streamFilePath = null ; $ this -> streamTimestamp = null ; $ this -> streamFileComment = null ; $ this -> streamFileLength = 0 ; $ this -> streamExtFileAttr = null ; unlink ( $ this -> streamFile ) ; $ this -> streamFile = null ; return TRUE ; }
|
Close the current stream .
|
7,117
|
public function finalize ( ) { if ( ! $ this -> isFinalized ) { if ( strlen ( $ this -> streamFilePath ) > 0 ) { $ this -> closeStream ( ) ; } $ cd = implode ( "" , $ this -> cdRec ) ; $ cdRecSize = pack ( "v" , sizeof ( $ this -> cdRec ) ) ; $ cdRec = $ cd . self :: ZIP_END_OF_CENTRAL_DIRECTORY . $ cdRecSize . $ cdRecSize . pack ( "VV" , strlen ( $ cd ) , $ this -> offset ) ; if ( ! empty ( $ this -> zipComment ) ) { $ cdRec .= pack ( "v" , strlen ( $ this -> zipComment ) ) . $ this -> zipComment ; } else { $ cdRec .= "\x00\x00" ; } $ this -> zipwrite ( $ cdRec ) ; $ this -> isFinalized = TRUE ; $ this -> cdRec = NULL ; return TRUE ; } return FALSE ; }
|
Close the archive . A closed archive can no longer have new files added to it .
|
7,118
|
public function getZipFile ( ) { if ( ! $ this -> isFinalized ) { $ this -> finalize ( ) ; } $ this -> zipflush ( ) ; rewind ( $ this -> zipFile ) ; return $ this -> zipFile ; }
|
Get the handle ressource for the archive zip file . If the zip haven t been finalized yet this will cause it to become finalized
|
7,119
|
public function getZipData ( ) { if ( ! $ this -> isFinalized ) { $ this -> finalize ( ) ; } if ( ! is_resource ( $ this -> zipFile ) ) { return $ this -> zipData ; } else { rewind ( $ this -> zipFile ) ; $ filestat = fstat ( $ this -> zipFile ) ; return fread ( $ this -> zipFile , $ filestat [ 'size' ] ) ; } }
|
Get the zip file contents If the zip haven t been finalized yet this will cause it to become finalized
|
7,120
|
public function getArchiveSize ( ) { if ( ! is_resource ( $ this -> zipFile ) ) { return strlen ( $ this -> zipData ) ; } $ filestat = fstat ( $ this -> zipFile ) ; return $ filestat [ 'size' ] ; }
|
Return the current size of the archive
|
7,121
|
private function getDosTime ( $ timestamp = 0 ) { $ timestamp = ( int ) $ timestamp ; $ oldTZ = @ date_default_timezone_get ( ) ; date_default_timezone_set ( 'UTC' ) ; $ date = ( $ timestamp == 0 ? getdate ( ) : getdate ( $ timestamp ) ) ; date_default_timezone_set ( $ oldTZ ) ; if ( $ date [ "year" ] >= 1980 ) { return pack ( "V" , ( ( $ date [ "mday" ] + ( $ date [ "mon" ] << 5 ) + ( ( $ date [ "year" ] - 1980 ) << 9 ) ) << 16 ) | ( ( $ date [ "seconds" ] >> 1 ) + ( $ date [ "minutes" ] << 5 ) + ( $ date [ "hours" ] << 11 ) ) ) ; } return "\x00\x00\x00\x00" ; }
|
Calculate the 2 byte dostime used in the zip entries .
|
7,122
|
public static function generateExtAttr ( $ owner = 07 , $ group = 05 , $ other = 05 , $ isFile = true ) { $ fp = $ isFile ? self :: S_IFREG : self :: S_IFDIR ; $ fp |= ( ( $ owner & 07 ) << 6 ) | ( ( $ group & 07 ) << 3 ) | ( $ other & 07 ) ; return ( $ fp << 16 ) | ( $ isFile ? self :: S_DOS_A : self :: S_DOS_D ) ; }
|
Create the file permissions for a file or directory for use in the extFileAttr parameters .
|
7,123
|
public static function getFileExtAttr ( $ filename ) { if ( file_exists ( $ filename ) ) { $ fp = fileperms ( $ filename ) << 16 ; return $ fp | ( is_dir ( $ filename ) ? self :: S_DOS_D : self :: S_DOS_A ) ; } return FALSE ; }
|
Get the file permissions for a file or directory for use in the extFileAttr parameters .
|
7,124
|
private static function getTemporaryFile ( ) { if ( is_callable ( self :: $ temp ) ) { $ temporaryFile = @ call_user_func ( self :: $ temp ) ; if ( is_string ( $ temporaryFile ) && strlen ( $ temporaryFile ) && is_writable ( $ temporaryFile ) ) { return $ temporaryFile ; } } $ temporaryDirectory = ( is_string ( self :: $ temp ) && strlen ( self :: $ temp ) ) ? self :: $ temp : sys_get_temp_dir ( ) ; return tempnam ( $ temporaryDirectory , 'Zip' ) ; }
|
Returns the path to a temporary file .
|
7,125
|
public function validate ( $ field , $ data = NULL , $ flags = 0x000000 ) { $ key = $ this -> getKey ( $ field ) ; if ( isset ( $ this -> dataProvider ) ) { $ data = $ this -> dataProvider -> getValidatorData ( $ field ) ; } if ( $ this -> hasField ( $ field ) ) { try { foreach ( $ this -> rules [ $ key ] as $ rule ) { $ data = $ rule -> validate ( $ data ) ; } } catch ( EmptyDataException $ e ) { if ( ( $ flags & self :: OPTIONAL ) == self :: OPTIONAL || $ this -> isOptional ( $ field ) ) { return $ e -> getDefaultValue ( ) ; } else { if ( $ e -> getMessage ( ) == NULL ) { $ e -> setMessage ( sprintf ( $ this -> standardEmptyMessage , $ this -> getKey ( $ field ) ) ) ; } throw $ this -> convertToValidatorException ( $ e , $ field , $ data ) ; } } catch ( \ Exception $ e ) { throw $ this -> convertToValidatorException ( $ e , $ field , $ data ) ; } } else { throw new \ Psc \ Exception ( 'Feld: ' . Code :: varInfo ( $ field ) . ' ist dem Validator nicht bekannt.' ) ; } return $ data ; }
|
Validiert die Daten zu einem Feld
|
7,126
|
public function setLightAmbientColor ( $ red , $ green , $ blue ) { $ this -> lightAmbientColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the ambient color in which elements reflect the light
|
7,127
|
public function setCloudsMinimumColor ( $ red , $ green , $ blue ) { $ this -> cloudsMinimumColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the minimum value for the background color range
|
7,128
|
public function setCloudsMaximumColor ( $ red , $ green , $ blue ) { $ this -> cloudsMaximumColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the maximum value for the background color range
|
7,129
|
public function setLight0Color ( $ red , $ green , $ blue ) { $ this -> light0Color = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the RGB color of light source 0
|
7,130
|
public function setLightBallColor ( $ red , $ green , $ blue ) { $ this -> lightBallColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the light ball color
|
7,131
|
public function setFogColor ( $ red , $ green , $ blue ) { $ this -> fogColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the fog color
|
7,132
|
public function setSelfIlluminationColor ( $ red , $ green , $ blue ) { $ this -> selfIlluminationColor = floatval ( $ red ) . ' ' . floatval ( $ green ) . ' ' . floatval ( $ blue ) ; return $ this ; }
|
Set the self illumination color
|
7,133
|
public function addSkyGradient ( $ x , $ color ) { $ skyGradientKey = new SkyGradientKey ( $ x , $ color ) ; return $ this -> addSkyGradientKey ( $ skyGradientKey ) ; }
|
Add a sky gradient
|
7,134
|
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "mood" ) ; if ( $ this -> lightAmbientColor ) { $ domElement -> setAttribute ( "LAmbient_LinearRgb" , $ this -> lightAmbientColor ) ; } if ( $ this -> cloudsMinimumColor ) { $ domElement -> setAttribute ( "CloudsRgbMinLinear" , $ this -> cloudsMinimumColor ) ; } if ( $ this -> cloudsMaximumColor ) { $ domElement -> setAttribute ( "CloudsRgbMaxLinear" , $ this -> cloudsMaximumColor ) ; } if ( $ this -> light0Color ) { $ domElement -> setAttribute ( "LDir0_LinearRgb" , $ this -> light0Color ) ; } if ( $ this -> light0Intensity != 1. ) { $ domElement -> setAttribute ( "LDir0_Intens" , $ this -> light0Intensity ) ; } if ( $ this -> light0PhiAngle ) { $ domElement -> setAttribute ( "LDir0_DirPhi" , $ this -> light0PhiAngle ) ; } if ( $ this -> light0ThetaAngle ) { $ domElement -> setAttribute ( "LDir0_DirTheta" , $ this -> light0ThetaAngle ) ; } if ( $ this -> lightBallColor ) { $ domElement -> setAttribute ( "LBall_LinearRgb" , $ this -> lightBallColor ) ; } if ( $ this -> lightBallIntensity != 1. ) { $ domElement -> setAttribute ( "LBall_Intens" , $ this -> lightBallIntensity ) ; } if ( $ this -> lightBallRadius ) { $ domElement -> setAttribute ( "LBall_Radius" , $ this -> lightBallRadius ) ; } if ( $ this -> fogColor ) { $ domElement -> setAttribute ( "FogColorSrgb" , $ this -> fogColor ) ; } if ( $ this -> selfIlluminationColor ) { $ domElement -> setAttribute ( "SelfIllumColor" , $ this -> selfIlluminationColor ) ; } if ( $ this -> skyGradientScale != 1. ) { $ domElement -> setAttribute ( "SkyGradientV_Scale" , $ this -> skyGradientScale ) ; } if ( $ this -> skyGradientKeys ) { $ skyGradientElement = $ domDocument -> createElement ( "skygradient" ) ; $ domElement -> appendChild ( $ skyGradientElement ) ; foreach ( $ this -> skyGradientKeys as $ skyGradientKey ) { $ skyGradientKeyElement = $ skyGradientKey -> render ( $ domDocument ) ; $ skyGradientElement -> appendChild ( $ skyGradientKeyElement ) ; } } return $ domElement ; }
|
Render the Mood
|
7,135
|
public function store ( $ table ) { $ table = config ( 'center.tables.' . $ table ) ; if ( ! isset ( $ table -> name ) ) { return redirect ( ) -> action ( '\LeftRight\Center\Controllers\TableController@index' ) -> with ( 'error' , trans ( 'center::site.table_does_not_exist' ) ) ; } $ inserts = self :: processColumnsInput ( $ table ) ; if ( $ table -> name == config ( 'center.db.users' ) ) { $ password = Str :: random ( 12 ) ; $ inserts [ 'password' ] = Hash :: make ( $ password ) ; $ email = $ inserts [ 'email' ] ; $ link = action ( '\LeftRight\Center\Controllers\TableController@index' ) ; Mail :: send ( 'center::emails.welcome' , [ 'email' => $ email , 'password' => $ password , 'link' => $ link ] , function ( $ message ) use ( $ email ) { $ message -> to ( $ email ) -> subject ( trans ( 'center::site.welcome_email_subject' ) ) ; } ) ; } try { $ row_id = DB :: table ( $ table -> name ) -> insertGetId ( $ inserts ) ; } catch ( Exception $ e ) { return redirect ( ) -> back ( ) -> withInput ( ) -> with ( 'error' , $ e -> getMessage ( ) ) ; } self :: processRelationsInput ( $ table , $ row_id ) ; FileController :: cleanup ( ) ; return redirect ( Trail :: last ( action ( '\LeftRight\Center\Controllers\RowController@index' , $ table -> name ) ) ) ; }
|
save a new object instance to the database
|
7,136
|
public static function listColumn ( $ table ) { if ( is_string ( $ table ) ) $ table = config ( 'center.tables.' . $ table ) ; $ fields = ! empty ( $ table -> list ) ? $ table -> list : array_keys ( ( array ) $ table -> fields ) ; foreach ( $ fields as $ field ) { if ( $ table -> fields -> { $ field } -> type == 'string' ) return $ field ; } }
|
get the first text field column name
|
7,137
|
public function setBorderSize ( $ pValue = null ) { $ this -> _borderTopSize = $ pValue ; $ this -> _borderLeftSize = $ pValue ; $ this -> _borderRightSize = $ pValue ; $ this -> _borderBottomSize = $ pValue ; $ this -> _borderInsideHSize = $ pValue ; $ this -> _borderInsideVSize = $ pValue ; }
|
Set TLRBVH Border Size
|
7,138
|
public function getBorderSize ( ) { $ t = $ this -> getBorderTopSize ( ) ; $ l = $ this -> getBorderLeftSize ( ) ; $ r = $ this -> getBorderRightSize ( ) ; $ b = $ this -> getBorderBottomSize ( ) ; $ h = $ this -> getBorderInsideHSize ( ) ; $ v = $ this -> getBorderInsideVSize ( ) ; return array ( $ t , $ l , $ r , $ b , $ h , $ v ) ; }
|
Get TLRBVH Border Size
|
7,139
|
public function getBorderColor ( ) { $ t = $ this -> getBorderTopColor ( ) ; $ l = $ this -> getBorderLeftColor ( ) ; $ r = $ this -> getBorderRightColor ( ) ; $ b = $ this -> getBorderBottomColor ( ) ; $ h = $ this -> getBorderInsideHColor ( ) ; $ v = $ this -> getBorderInsideVColor ( ) ; return array ( $ t , $ l , $ r , $ b , $ h , $ v ) ; }
|
Get TLRB Border Color
|
7,140
|
public static function create ( ) { $ arguments = func_get_args ( ) ; $ name = array_shift ( $ arguments ) ; $ class_name = "Core\\CCShipyard_" . ucfirst ( $ name ) ; if ( ! class_exists ( $ class_name ) ) { throw new CCException ( "CCShipyard - invalid builder (" . $ name . ") given." ) ; } $ builder = new $ class_name ; call_user_func_array ( array ( $ builder , 'create' ) , $ arguments ) ; return $ builder ; }
|
Static call wrapper to require the right builder
|
7,141
|
private function hasValidCacheItem ( CacheItemInterface $ cacheItem , array $ fieldList ) : bool { $ data = $ cacheItem -> get ( ) ; if ( is_null ( $ data ) ) { return false ; } $ fieldDiff = array_diff ( $ fieldList , array_keys ( $ data ) ) ; return ! $ fieldDiff ; }
|
Has valid cache item .
|
7,142
|
private function getCacheItemGenerator ( SearchCriteriaInterface $ searchCriteria ) { try { foreach ( $ searchCriteria -> getIdList ( ) as $ item ) { $ cacheKey = $ this -> keyGenerator -> generate ( $ item , $ searchCriteria ) ; yield $ item => $ this -> cacheItemPool -> getItem ( $ cacheKey ) ; } } catch ( PsrCacheInvalidArgumentException $ e ) { throw new InvalidCacheKeyException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
|
Retrieve cache data generator .
|
7,143
|
public function get ( $ class ) { if ( $ class instanceof ReflectionClass ) { $ reflection = $ class ; $ class = $ reflection -> getName ( ) ; } if ( isset ( $ this -> utils [ $ class ] ) ) { return $ this -> utils [ $ class ] ; } if ( ! isset ( $ reflection ) ) { if ( ! class_exists ( $ class ) && ! interface_exists ( $ class ) ) { throw new InvalidClassException ( "$class doesn't exist" ) ; } $ reflection = new ReflectionClass ( $ class ) ; } $ config = null ; if ( $ this -> config ) { $ config = $ this -> config -> getConfig ( $ class ) ; if ( ! $ config ) { $ config = $ this -> config -> getConfig ( $ reflection -> getShortName ( ) ) ; } } if ( ! $ config ) { if ( $ reflection -> isInstantiable ( ) && $ this -> getConstructor ( $ reflection ) -> getNumberOfRequiredParameters ( ) == 0 ) { return $ reflection -> newInstance ( ) ; } else { throw new MissingConfigurationException ( "No configuration found for utility $class" ) ; } } $ driver = $ config -> get ( 'driver' ) ; if ( ! $ driver ) { if ( $ reflection -> isInstantiable ( ) ) { $ driver = $ reflection -> getName ( ) ; $ driverReflection = $ reflection ; } else { throw new MissingConfigurationException ( "Configuration for $class must include a driver" ) ; } } else { if ( ! class_exists ( $ driver ) ) { throw new InvalidClassException ( "$class driver $driver doesn't exist" ) ; } $ driverReflection = new ReflectionClass ( $ driver ) ; if ( ! $ driverReflection -> isInstantiable ( ) ) { throw new InvalidClassException ( "$class driver $driver is not instantiable" ) ; } } $ utility = $ this -> getClass ( $ driverReflection , $ config ) ; $ this -> utils [ $ class ] = $ utility ; return $ utility ; }
|
Get a utility class
|
7,144
|
public function isExpired ( ) { if ( null === $ this -> expiresAt ) { return false ; } $ now = new \ DateTime ( ) ; return $ this -> expiresAt < $ now ; }
|
Checks whether the cart is expired or not .
|
7,145
|
public function addBinding ( $ field , $ values ) { if ( ! is_array ( $ values ) ) { $ values = [ $ values ] ; } foreach ( $ values as $ value ) { if ( $ value instanceof Predicate ) { $ this -> resolvePredicate ( $ value ) ; } else if ( $ value instanceof SubQuery ) { $ this -> resolveSubQuery ( $ value ) ; } else { $ this -> _bindings [ ] = [ 'field' => $ field , 'value' => $ value ] ; } } return $ this ; }
|
Add a value to use in SQL parameter binding .
|
7,146
|
public function resolvePredicate ( Predicate $ predicate ) { $ this -> _bindings = array_merge ( $ this -> _bindings , $ predicate -> getBindings ( ) ) ; return $ this ; }
|
Merge an external predicates bindings with the current bindings .
|
7,147
|
public function resolveSubQuery ( SubQuery $ query ) { foreach ( $ query -> getGroupedBindings ( ) as $ bindings ) { $ this -> _bindings = array_merge ( $ this -> _bindings , $ bindings ) ; } return $ this ; }
|
Merge an external sub - queries bindings with the current bindings .
|
7,148
|
public function getRootDirModule ( ) { $ r = new \ ReflectionObject ( $ this ) ; $ injectionDir = str_replace ( '\\' , '/' , dirname ( $ r -> getFileName ( ) ) ) ; return $ injectionDir . '/..' ; }
|
Get Root Dir Module
|
7,149
|
public function loadRoutes ( ) { $ routesJsonFile = $ this -> configDir . '/routes.json' ; $ routesPhpFile = $ this -> configDir . '/routes.php' ; if ( file_exists ( $ this -> resourcesDir ) && file_exists ( $ this -> configDir ) ) { if ( file_exists ( $ routesJsonFile ) ) return json_decode ( file_get_contents ( $ routesJsonFile ) , true ) ; elseif ( file_exists ( $ routesPhpFile ) ) return require_once $ routesPhpFile ; } else { return array ( ) ; } }
|
Load routes of the Module
|
7,150
|
public function reverseMapPrice ( ? float $ price ) : ? int { if ( null === $ price ) { return null ; } if ( 0.00 === $ price ) { return 0 ; } return ( int ) str_replace ( '.' , '' , number_format ( $ price , 2 , '.' , '' ) ) ; }
|
Maps price to string .
|
7,151
|
public function send ( $ subject , $ content , $ to , $ fromName = '' , $ fromEmail = '' ) { $ mail = new CakeEmail ( ) ; $ fromName = ( $ fromName !== '' ) ? $ fromName : $ this -> _fromName ; $ fromEmail = ( $ fromEmail !== '' ) ? $ fromEmail : $ this -> _fromEmail ; $ transport = new MailTransport ( ) ; return $ mail -> setTransport ( $ transport ) -> setTemplate ( $ this -> _tpl ) -> setEmailFormat ( $ this -> _format ) -> setFrom ( $ fromEmail , $ fromName ) -> setTo ( $ to ) -> setSubject ( $ subject ) -> setViewVars ( [ 'page_title' => $ subject ] ) -> send ( $ content ) ; }
|
Send message method .
|
7,152
|
public function setDependencies ( array $ dependencies ) { $ this -> dependencies = array_values ( array_filter ( $ dependencies , function ( $ dependency ) : bool { return $ dependency instanceof Dependency ; } ) ) ; return $ this ; }
|
Sets the dependencies of the mod .
|
7,153
|
public function restGet ( $ cursor ) { if ( $ cursor instanceof Cursor ) { $ name = $ cursor -> getCollection ( ) -> getName ( ) ; $ criteria = $ cursor -> getCriteria ( ) ; $ limit = $ cursor -> limit ( ) ; $ skip = $ cursor -> skip ( ) ; $ sorts = $ cursor -> sort ( ) ; $ query = array ( ) ; foreach ( $ criteria as $ key => $ value ) { $ query [ $ key ] = $ value ; } if ( $ limit ) { $ query [ '!limit' ] = $ limit ; } if ( $ skip ) { $ query [ '!skip' ] = $ skip ; } if ( ! empty ( $ sorts ) ) { foreach ( $ sorts as $ key => $ value ) { $ query [ "!sort[$key]" ] = $ value ; } } $ qs = array ( ) ; foreach ( $ query as $ key => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ qs [ ] = '!' . $ key . '=' . $ v ; } } else { $ qs [ ] = $ key . '=' . $ value ; } } if ( $ qs ) { $ qs = '?' . implode ( '&' , $ qs ) ; } else { $ qs = '' ; } $ url = $ this -> option ( 'baseUrl' ) . '/' . $ name . '.json' . $ qs ; $ client = new Client ( ) ; $ response = $ client -> get ( $ url ) -> send ( ) ; return json_decode ( $ response -> getBody ( true ) , true ) ; } else { throw new Exception ( 'Unimplemented yet!' ) ; } }
|
Get data from rest service .
|
7,154
|
public function addInstallMacroblock ( $ name , $ file , $ url ) { $ macroblockElement = new InstallMacroblock ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ macroblockElement ) ; }
|
Install a Macroblock
|
7,155
|
public function addInstallMap ( $ name , $ url ) { $ mapElement = new InstallMap ( $ name , $ url ) ; return $ this -> addElement ( $ mapElement ) ; }
|
Install a map
|
7,156
|
public function addPlayMap ( $ name , $ url ) { $ mapElement = new PlayMap ( $ name , $ url ) ; return $ this -> addElement ( $ mapElement ) ; }
|
Play a map
|
7,157
|
public function addInstallReplay ( $ name , $ url ) { $ replayElement = new InstallReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
|
Install a replay
|
7,158
|
public function addViewReplay ( $ name , $ url ) { $ replayElement = new ViewReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
|
View a replay
|
7,159
|
public function addPlayReplay ( $ name , $ url ) { $ replayElement = new PlayReplay ( $ name , $ url ) ; return $ this -> addElement ( $ replayElement ) ; }
|
Play a replay
|
7,160
|
public function addInstallSkin ( $ name , $ file , $ url ) { $ skinElement = new InstallSkin ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ skinElement ) ; }
|
Install a skin
|
7,161
|
public function addGetSkin ( $ name , $ file , $ url ) { $ skinElement = new GetSkin ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ skinElement ) ; }
|
Get a skin
|
7,162
|
public function addJoinServer ( $ loginOrIp = null , $ port = null ) { $ serverElement = new JoinServer ( $ loginOrIp , $ port ) ; return $ this -> addElement ( $ serverElement ) ; }
|
Join a server
|
7,163
|
public function addAddFavorite ( $ loginOrIp = null , $ port = null ) { $ favoriteElement = new AddFavorite ( $ loginOrIp , $ port ) ; return $ this -> addElement ( $ favoriteElement ) ; }
|
Add a server as favorite
|
7,164
|
public function addInstallScript ( $ name , $ file , $ url ) { $ scriptElement = new InstallScript ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ scriptElement ) ; }
|
Install a script
|
7,165
|
public function addInstallPack ( $ name , $ file , $ url ) { $ packElement = new InstallPack ( $ name , $ file , $ url ) ; return $ this -> addElement ( $ packElement ) ; }
|
Install a title pack
|
7,166
|
public function addElement ( Element $ element ) { if ( ! in_array ( $ element , $ this -> elements , true ) ) { array_push ( $ this -> elements , $ element ) ; } return $ this ; }
|
Add a ManiaCode Element
|
7,167
|
public function render ( $ echo = false ) { $ domDocument = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ domDocument -> xmlStandalone = true ; $ domElement = $ domDocument -> createElement ( "maniacode" ) ; $ domDocument -> appendChild ( $ domElement ) ; if ( $ this -> disableConfirmation ) { $ domElement -> setAttribute ( "noconfirmation" , 1 ) ; } foreach ( $ this -> elements as $ element ) { $ childDomElement = $ element -> render ( $ domDocument ) ; $ domElement -> appendChild ( $ childDomElement ) ; } if ( $ echo ) { header ( "Content-Type: application/xml; charset=utf-8;" ) ; echo $ domDocument -> saveXML ( ) ; } return $ domDocument ; }
|
Render the ManiaCode
|
7,168
|
private function render ( ) { $ output = '' ; foreach ( $ this -> jobs as $ job ) { $ output .= $ this -> getTaskDefinition ( $ job ) ; } return $ output ; }
|
Render all the cron jobs .
|
7,169
|
public function attach ( $ observer ) { if ( is_array ( $ observer ) ) { if ( ! isset ( $ observer [ 'handler' ] ) || ! isset ( $ observer [ 'event' ] ) || ! is_callable ( $ observer [ 'handler' ] ) ) { return ; } foreach ( $ this -> _observers as $ check ) { if ( is_array ( $ check ) && $ check [ 'event' ] == $ observer [ 'event' ] && $ check [ 'handler' ] == $ observer [ 'handler' ] ) { return ; } } $ this -> _observers [ ] = $ observer ; end ( $ this -> _observers ) ; $ methods = array ( $ observer [ 'event' ] ) ; } else { if ( ! ( $ observer instanceof JObserver ) ) { return ; } $ class = get_class ( $ observer ) ; foreach ( $ this -> _observers as $ check ) { if ( $ check instanceof $ class ) { return ; } } $ this -> _observers [ ] = $ observer ; $ methods = array_diff ( get_class_methods ( $ observer ) , get_class_methods ( 'JPlugin' ) ) ; } $ key = key ( $ this -> _observers ) ; foreach ( $ methods as $ method ) { $ method = strtolower ( $ method ) ; if ( ! isset ( $ this -> _methods [ $ method ] ) ) { $ this -> _methods [ $ method ] = array ( ) ; } $ this -> _methods [ $ method ] [ ] = $ key ; } }
|
Attach an observer object
|
7,170
|
public function detach ( $ observer ) { $ retval = false ; $ key = array_search ( $ observer , $ this -> _observers ) ; if ( $ key !== false ) { unset ( $ this -> _observers [ $ key ] ) ; $ retval = true ; foreach ( $ this -> _methods as & $ method ) { $ k = array_search ( $ key , $ method ) ; if ( $ k !== false ) { unset ( $ method [ $ k ] ) ; } } } return $ retval ; }
|
Detach an observer object
|
7,171
|
public static function attr ( $ attr = array ( ) ) { $ buffer = " " ; foreach ( $ attr as $ key => $ value ) { $ buffer .= $ key . '="' . $ value . '" ' ; } return substr ( $ buffer , 0 , - 1 ) ; }
|
generates element attribute string
|
7,172
|
public function render ( ) { if ( is_closure ( $ this -> value ) ) { ob_start ( ) ; $ return = call_user_func ( $ this -> value ) ; $ this -> value = ob_get_clean ( ) . $ return ; } return '<' . $ this -> name . static :: attr ( $ this -> attr ) . ( ! is_null ( $ this -> value ) ? '>' . $ this -> value . '</' . $ this -> name . '>' : ' />' ) ; }
|
render this element
|
7,173
|
public function save ( string $ namespace , string $ hash , string $ content ) : void { $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; $ this -> ensureDirectory ( dirname ( $ fileName ) ) ; $ success = false ; if ( ! file_exists ( $ fileName ) || is_writable ( $ fileName ) ) { $ success = file_put_contents ( $ fileName , $ content ) ; } if ( $ success === false ) { throw new ExportDataException ( 'Unable to write file ' . $ fileName ) ; } }
|
Saves the content under the specified hash .
|
7,174
|
public function load ( string $ namespace , string $ hash ) : ? string { $ result = null ; $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; if ( file_exists ( $ fileName ) && is_readable ( $ fileName ) ) { $ result = file_get_contents ( $ fileName ) ; } return is_string ( $ result ) ? $ result : null ; }
|
Loads and returns the content of the specified hash if available .
|
7,175
|
public function delete ( string $ namespace , string $ hash ) : void { $ fileName = $ this -> getFileName ( $ namespace , $ hash ) ; if ( file_exists ( $ fileName ) ) { unlink ( $ fileName ) ; } }
|
Deletes the content under the specified hash .
|
7,176
|
protected function getFileName ( string $ namespace , string $ hash ) : string { $ fileName = implode ( DIRECTORY_SEPARATOR , [ $ this -> directory , $ namespace , substr ( $ hash , 0 , 2 ) , $ hash ] ) ; return $ fileName ; }
|
Returns the filename to use to save the content with the specified namespace and hash .
|
7,177
|
protected function ensureDirectory ( string $ directory ) : void { if ( ! is_dir ( $ directory ) ) { $ success = @ mkdir ( $ directory , 0775 , true ) ; if ( ! $ success && ! is_dir ( $ directory ) ) { throw new ExportDataException ( 'Unable to create directory ' . $ directory . '.' ) ; } } if ( ! is_writable ( $ directory ) ) { throw new ExportDataException ( 'Directory ' . $ directory . ' is not writable.' ) ; } }
|
Ensures that the specified directory is available and writable .
|
7,178
|
public function getAllHashes ( string $ namespace ) : array { $ directory = implode ( DIRECTORY_SEPARATOR , [ $ this -> directory , $ namespace , ] ) ; $ result = [ ] ; if ( is_dir ( $ directory ) ) { $ directoryIterator = new RecursiveDirectoryIterator ( $ directory , RecursiveDirectoryIterator :: SKIP_DOTS ) ; foreach ( new RecursiveIteratorIterator ( $ directoryIterator ) as $ file ) { $ result [ ] = $ file -> getFilename ( ) ; } } return $ result ; }
|
Returns all hashes currently known to the adapter .
|
7,179
|
protected function delete ( array $ criteria = array ( ) ) { $ conditions = array ( ) ; foreach ( $ criteria as $ field => $ value ) { $ conditions [ ] = "$field = ?" ; } $ sql = "DELETE FROM $this->_table WHERE " . implode ( ' AND ' , $ conditions ) ; $ pdos = $ this -> _pdo -> prepare ( $ sql ) ; $ pdos -> execute ( array_values ( $ criteria ) ) ; return $ pdos -> statement ( ) -> rowCount ( ) ; }
|
Function SQL DELETE
|
7,180
|
protected function insert ( array $ data = array ( ) ) { $ fields = array ( ) ; $ values = array ( ) ; foreach ( $ data as $ field => $ value ) { $ fields [ ] = $ field ; $ values [ ] = '?' ; } $ sql = "INSERT INTO $this->_table " . "(" . implode ( ', ' , $ fields ) . ")" . "VALUES (" . implode ( ', ' , $ values ) . ")" ; $ pdos = $ this -> _pdo -> prepare ( $ sql ) ; $ pdos -> execute ( array_values ( $ data ) ) ; return $ pdos -> statement ( ) -> rowCount ( ) ; }
|
Function SQL INSERT
|
7,181
|
protected function select ( array $ fields , array $ criteria = array ( ) , array $ operators = array ( ) , array $ conditions = array ( ) ) { $ sql = "" ; $ stringConditions = array ( ) ; if ( ( ! empty ( $ criteria ) && ! empty ( $ operators ) ) && ! empty ( $ conditions ) ) { if ( ( count ( $ criteria ) == count ( $ operators ) && ( count ( $ criteria ) - 1 ) == count ( $ conditions ) ) && ( ( count ( $ operators ) - 1 ) != count ( $ conditions ) && count ( $ criteria ) > 1 ) ) { throw new \ Exception ( "The number of Criteria, Operators and Conditions are not equals." ) ; } $ criteriaFields = array_keys ( $ criteria ) ; $ stringConditions [ ] = "$criteriaFields[0] $operators[0] ?" ; for ( $ i = 1 ; $ i < count ( $ criteriaFields ) ; $ i ++ ) { $ j = $ i - 1 ; $ stringConditions [ ] = "$conditions[$j] $criteriaFields[$i] $operators[$i] ?" ; } $ sql = "SELECT " . implode ( ', ' , $ fields ) . " FROM $this->_table " . "WHERE " . implode ( ' ' , $ stringConditions ) ; } elseif ( ( ! empty ( $ criteria ) && ! empty ( $ operators ) ) && count ( $ criteria ) > 1 ) { if ( count ( $ criteria ) != count ( $ operators ) ) { throw new \ Exception ( "The number of Criteria and Operators are not equals." ) ; } $ criteriaFields = array_keys ( $ criteria ) ; for ( $ i = 0 ; $ i < count ( $ criteriaFields ) ; $ i ++ ) { $ stringConditions [ ] = "$criteriaFields[$i] $operators[$i] ?" ; } $ sql = "SELECT " . implode ( ', ' , $ fields ) . " FROM $this->_table " . "WHERE " . implode ( ' AND ' , $ stringConditions ) ; } elseif ( ! empty ( $ criteria ) ) { foreach ( $ criteria as $ field => $ value ) { $ stringConditions [ ] = "$field = ?" ; } $ sql = "SELECT " . implode ( ', ' , $ fields ) . " FROM $this->_table " . "WHERE " . implode ( ' AND ' , $ stringConditions ) ; } elseif ( ! empty ( $ fields ) ) { $ sql = "SELECT " . implode ( ', ' , $ fields ) . " FROM $this->_table" ; } $ pdos = $ this -> _pdo -> prepare ( $ sql ) ; $ pdos -> execute ( array_values ( $ criteria ) ) ; return $ pdos -> fetchAll ( ) ; }
|
Function SQL SELECT
|
7,182
|
protected function update ( array $ data = array ( ) , array $ criteria ) { $ set = array ( ) ; foreach ( $ data as $ columnName => $ value ) { $ set [ ] = "$columnName = ?" ; } $ params = array_merge ( array_values ( $ data ) , array_values ( $ criteria ) ) ; $ sql = "UPDATE $this->_table SET " . implode ( ', ' , $ set ) . " WHERE " . implode ( ' = ? AND ' , array_keys ( $ criteria ) ) . " = ?" ; $ pdos = $ this -> _pdo -> prepare ( $ sql ) ; $ pdos -> execute ( $ params ) ; return $ pdos -> statement ( ) -> rowCount ( ) ; }
|
Function SQL UPDATE
|
7,183
|
protected function prepareDatabaseEcosystem ( ) { $ basePath = realpath ( '../' ) ; $ dbPath = $ basePath . '/' . $ this -> options [ 'dbPath' ] . '/' . $ this -> options [ 'database' ] ; if ( ! is_dir ( $ dbPath ) ) { mkdir ( $ dbPath , 0755 , true ) ; } $ this -> dbPath = realpath ( $ dbPath ) ; }
|
Prepare database file and folder structure .
|
7,184
|
public function getCollectionData ( $ collection , $ criteria = null ) { if ( is_null ( $ this -> dbPath ) ) { $ this -> prepareDatabaseEcosystem ( ) ; } if ( ! is_dir ( $ this -> dbPath . '/' . $ collection ) ) { mkdir ( $ this -> dbPath . '/' . $ collection , 0755 , true ) ; } $ rows = array ( ) ; if ( $ handle = opendir ( $ this -> dbPath . '/' . $ collection ) ) { while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( ! in_array ( $ entry , array ( '.' , '..' ) ) ) { if ( is_readable ( $ pathToFile = $ this -> dbPath . '/' . $ collection . '/' . $ entry ) ) { $ match = true ; $ raw = file_get_contents ( $ pathToFile ) ; $ content = json_decode ( $ raw , true ) ; if ( ! is_null ( $ criteria ) and ! empty ( $ criteria ) ) { if ( isset ( $ criteria [ '!or' ] ) ) { $ string = reset ( array_values ( reset ( $ criteria [ '!or' ] ) ) ) ; if ( ! preg_match ( '/' . $ string . '/' , strtolower ( $ raw ) ) ) { $ match = false ; } } else { $ intersection = array_intersect_assoc ( $ content , $ criteria ) ; if ( empty ( $ intersection ) ) { $ match = false ; } } } if ( $ match ) { $ rows [ ] = $ content ; } } } } closedir ( $ handle ) ; } return $ rows ; }
|
Getter for specific data for collection
|
7,185
|
protected function writeDeclaration ( ClassDeclaration $ declaration , string $ type = null ) { $ type = $ type ?? static :: ELEMENT ; $ filename = $ this -> config -> classFilename ( $ type , $ this -> argument ( 'name' ) ) ; $ filename = $ this -> files -> normalizePath ( $ filename ) ; if ( $ this -> files -> exists ( $ filename ) ) { $ this -> writeln ( "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " . "file '<comment>{$filename}</comment>' already exists.</fg=red>" ) ; return ; } $ file = new FileDeclaration ( $ this -> config -> classNamespace ( $ type , $ this -> argument ( 'name' ) ) ) ; $ file -> setComment ( $ this -> config -> headerLines ( ) ) ; $ file -> addElement ( $ declaration ) ; $ this -> files -> write ( $ filename , $ file -> render ( ) , FilesInterface :: READONLY , true ) ; $ this -> writeln ( "Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'." ) ; }
|
Write declaration into file .
|
7,186
|
public function insert ( $ sessionId , $ clientId ) { $ this -> session_id = $ sessionId ; $ this -> client_id = $ clientId ; $ this -> time = time ( ) ; $ ret = $ this -> _db -> insertObject ( $ this -> _tbl , $ this , 'session_id' ) ; if ( ! $ ret ) { $ this -> setError ( JText :: sprintf ( 'JLIB_DATABASE_ERROR_STORE_FAILED' , strtolower ( get_class ( $ this ) ) , $ this -> _db -> stderr ( ) ) ) ; return false ; } else { return true ; } }
|
Insert a session
|
7,187
|
public function update ( $ updateNulls = false ) { $ this -> time = time ( ) ; $ ret = $ this -> _db -> updateObject ( $ this -> _tbl , $ this , 'session_id' , $ updateNulls ) ; if ( ! $ ret ) { $ this -> setError ( JText :: sprintf ( 'JLIB_DATABASE_ERROR_STORE_FAILED' , strtolower ( get_class ( $ this ) ) , $ this -> _db -> stderr ( ) ) ) ; return false ; } else { return true ; } }
|
Updates the session
|
7,188
|
public function destroy ( $ userId , $ clientIds = array ( ) ) { $ clientIds = implode ( ',' , $ clientIds ) ; $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'userid' ) . ' = ' . $ this -> _db -> quote ( $ userId ) ) -> where ( $ this -> _db -> quoteName ( 'client_id' ) . ' IN (' . $ clientIds . ')' ) ; $ this -> _db -> setQuery ( $ query ) ; if ( ! $ this -> _db -> execute ( ) ) { $ this -> setError ( $ this -> _db -> stderr ( ) ) ; return false ; } return true ; }
|
Destroys the pre - existing session
|
7,189
|
public function purge ( $ maxLifetime = 1440 ) { $ past = time ( ) - $ maxLifetime ; $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'time' ) . ' < ' . ( int ) $ past ) ; $ this -> _db -> setQuery ( $ query ) ; return $ this -> _db -> execute ( ) ; }
|
Purge old sessions
|
7,190
|
public function exists ( $ userid ) { $ query = $ this -> _db -> getQuery ( true ) -> select ( 'COUNT(userid)' ) -> from ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( 'userid' ) . ' = ' . $ this -> _db -> quote ( $ userid ) ) ; $ this -> _db -> setQuery ( $ query ) ; if ( ! $ result = $ this -> _db -> loadResult ( ) ) { $ this -> setError ( $ this -> _db -> stderr ( ) ) ; return false ; } return ( boolean ) $ result ; }
|
Find out if a user has one or more active sessions
|
7,191
|
public function delete ( $ oid = null ) { $ k = $ this -> _tbl_key ; if ( $ oid ) { $ this -> $ k = $ oid ; } $ query = $ this -> _db -> getQuery ( true ) -> delete ( $ this -> _db -> quoteName ( $ this -> _tbl ) ) -> where ( $ this -> _db -> quoteName ( $ this -> _tbl_key ) . ' = ' . $ this -> _db -> quote ( $ this -> $ k ) ) ; $ this -> _db -> setQuery ( $ query ) ; $ this -> _db -> execute ( ) ; return true ; }
|
Overloaded delete method
|
7,192
|
public function setModelId ( $ modelId ) { $ this -> modelId = ( string ) $ modelId ; $ this -> model = null ; return $ this ; }
|
Set the FrameModel id
|
7,193
|
public function setModel ( FrameModel $ frameModel ) { $ this -> modelId = null ; $ this -> model = $ frameModel ; return $ this ; }
|
Set the FrameModel
|
7,194
|
public static function escapeText ( $ text , $ addApostrophes = true ) { $ dangers = array ( '\\' , '"' , "\n" ) ; $ replacements = array ( '\\\\' , '\\"' , '\\n' ) ; $ escapedText = str_ireplace ( $ dangers , $ replacements , $ text ) ; if ( $ addApostrophes ) { $ escapedText = '"' . $ escapedText . '"' ; } return $ escapedText ; }
|
Escape dangerous characters in the given text
|
7,195
|
public static function getReal ( $ value ) { $ value = ( float ) $ value ; $ stringVal = ( string ) $ value ; if ( ! fmod ( $ value , 1 ) ) { $ stringVal .= "." ; } return $ stringVal ; }
|
Get the Real string representation of the given value
|
7,196
|
public static function getArray ( array $ array , $ associative = true ) { $ arrayText = "[" ; $ index = 0 ; $ count = count ( $ array ) ; foreach ( $ array as $ key => $ value ) { if ( $ associative ) { $ arrayText .= static :: getValue ( $ key ) ; $ arrayText .= " => " ; } $ arrayText .= static :: getValue ( $ value ) ; if ( $ index < $ count - 1 ) { $ arrayText .= ", " ; $ index ++ ; } } return $ arrayText . "]" ; }
|
Get the string representation of the given array
|
7,197
|
public static function getValue ( $ value ) { if ( is_string ( $ value ) ) { return static :: escapeText ( $ value ) ; } if ( is_bool ( $ value ) ) { return static :: getBoolean ( $ value ) ; } if ( is_array ( $ value ) ) { return static :: getArray ( $ value ) ; } return $ value ; }
|
Get the string representation for the given value
|
7,198
|
public static function getInclude ( $ file , $ namespace = null ) { if ( ! $ namespace && stripos ( $ file , "." ) === false ) { $ namespace = $ file ; } $ file = static :: escapeText ( $ file ) ; $ includeText = "#Include {$file}" ; if ( $ namespace ) { $ includeText .= " as {$namespace}" ; } return $ includeText . "" ; }
|
Get the include command for the given file and namespace
|
7,199
|
public function getByCriteria ( $ collection , $ criteria ) { if ( $ data = $ this -> findOne ( $ collection , $ criteria ) ) { $ obj = $ this -> container -> get ( $ this -> classMap -> getClassForResult ( $ collection , $ data ) ) ; $ obj -> setCollection ( $ collection ) ; $ obj -> loadFromArray ( $ data ) ; return $ obj ; } return null ; }
|
convenience method to retrieve object by criteria should be used in public static method by the derived class
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.