idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
5,200
|
public function remove ( string $ string , bool $ caseSensitive = true ) : Manipulator { return new static ( $ this -> replace ( $ string , '' , $ caseSensitive ) -> toString ( ) ) ; }
|
Remove from string .
|
5,201
|
public function removeSpecialCharacters ( array $ exceptions = [ ] ) : Manipulator { $ regEx = "/" ; $ regEx .= "[^\w\d" ; foreach ( $ exceptions as $ exception ) { $ regEx .= "\\" . $ exception ; } $ regEx .= "]/" ; $ modifiedString = preg_replace ( $ regEx , '' , $ this -> string ) ; return new static ( $ modifiedString ) ; }
|
Remove non - alphanumeric characters .
|
5,202
|
public function snakeToCamel ( ) : Manipulator { $ modifiedString = $ this -> replace ( '_' , ' ' ) -> capitalizeEach ( ) -> lowercaseFirst ( ) -> remove ( ' ' ) -> toString ( ) ; return new static ( $ modifiedString ) ; }
|
Convert snake - case to camel - case .
|
5,203
|
public function toCamelCase ( ) : Manipulator { $ modifiedString = '' ; foreach ( explode ( ' ' , $ this -> string ) as $ word ) { $ modifiedString .= self :: make ( $ word ) -> toLower ( ) -> capitalize ( ) -> toString ( ) ; } $ final = self :: make ( $ modifiedString ) -> replace ( ' ' , '' ) -> lowercaseFirst ( ) -> toString ( ) ; return new static ( $ final ) ; }
|
Convert a string to camel - case .
|
5,204
|
public function send ( BroadcastInterface $ broadcast = null ) { if ( $ broadcast === null && $ this -> broadcast === null ) { $ broadcast = Yii :: $ app -> getBroadcast ( ) ; } elseif ( $ broadcast === null ) { $ broadcast = $ this -> broadcast ; } return $ broadcast -> send ( $ this ) ; }
|
Sends this broadcast message .
|
5,205
|
public function registerEntityClassesMetadataDriver ( Array $ classes = array ( ) , $ namespace = 'Psc' , \ Doctrine \ Common \ Annotations \ Reader $ reader = NULL ) { if ( ! isset ( $ this -> entityClassesMetadataDriver ) ) { if ( ! isset ( $ reader ) ) { $ reader = $ this -> createAnnotationReader ( ) ; } $ this -> entityClassesMetadataDriver = new \ Psc \ Doctrine \ MetadataDriver ( $ reader , NULL , $ classes ) ; $ this -> registerMetadataDriver ( $ this -> entityClassesMetadataDriver , $ namespace ) ; } return $ this ; }
|
Erstellt den EntityClassesMetadataDriver
|
5,206
|
public function useCache ( $ type = self :: CACHE_APC ) { if ( $ type === self :: CACHE_APC ) { $ this -> setCache ( new \ Doctrine \ Common \ Cache \ ApcCache ) ; } else { $ this -> setCache ( new \ Doctrine \ Common \ Cache \ ArrayCache ) ; } }
|
Overwrites the current cache
|
5,207
|
public static function fromEncodedDer ( $ encodedDerCert ) { $ pemCert = sprintf ( '-----BEGIN CERTIFICATE-----%s-----END CERTIFICATE-----' , PHP_EOL . wordwrap ( $ encodedDerCert , 64 , "\n" , true ) . PHP_EOL ) ; return new self ( $ pemCert ) ; }
|
Create a new CertParser object from the Base 64 encoded DER i . e . a base64_encode of a binary string .
|
5,208
|
private function toDer ( ) { $ pattern = '/.*-----BEGIN CERTIFICATE-----(.*)-----END CERTIFICATE-----.*/msU' ; $ replacement = '${1}' ; $ plainPemData = preg_replace ( $ pattern , $ replacement , $ this -> pemCert ) ; if ( null === $ plainPemData ) { throw new RuntimeException ( 'unable to extract the encoded DER data from the certificate' ) ; } $ search = array ( ' ' , "\t" , "\n" , "\r" , "\0" , "\x0B" ) ; $ encodedDerCert = str_replace ( $ search , '' , $ plainPemData ) ; return base64_decode ( $ encodedDerCert ) ; }
|
Get the DER format of the certificate .
|
5,209
|
public function getFingerprint ( $ alg = 'sha256' ) { if ( ! in_array ( $ alg , hash_algos ( ) ) ) { throw new RuntimeException ( sprintf ( 'unsupported algorithm "%s"' , $ alg ) ) ; } return hash ( $ alg , $ this -> toDer ( ) , true ) ; }
|
Get the raw fingerprint of the certificate .
|
5,210
|
public function restart ( int $ sleep ) : void { $ this -> storage [ 'sentenced' ] = 'rewind' ; $ this -> storage [ 'sleep' ] = $ sleep ; $ this -> store ( $ this -> storage ) ; }
|
Gently stops daemon and starts it with new frequency
|
5,211
|
public function exec ( ) : void { $ this -> actionLog ( 'Script successfully entered' ) ; $ sentence = $ this -> storage [ 'sentenced' ] ; $ response = NULL ; if ( method_exists ( $ this , $ sentence ) ) $ response = $ this -> $ sentence ( ) ; else $ this -> errorLog ( 'Unknown method ' . $ sentence ) ; if ( $ response ) $ this -> actionLog ( 'Received data: ' . $ response ) ; $ this -> setMemory ( memory_get_usage ( TRUE ) ) ; $ this -> actionLog ( 'Script successfully completed, action: ' . $ sentence ) ; }
|
Makes preparations for run method Also stores memory used by daemon to be recovered
|
5,212
|
public static function route ( string $ command , array $ args ) : void { $ object = new static ( 'test' ) ; echo "\n" ; if ( method_exists ( static :: class , $ command ) ) { $ response = call_user_func_array ( [ $ object , $ command ] , $ args ) ; if ( $ response === NULL ) echo "SUCCESS" ; else if ( $ response === FALSE ) echo "FALSE" ; else if ( $ response === TRUE ) echo "TRUE" ; else { if ( is_string ( $ response ) ) echo $ response ; else print_r ( $ response ) ; } } else echo "No such method available" ; echo "\n\n" ; }
|
Start a command to services
|
5,213
|
public static function _init ( ) { if ( \ ClanCats :: in_development ( ) ) { \ CCEvent :: mind ( 'response.output' , function ( $ output ) { if ( strpos ( $ output , '</body>' ) === false ) { return $ output ; } $ table = \ UI \ Table :: create ( array ( 'style' => array ( 'width' => '100%' , ) , 'cellpadding' => '5' , 'class' => 'table debug-table debug-table-db' , ) ) ; $ table -> header ( array ( '#' , 'query' ) ) ; foreach ( static :: log ( ) as $ key => $ item ) { $ table -> row ( array ( $ key + 1 , $ item ) ) ; } return str_replace ( '</body>' , $ table . "\n</body>" , $ output ) ; } ) ; } }
|
Static init When we are in development then we append the qurey log to body
|
5,214
|
protected function connect ( $ name ) { if ( $ this -> _connected ) { return true ; } if ( is_array ( $ name ) ) { $ config = $ name ; } else { $ config = \ CCConfig :: create ( 'database' ) -> get ( $ name ) ; if ( is_string ( $ config ) ) { $ config = \ CCConfig :: create ( 'database' ) -> get ( $ config ) ; } } $ driver_class = __NAMESPACE__ . "\\Handler_" . ucfirst ( $ config [ 'driver' ] ) ; if ( ! class_exists ( $ driver_class ) ) { throw new Exception ( "DB\\Handler::connect - The driver (" . $ driver_class . ") is invalid." ) ; } $ this -> set_driver ( $ driver_class ) ; $ driver_class = __NAMESPACE__ . "\\Builder_" . ucfirst ( $ config [ 'driver' ] ) ; if ( ! class_exists ( $ driver_class ) ) { throw new Exception ( "DB\\Handler::connect - The builder (" . $ driver_class . ") is invalid." ) ; } $ this -> set_builder ( $ driver_class ) ; if ( $ this -> driver ( ) -> connect ( $ config ) ) { return $ this -> _connected = true ; } return $ this -> _connected = false ; }
|
Try to etablish a connetion to the database . Also assign the connection and query builder to the current DB driver .
|
5,215
|
public function statement ( $ query , $ params = array ( ) ) { $ sth = $ this -> driver ( ) -> connection ( ) -> prepare ( $ query ) ; try { $ sth -> execute ( $ params ) ; } catch ( \ PDOException $ e ) { throw new Exception ( "DB\\Handler - PDOException: {$e->getMessage()} \n Query: {$query}" ) ; } if ( \ ClanCats :: in_development ( ) ) { $ keys = array ( ) ; foreach ( $ params as $ key => $ value ) { if ( is_string ( $ key ) ) { $ keys [ ] = '/:' . $ key . '/' ; } else { $ keys [ ] = '/[?]/' ; } } static :: $ _query_log [ ] = preg_replace ( $ keys , $ params , $ query , 1 ) ; } return $ sth ; }
|
Run the query and return the PDO statement
|
5,216
|
public function fetch ( $ query , $ params = array ( ) , $ arguments = array ( 'obj' ) ) { $ sth = $ this -> statement ( $ query , $ params ) ; $ args = null ; foreach ( $ arguments as $ argument ) { $ args |= constant ( "\PDO::FETCH_" . strtoupper ( $ argument ) ) ; } return $ sth -> fetchAll ( $ args ) ; }
|
Run the query and fetch the results
|
5,217
|
public function run ( $ query , $ params = array ( ) ) { $ sth = $ this -> statement ( $ query , $ params ) ; $ type = strtolower ( substr ( $ query , 0 , strpos ( $ query , ' ' ) ) ) ; switch ( $ type ) { case 'update' : case 'delete' : return $ sth -> rowCount ( ) ; break ; case 'insert' : return $ this -> driver ( ) -> connection ( ) -> lastInsertId ( ) ; break ; } return $ sth ; }
|
Run the query and get the correct response
|
5,218
|
public function get ( $ name ) { $ query = $ this -> queryAll ( ) ; return isset ( $ query [ $ name ] ) ? $ query [ $ name ] : null ; }
|
Get value from GET params
|
5,219
|
public function render ( & $ node ) { $ id = call_user_func_array ( [ & $ this , 'fetchId' ] , $ node ) ; $ output = call_user_func_array ( [ & $ this , 'fetchItem' ] , $ node ) ; list ( $ source ) = $ node ; list ( $ plugin ) = pluginSplit ( $ source ) ; $ options = [ 'id' => $ id , 'output' => $ output , 'class' => $ node [ 'class' ] , ] ; $ element = 'Toolbar/wrapper' ; if ( $ plugin !== null ) { $ element = $ plugin . '.' . $ element ; } return $ this -> _view -> element ( $ element , $ options ) ; }
|
Render toolbar html .
|
5,220
|
protected function isInIncrementsOfRange ( $ increments , $ value ) { $ incrementsParts = explode ( '/' , $ increments ) ; if ( '*' === $ incrementsParts [ 0 ] ) { return ( int ) $ value % $ incrementsParts [ 1 ] === 0 ; } if ( ! $ this -> isInRange ( $ incrementsParts [ 0 ] , $ value ) ) { return false ; } $ rangeParts = explode ( '-' , $ incrementsParts [ 0 ] ) ; for ( $ i = $ rangeParts [ 0 ] ; $ i <= $ rangeParts [ 1 ] ; $ i += $ incrementsParts [ 1 ] ) { if ( $ i == $ value ) { return true ; } } return false ; }
|
Checks if the given value is in the given increments of range .
|
5,221
|
protected function isInRange ( $ range , $ value ) { $ parts = explode ( '-' , $ range ) ; return $ value >= $ parts [ 0 ] && $ value <= $ parts [ 1 ] ; }
|
Checks if the given value is in the given range .
|
5,222
|
public function setControl ( Control $ control ) { $ control -> checkId ( ) ; if ( $ control instanceof Scriptable ) { $ control -> setScriptEvents ( true ) ; } $ this -> control = $ control ; return $ this ; }
|
Set the Profile Control
|
5,223
|
public static function toHex ( $ args ) { if ( func_num_args ( ) != 1 || ! is_array ( $ args ) ) { $ args = func_get_args ( ) ; } $ ret = '' ; for ( $ i = 0 ; $ i < count ( $ args ) ; $ i ++ ) $ ret .= sprintf ( '%02x' , $ args [ $ i ] ) ; return $ ret ; }
|
convert a number array to a hex string
|
5,224
|
public static function toNumbers ( $ s ) { $ ret = array ( ) ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i += 2 ) { $ ret [ ] = hexdec ( substr ( $ s , $ i , 2 ) ) ; } return $ ret ; }
|
convert a hex string to a number array
|
5,225
|
protected function insecureEmailChange ( ) { $ this -> user -> email = $ this -> email ; Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( 'yuncms' , 'Your email address has been changed' ) ) ; }
|
Changes user s email address to given without any confirmation .
|
5,226
|
public function is_current_section ( ) { if ( ! isset ( $ this -> active ) ) { $ this -> active = filter_input ( INPUT_GET , 'section' ) == $ this -> get_slug ( ) ; } return $ this -> active ; }
|
Check if this is the current section .
|
5,227
|
public function get_fields ( ) { if ( ! isset ( $ this -> fields ) ) { if ( ! $ this -> has_sub_sections ( ) ) { $ this -> fields = $ this -> model [ 'fields' ] ; } else { $ this -> fields = array ( ) ; foreach ( $ this -> model [ 'subsections' ] as $ subsection ) { foreach ( $ subsection [ 'fields' ] as $ field ) { $ field -> subsection = \ Amarkal \ Common \ Tools :: strtoslug ( $ subsection [ 'title' ] ) ; } $ this -> fields = array_merge ( $ this -> fields , $ subsection [ 'fields' ] ) ; } } } return $ this -> fields ; }
|
Get the array of fields for this section . If this section has subsections the returning array will consist of all fields from all subsections .
|
5,228
|
public function getUser ( ) { $ this -> user = $ this -> sessionStorage -> read ( 'user' ) ; if ( ! empty ( $ this -> user ) ) { return $ this -> user ; } $ this -> exchangeToken ( ) ; return $ this -> user ; }
|
Get User object
|
5,229
|
public function getAccessToken ( ) { if ( ! empty ( $ this -> accessToken ) ) { return $ this -> accessToken ; } $ accessToken = $ this -> sessionStorage -> read ( 'access_token' ) ; if ( ! empty ( $ accessToken ) ) { $ this -> accessToken = $ accssToken ; return $ this -> accessToken ; } $ this -> exchangeToken ( ) ; return $ this -> accessToken ; }
|
Get Access token .
|
5,230
|
public function getRefreshToken ( ) { if ( empty ( $ this -> refreshToken ) ) { $ this -> refreshToken = $ this -> sessionStorage -> read ( 'refresh_token' ) ; return $ this -> refreshToken ; } return $ this -> refreshToken ; }
|
Get Refresh token .
|
5,231
|
public function requestClientCredentials ( $ options = array ( ) ) { $ options = array_merge ( array ( 'scope' => '' , ) , $ options ) ; $ res = $ this -> sendRequest ( 'POST' , $ this -> getUrl ( 'oauth' , 'token' ) , array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'grant_type' => 'client_credentials' , 'scope' => $ options [ 'scope' ] , ) ) ; $ result = $ res -> getBody ( ) ; $ token = null ; if ( $ result && $ result = json_decode ( $ result , true ) ) { if ( ! empty ( $ result [ 'error' ] ) ) { throw new Exception ( $ result [ 'error_description' ] ) ; } if ( ! empty ( $ result [ 'access_token' ] ) ) { $ this -> accessToken = $ token = $ result [ 'access_token' ] ; } } if ( empty ( $ token ) ) { throw new InvalidTokenException ( 'token not available.' ) ; } return $ token ; }
|
Request Client Credentials token
|
5,232
|
public function getLoginUrl ( $ options = array ( ) ) { $ options = array_merge ( array ( 'scope' => 'openid profile' , ) , $ options ) ; if ( isset ( $ options [ 'scope' ] ) && is_array ( $ options [ 'scope' ] ) ) { $ options [ 'scope' ] = join ( ' ' , $ options [ 'scope' ] ) ; } if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ nonce = sha1 ( openssl_random_pseudo_bytes ( 24 ) ) ; } else { $ nonce = sha1 ( uniqid ( mt_rand ( ) , true ) ) ; } $ this -> sessionStorage -> write ( 'nonce' , $ nonce ) ; return $ this -> getUrl ( 'oauth' , 'authorize' , array ( 'client_id' => $ this -> getClientId ( ) , 'response_type' => 'code' , 'scope' => $ options [ 'scope' ] , 'redirect_uri' => isset ( $ options [ 'redirect_uri' ] ) ? $ options [ 'redirect_uri' ] : $ this -> redirectUri , 'nonce' => $ nonce , ) ) ; }
|
Get login url for redirect .
|
5,233
|
protected function exchangeToken ( ) { $ result = $ this -> requestAccessToken ( ) ; if ( $ result && ! empty ( $ result [ 'access_token' ] ) ) { $ this -> accessToken = $ result [ 'access_token' ] ; $ this -> sessionStorage -> write ( 'access_token' , $ result [ 'access_token' ] ) ; if ( ! empty ( $ result [ 'refresh_token' ] ) ) { $ this -> refreshToken = $ result [ 'refresh_token' ] ; $ this -> sessionStorage -> write ( 'refresh_token' , $ result [ 'refresh_token' ] ) ; } if ( ! empty ( $ result [ 'id_token' ] ) ) { $ this -> validateIdToken ( $ result [ 'id_token' ] ) ; $ this -> user = $ this -> requestUserInfo ( ) ; if ( $ this -> user ) { $ this -> sessionStorage -> write ( 'user' , $ this -> user ) ; } } } }
|
Exchange code to access_token
|
5,234
|
protected function requestUserInfo ( ) { $ res = $ this -> sendRequest ( 'GET' , $ this -> getUrl ( 'oauth' , 'userinfo' ) , array ( ) , array ( 'Authorization' => 'Bearer ' . $ this -> sessionStorage -> read ( 'access_token' ) , ) ) ; $ result = $ res -> getBody ( ) ; return json_decode ( $ result , true ) ; }
|
Request User Info
|
5,235
|
protected function requestAccessToken ( ) { $ code = $ this -> getRequestVar ( 'code' ) ; if ( ! empty ( $ code ) ) { $ res = $ this -> sendRequest ( 'POST' , $ this -> getUrl ( 'oauth' , 'token' ) , array ( 'code' => $ code , 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ this -> redirectUri , ) ) ; $ result = $ res -> getBody ( ) ; if ( $ result && $ result = json_decode ( $ result , true ) ) { if ( ! empty ( $ result [ 'error' ] ) ) { throw new Exception ( $ result [ 'error_description' ] ) ; } return $ result ; } } return null ; }
|
Request Access Token
|
5,236
|
public function getUrl ( $ type , $ path , $ params = array ( ) ) { $ url = self :: $ URL_TABLE [ $ type ] . $ path ; if ( ! empty ( $ params ) ) { $ url .= '?' . http_build_query ( $ params ) ; } return $ url ; }
|
Build API Url
|
5,237
|
protected function getCurrentUrl ( ) { $ isHttps = $ this -> getServerVar ( 'HTTPS' ) ; $ forwardedProto = $ this -> getServerVar ( 'HTTP_X_FORWARDED_PROTO' ) ; if ( $ isHttps == 'on' || $ forwardedProto === 'https' ) { $ schema = 'https://' ; } else { $ schema = 'http://' ; } $ host = $ this -> getServerVar ( 'HTTP_HOST' ) ; if ( preg_match ( '#:(\d+)$#' , $ host , $ match ) ) { $ port = ':' . $ match [ 1 ] ; } else { $ port = '' ; } $ urls = parse_url ( $ this -> getServerVar ( 'REQUEST_URI' ) ) ; $ path = $ urls [ 'path' ] ; $ query = '' ; return $ schema . $ host . $ port . $ path . $ query ; }
|
Get Current Url
|
5,238
|
protected function validateIdToken ( $ idToken ) { $ segments = explode ( '.' , $ idToken ) ; if ( count ( $ segments ) != 3 ) { throw new InvalidIdTokenException ( 'Invalid Token' ) ; } $ header = json_decode ( $ this -> decodeBase64Url ( $ segments [ 0 ] ) , true ) ; if ( empty ( $ header ) ) { throw new InvalidIdTokenException ( 'Invalid Token' ) ; } $ payload = json_decode ( $ this -> decodeBase64Url ( $ segments [ 1 ] ) , true ) ; if ( empty ( $ payload ) ) { throw new InvalidIdTokenException ( 'Invalid Token' ) ; } $ signature = $ this -> decodeBase64Url ( $ segments [ 2 ] ) ; $ signingInput = implode ( '.' , array ( $ segments [ 0 ] , $ segments [ 1 ] ) ) ; $ kid = isset ( $ header [ 'kid' ] ) ? $ header [ 'kid' ] : null ; switch ( $ header [ 'alg' ] ) { case 'RS256' : case 'RS384' : case 'RS512' : $ publicKey = $ this -> getPublicKey ( $ kid ) ; $ algo = 'sha' . substr ( $ header [ 'alg' ] , 2 ) ; if ( openssl_verify ( $ signingInput , $ signature , $ publicKey , $ algo ) != 1 ) { openssl_free_key ( $ publicKey ) ; throw new InvalidIdTokenException ( 'Signature Mismatch' ) ; } openssl_free_key ( $ publicKey ) ; break ; default : throw new InvalidIdTokenException ( 'Unsupported Algorithm: ' . $ header [ 'alg' ] ) ; } if ( $ payload [ 'iss' ] != 'minecraft.jp' ) { throw new InvalidIdTokenException ( 'Invalid Issuer.' ) ; } if ( $ payload [ 'aud' ] != $ this -> getClientId ( ) ) { throw new InvalidIdTokenException ( 'Client ID Mismatch.' ) ; } $ now = time ( ) ; if ( $ payload [ 'exp' ] < $ now || $ payload [ 'iat' ] < $ now - 600 ) { throw new InvalidIdTokenException ( 'ID Token expired.' ) ; } if ( $ payload [ 'nonce' ] != $ this -> sessionStorage -> read ( 'nonce' ) ) { throw new InvalidIdTokenException ( 'Nonce Mismatch.' ) ; } $ this -> sessionStorage -> remove ( 'nonce' ) ; return $ payload ; }
|
Validate ID Token
|
5,239
|
public function read ( $ key ) { return isset ( $ _SESSION [ $ this -> prefix . $ key ] ) ? $ _SESSION [ $ this -> prefix . $ key ] : null ; }
|
Read from session
|
5,240
|
public function build ( $ sourceDir , $ outputDir ) { $ sourceList = $ this -> findSources ( $ sourceDir , $ outputDir ) ; return array_walk ( $ sourceList , [ $ this , 'publish' ] ) ; }
|
Build the site .
|
5,241
|
protected function findSources ( $ searchIn , $ outputTo ) { $ files = iterator_to_array ( new FilesystemIterator ( $ searchIn ) ) ; return array_map ( function ( SplFileInfo $ file ) use ( $ outputTo ) { return $ this -> makeSource ( $ file , $ outputTo ) ; } , $ files ) ; }
|
Create array of Sources from the given input directory .
|
5,242
|
public function makeSource ( SplFileInfo $ file , $ outputDir ) { return new Source ( $ file -> getPathname ( ) , $ outputDir . DIRECTORY_SEPARATOR . $ file -> getFilename ( ) ) ; }
|
Create a Source from the given file and output dir .
|
5,243
|
public function clean ( $ dir , $ preserveGit = false ) { $ filesystem = new Filesystem ( ) ; if ( ! $ filesystem -> exists ( $ dir ) ) { return $ filesystem -> makeDirectory ( $ dir , 0755 , true ) ; } foreach ( new FilesystemIterator ( $ dir ) as $ file ) { if ( $ preserveGit && $ file -> getFilename ( ) == '.git' ) { continue ; } if ( $ file -> isDir ( ) && ! $ file -> isLink ( ) ) { $ filesystem -> deleteDirectory ( $ file ) ; } else { $ filesystem -> delete ( $ file ) ; } } return true ; }
|
Remove the contents of a directory but not the directory itself .
|
5,244
|
public function prepare ( $ sql , array $ driverOptions = array ( ) ) { $ this -> numStatements ++ ; $ pdos = $ this -> _pdo -> prepare ( $ sql , $ driverOptions ) ; return new PDOStatement ( $ this , $ pdos ) ; }
|
Prepare the statement SQL
|
5,245
|
public function query ( $ sql ) { $ this -> numExecutes ++ ; $ this -> numStatements ++ ; $ pdos = $ this -> _pdo -> query ( $ sql ) ; return new PDOStatement ( $ this , $ pdos ) ; }
|
Executes the statement query
|
5,246
|
public function import ( $ contentItem , $ target , $ includeParent = false , $ includeChildren = true , $ duplicateStrategy = 'Overwrite' , $ params = array ( ) ) { $ this -> runOnImportStart ( ) ; $ this -> params = $ params ; $ queuedVersion = 'Queued' . get_class ( $ this ) ; if ( $ this -> config ( ) -> use_queue && ClassInfo :: exists ( 'QueuedJob' ) && ClassInfo :: exists ( $ queuedVersion ) ) { $ importer = new $ queuedVersion ( $ contentItem , $ target , $ includeParent , $ includeChildren , $ duplicateStrategy , $ params ) ; $ service = singleton ( 'QueuedJobService' ) ; $ service -> queueJob ( $ importer ) ; return $ importer ; } $ children = null ; if ( $ includeParent ) { $ children = new ArrayList ( ) ; $ children -> push ( $ contentItem ) ; } else { $ children = $ contentItem -> stageChildren ( ) ; } $ this -> importChildren ( $ children , $ target , $ includeChildren , $ duplicateStrategy ) ; $ this -> runOnImportEnd ( ) ; return true ; }
|
Import from a content source to a particular target
|
5,247
|
protected function importChildren ( $ children , $ parent , $ includeChildren , $ duplicateStrategy ) { if ( ! $ children ) { return ; } foreach ( $ children as $ child ) { $ pageType = $ this -> getExternalType ( $ child ) ; if ( isset ( $ this -> contentTransforms [ $ pageType ] ) ) { $ transformer = $ this -> contentTransforms [ $ pageType ] ; $ result = $ transformer -> transform ( $ child , $ parent , $ duplicateStrategy ) ; $ this -> extend ( 'onAfterImport' , $ result ) ; if ( $ includeChildren && $ result && $ result -> children && count ( $ result -> children ) ) { $ this -> importChildren ( $ result -> children , $ result -> page , $ includeChildren , $ duplicateStrategy ) ; } } } }
|
Execute the importing of several children
|
5,248
|
public function getBase64Tag ( ) { if ( $ this -> owner -> exists ( ) ) { $ url = $ this -> owner -> getBase64Source ( ) ; $ title = ( $ this -> owner -> Title ) ? $ this -> owner -> Title : $ this -> owner -> Filename ; if ( $ this -> owner -> Title ) { $ title = Convert :: raw2att ( $ this -> owner -> Title ) ; } else { if ( preg_match ( "/([^\/]*)\.[a-zA-Z0-9]{1,6}$/" , $ title , $ matches ) ) $ title = Convert :: raw2att ( $ matches [ 1 ] ) ; } return "<img src=\"$url\" alt=\"$title\" />" ; } }
|
Return an XHTML img tag for this Image .
|
5,249
|
public function getBase64Source ( ) { $ Fullpath = $ this -> owner -> getFullPath ( ) ; $ cache = SS_Cache :: factory ( 'Base64Image' ) ; $ cachekey = md5 ( $ Fullpath ) ; if ( ! ( $ Base64Image = $ cache -> load ( $ cachekey ) ) ) { $ Base64Image = base64_encode ( file_get_contents ( $ Fullpath ) ) ; $ cache -> save ( $ Base64Image ) ; } $ type = strtolower ( $ this -> owner -> getExtension ( ) ) ; return "data:image/" . $ type . ";base64," . $ Base64Image ; }
|
retrun the Base64 Notation of the Image
|
5,250
|
public function DetectFace ( ) { $ detector = new svay \ FaceDetector ( ) ; $ detector -> faceDetect ( $ this -> owner -> getFullPath ( ) ) ; return $ detector -> getFace ( ) ; }
|
Detect a Face inside the image
|
5,251
|
public function DetectedFace ( ) { if ( $ this -> owner -> exists ( ) ) { $ cacheFile = $ this -> owner -> cacheDetectedFaceFilename ( ) ; if ( ! file_exists ( Director :: baseFolder ( ) . "/" . $ cacheFile ) || isset ( $ _GET [ 'flush' ] ) ) { $ this -> owner -> generateDetectedFaceImage ( ) ; } if ( $ this -> owner instanceof SecureImage ) $ cached = new SecureImage_Cached ( $ cacheFile ) ; else $ cached = new Image_Cached ( $ cacheFile ) ; $ cached -> Title = $ this -> owner -> Title ; $ cached -> ID = $ this -> owner -> ID ; $ cached -> ParentID = $ this -> owner -> ParentID ; return $ cached ; } }
|
returns the image with the face marked in a red square
|
5,252
|
public function getMergedImage ( $ format , $ padding , $ mergeimage ) { if ( $ this -> owner -> exists ( ) && Director :: fileExists ( $ mergeimage ) ) { $ cacheFile = $ this -> owner -> cacheMergedFilename ( $ format , $ padding , $ mergeimage ) ; if ( ! file_exists ( Director :: baseFolder ( ) . "/" . $ cacheFile ) || isset ( $ _GET [ 'flush' ] ) ) { if ( $ format == 'over' ) $ this -> owner -> generateMergedImage ( $ padding , $ mergeimage , $ this -> owner -> getFullPath ( ) , $ cacheFile ) ; else $ this -> owner -> generateMergedImage ( $ padding , $ this -> owner -> getFullPath ( ) , $ mergeimage , $ cacheFile ) ; } if ( $ this -> owner instanceof SecureImage ) $ cached = new SecureImage_Cached ( $ cacheFile ) ; else $ cached = new Image_Cached ( $ cacheFile ) ; $ cached -> Title = $ this -> owner -> Title ; $ cached -> ID = $ this -> owner -> ID ; $ cached -> ParentID = $ this -> owner -> ParentID ; return $ cached ; } }
|
Return an image object representing the merged image .
|
5,253
|
public function generateMergedImage ( $ padding , $ bgImagePath , $ overlayImagePath , $ cacheFile ) { $ bgImage = Injector :: inst ( ) -> createWithArgs ( Image :: get_backend ( ) , array ( $ bgImagePath ) ) ; $ ovImage = Injector :: inst ( ) -> createWithArgs ( Image :: get_backend ( ) , array ( $ overlayImagePath ) ) ; $ frontImage = $ this -> owner -> generateFit ( $ ovImage , ( $ bgImage -> getWidth ( ) - ( 2 * $ padding ) ) , ( $ bgImage -> getHeight ( ) - ( 2 * $ padding ) ) ) ; $ backend = $ bgImage -> merge ( $ frontImage ) ; if ( $ backend ) { $ backend -> writeTo ( Director :: baseFolder ( ) . "/" . $ cacheFile ) ; } }
|
genereate the merged image
|
5,254
|
public function ToJPEG ( $ quality = null , $ backgroundColor = null ) { if ( ! $ quality ) $ quality = Config :: inst ( ) -> get ( 'ExtendedImage' , 'get_jpeg_default_quality' ) ; if ( ! $ backgroundColor ) $ backgroundColor = Config :: inst ( ) -> get ( 'ExtendedImage' , 'get_jpeg_default_background_color' ) ; return $ this -> owner -> getJPEGImage ( $ quality , $ backgroundColor ) ; }
|
Generate a jpeg image from the source
|
5,255
|
public function checkRequired ( $ required ) { foreach ( $ required as $ fieldRequired ) { if ( ! isset ( $ this -> _parameters [ $ fieldRequired ] ) ) { throw new CommandsException ( "The parameter '$fieldRequired' is required for this script" ) ; } } }
|
Check that a set of parameters has been received .
|
5,256
|
public function showHelp ( $ possibleParameters ) { echo get_class ( $ this ) . ' - Usage:' . PHP_EOL . PHP_EOL ; foreach ( $ possibleParameters as $ parameter => $ description ) { echo html_entity_decode ( $ description , ENT_COMPAT , $ this -> _encoding ) . PHP_EOL ; } }
|
Displays help for the script .
|
5,257
|
public function getOptions ( $ filters = null ) { if ( ! $ filters ) { return $ this -> _parameters ; } $ result = [ ] ; foreach ( $ this -> _parameters as $ param ) { $ result [ ] = $ this -> filter ( $ param , $ filters ) ; } return $ result ; }
|
Returns all received options .
|
5,258
|
public function getOption ( $ option , $ filters = null , $ defaultValue = null ) { if ( is_array ( $ option ) ) { foreach ( $ option as $ optionItem ) { if ( isset ( $ this -> _parameters [ $ optionItem ] ) ) { if ( $ filters !== null ) { return $ this -> filter ( $ this -> _parameters [ $ optionItem ] , $ filters ) ; } return $ this -> _parameters [ $ optionItem ] ; } } return $ defaultValue ; } if ( isset ( $ this -> _parameters [ $ option ] ) ) { if ( $ filters !== null ) { return $ this -> filter ( $ this -> _parameters [ $ option ] , $ filters ) ; } return $ this -> _parameters [ $ option ] ; } return $ defaultValue ; }
|
Returns the value of an option received .
|
5,259
|
public function isReceivedOption ( $ option ) { if ( ! is_array ( $ option ) ) { $ option = [ $ option ] ; } foreach ( $ option as $ op ) { if ( isset ( $ this -> _parameters [ $ op ] ) ) { return true ; } } return false ; }
|
Indicates whether the script was a particular option .
|
5,260
|
public function getLastUnNamedParam ( ) { foreach ( array_reverse ( $ this -> _parameters ) as $ key => $ value ) { if ( is_numeric ( $ key ) ) { return $ value ; } } return false ; }
|
Gets the last parameter is not associated with any parameter name .
|
5,261
|
public function printParameters ( $ parameters ) { $ length = 0 ; foreach ( $ parameters as $ parameter => $ description ) { if ( $ length == 0 ) { $ length = strlen ( $ parameter ) ; } if ( strlen ( $ parameter ) > $ length ) { $ length = strlen ( $ parameter ) ; } } print Color :: head ( 'Options:' ) . PHP_EOL ; foreach ( $ parameters as $ parameter => $ description ) { print Color :: colorize ( ' --' . $ parameter . str_repeat ( ' ' , $ length - strlen ( $ parameter ) ) , Color :: FG_GREEN ) ; print Color :: colorize ( " " . $ description ) . PHP_EOL ; } }
|
Prints the available options in the script
|
5,262
|
protected function findModel ( $ id ) { if ( ( $ model = Order :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
|
Finds the Order model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
|
5,263
|
public function getDom ( $ path ) { $ dom = new \ DOMDocument ( '1.0' , 'utf8' ) ; if ( ( $ content = $ this -> getContent ( $ path ) ) && $ dom -> loadHTML ( $ content ) ) { return $ dom ; } else { return ; } }
|
Get DOMDocument from path .
|
5,264
|
public function getContent ( $ path ) { $ response = $ this -> getBrowser ( ) -> get ( $ path ) -> send ( ) ; if ( $ response -> isError ( ) ) { throw new \ RuntimeException ( 'Failed to query the server ' . $ this -> host ) ; } if ( $ response -> getStatusCode ( ) !== 200 || ! ( $ html = $ response -> getBody ( true ) ) ) { return ; } $ html = iconv ( 'windows-1251' , 'utf-8' , $ html ) ; $ config = [ 'output-xhtml' => true , 'indent' => true , 'indent-spaces' => 0 , 'fix-backslash' => true , 'hide-comments' => true , 'drop-empty-paras' => true , 'wrap' => false , ] ; $ tidy = new \ tidy ( ) ; $ tidy -> parseString ( $ html , $ config , 'utf8' ) ; $ tidy -> cleanRepair ( ) ; $ html = $ tidy -> root ( ) -> value ; $ html = preg_replace ( '/<noembed>.*?<\/noembed>/is' , '' , $ html ) ; $ html = preg_replace ( '/<noindex>.*?<\/noindex>/is' , '' , $ html ) ; return $ html ; }
|
Get content from path .
|
5,265
|
protected function getBrowser ( ) { if ( ! ( $ this -> browser instanceof Client ) ) { $ this -> browser = new Client ( $ this -> host ) ; $ user_agent = self :: DEFAULT_USER_AGENT ; if ( $ this -> request ) { $ user_agent = $ this -> request -> server -> get ( 'HTTP_USER_AGENT' , self :: DEFAULT_USER_AGENT ) ; } $ this -> browser -> setDefaultHeaders ( [ 'User-Agent' => $ user_agent ] ) ; $ this -> browser -> setDefaultOption ( 'timeout' , $ this -> timeout ) ; if ( $ this -> proxy_list ) { $ this -> browser -> setDefaultOption ( 'proxy' , $ this -> proxy_list [ array_rand ( $ this -> proxy_list ) ] ) ; } } return $ this -> browser ; }
|
Get HTTP browser .
|
5,266
|
public function validate ( $ columns = null ) { $ res = $ this -> doValidate ( $ columns ) ; if ( $ res === true ) { $ this -> validationFailures = array ( ) ; return true ; } $ this -> validationFailures = $ res ; return false ; }
|
Validates the objects modified field values and all objects related to this table .
|
5,267
|
public static function mock ( $ mockedClass ) { $ reflection = self :: getMockReflection ( $ mockedClass ) ; return static :: mockClass ( $ reflection , self :: $ namespace , self :: $ classBasePrefix ) ; }
|
Mocking interfaces & classes
|
5,268
|
public static function partialMock ( $ mockedClass ) { $ reflection = self :: getMockReflection ( $ mockedClass ) ; return static :: mockClass ( $ reflection , self :: $ namespace , self :: $ classBasePrefix , MockTypes :: PARTIAL ) ; }
|
Partial Mocking interfaces & classes
|
5,269
|
protected static function _isMethodStubbed ( $ className , $ instanceId , $ methodName ) { if ( ! isset ( self :: $ returnValues [ $ className ] [ $ instanceId ] [ $ methodName ] ) ) { return false ; } return true ; }
|
Checking if a method with specific arguments has been stubbed
|
5,270
|
protected static function _createChainResponse ( $ mockClassInstanceId , $ mockClassType , $ chainedMethodsBefore , $ currentMethod , $ args ) { $ currentMethodName = key ( $ currentMethod ) ; $ rReturnValues = & self :: getMockHierarchyResponse ( $ chainedMethodsBefore , $ mockClassType , $ mockClassInstanceId ) ; $ serializedArgs = serialize ( $ args ) ; if ( ! isset ( $ rReturnValues [ $ currentMethodName ] [ $ serializedArgs ] [ 'response' ] ) ) { $ serializedArgs = static :: checkMatchingArguments ( $ rReturnValues [ $ currentMethodName ] , $ args ) ; if ( is_null ( $ serializedArgs ) ) { return null ; } } return self :: generateResponse ( $ rReturnValues [ $ currentMethodName ] [ $ serializedArgs ] [ 'response' ] , $ args ) ; }
|
Setting up a chained mock response function is called from mocked classes
|
5,271
|
protected static function _setWhenMockResponse ( $ className , $ instanceId , $ methodName , $ args , $ action , $ returns ) { $ args = serialize ( $ args ) ; $ returnValues = array ( ) ; $ returnValues [ $ className ] [ $ instanceId ] [ $ methodName ] [ $ args ] [ 'response' ] = [ 'action' => $ action , 'value' => $ returns ] ; self :: _addChainedResponse ( $ returnValues ) ; }
|
Setting up a mock response function is called from mocked classes
|
5,272
|
protected static function _addChainedResponse ( $ response ) { $ firstChainedMethodName = key ( $ response ) ; if ( isset ( self :: $ returnValues [ $ firstChainedMethodName ] ) ) { self :: $ returnValues [ $ firstChainedMethodName ] = array_replace_recursive ( self :: $ returnValues [ $ firstChainedMethodName ] , $ response [ $ firstChainedMethodName ] ) ; } else { self :: $ returnValues [ $ firstChainedMethodName ] = $ response [ $ firstChainedMethodName ] ; } }
|
Adding chained response to ReturnValues array
|
5,273
|
private static function & getMockHierarchyResponse ( $ chainedMethodsBefore , $ mockClassType , $ mockClassInstanceId ) { $ rReturnValues = & self :: $ returnValues [ $ mockClassType ] [ $ mockClassInstanceId ] ; foreach ( $ chainedMethodsBefore as $ chainedMethod ) { $ chainedMethodName = key ( $ chainedMethod ) ; $ chainedMethodArgs = $ chainedMethod [ $ chainedMethodName ] ; $ serializedChainMethodArgs = serialize ( $ chainedMethodArgs ) ; $ rReturnValues = & $ rReturnValues [ $ chainedMethodName ] [ $ serializedChainMethodArgs ] ; } return $ rReturnValues ; }
|
Returns the mock hierarchy response values
|
5,274
|
public function quantifyYCbCr ( ) { $ inc = $ this -> iteratorIncrement ; $ width = $ this -> width ( ) ; $ height = $ this -> height ( ) ; list ( $ Cb1 , $ Cb2 , $ Cr1 , $ Cr2 ) = $ this -> boundsCbCr ; $ white = $ this -> excludeWhite ; $ black = $ this -> excludeBlack ; $ total = $ count = 0 ; for ( $ x = 0 ; $ x < $ width ; $ x += $ inc ) for ( $ y = 0 ; $ y < $ height ; $ y += $ inc ) { list ( $ r , $ g , $ b ) = $ this -> rgbXY ( $ x , $ y ) ; if ( ( ( $ r > $ white ) && ( $ g > $ white ) && ( $ b > $ white ) ) || ( ( $ r < $ black ) && ( $ g < $ black ) && ( $ b < $ black ) ) ) continue ; $ Cb = 128 + ( - 0.1482 * $ r ) + ( - 0.291 * $ g ) + ( 0.4392 * $ b ) ; $ Cr = 128 + ( 0.4392 * $ r ) + ( - 0.3678 * $ g ) + ( - 0.0714 * $ b ) ; if ( ( $ Cb >= $ Cb1 ) && ( $ Cb <= $ Cb2 ) && ( $ Cr >= $ Cr1 ) && ( $ Cr <= $ Cr2 ) ) $ count ++ ; $ total ++ ; } return $ count / $ total ; }
|
Quantify flesh color amount using YCbCr color model
|
5,275
|
public function isPorn ( $ threshold = FALSE ) { return $ threshold === FALSE ? $ this -> quantifyYCbCr ( ) >= $ this -> threshold : $ this -> quantifyYCbCr ( ) >= $ threshold ; }
|
Check if image is of pornographic content
|
5,276
|
function Link ( $ action = null ) { $ cur = Controller :: curr ( ) ; if ( $ cur instanceof ExternalContentPage_Controller ) { return $ cur -> data ( ) -> LinkFor ( $ this , 'view' ) ; } return ExternalContentPage_Controller :: URL_STUB . '/view/' . $ this -> ID ; }
|
Return a URL that simply links back to the externalcontentadmin class view action
|
5,277
|
public function DownloadLink ( ) { $ cur = Controller :: curr ( ) ; if ( $ cur instanceof ExternalContentPage_Controller ) { return $ cur -> data ( ) -> LinkFor ( $ this , 'download' ) ; } return ExternalContentPage_Controller :: URL_STUB . '/download/' . $ this -> ID ; }
|
Where this can be downloaded from
|
5,278
|
public function stageChildren ( $ showAll = false ) { if ( $ this -> Title != 'Content Root' && $ this -> source ) { $ children = new ArrayList ( ) ; $ item = new ExternalContentItem ( $ this -> source , $ this -> Title . '1' ) ; $ item -> Title = $ this -> Title . '1' ; $ item -> MenuTitle = $ item -> Title ; $ children -> push ( $ item ) ; return $ children ; } }
|
Overridden to load all children from a remote content source instead of this node directly
|
5,279
|
public function Children ( ) { if ( ! $ this -> children ) { $ this -> children = new ArrayList ( ) ; $ kids = $ this -> stageChildren ( ) ; if ( $ kids ) { foreach ( $ kids as $ child ) { if ( $ child -> canView ( ) ) { $ this -> children -> push ( $ child ) ; } } } } return $ this -> children ; }
|
Handle a children call by retrieving from stageChildren
|
5,280
|
public function getCMSFields ( ) { $ fields = parent :: getCMSFields ( ) ; $ fields -> removeByName ( 'ParentID' ) ; if ( count ( $ this -> remoteProperties ) ) { $ mapping = $ this -> editableFieldMapping ( ) ; foreach ( $ this -> remoteProperties as $ name => $ value ) { $ field = null ; if ( isset ( $ mapping [ $ name ] ) ) { $ field = $ mapping [ $ name ] ; if ( is_string ( $ field ) ) { $ field = new $ field ( $ name , $ this -> fieldLabel ( $ name ) , $ value ) ; $ fields -> addFieldToTab ( 'Root.Main' , $ field ) ; } } else if ( ! is_object ( $ value ) && ! is_array ( $ value ) ) { $ value = ( string ) $ value ; $ field = new ReadonlyField ( $ name , _t ( 'ExternalContentItem.' . $ name , $ name ) , $ value ) ; $ fields -> addFieldToTab ( 'Root.Main' , $ field ) ; } else if ( is_object ( $ value ) || is_array ( $ value ) ) { foreach ( $ value as $ childName => $ childValue ) { if ( is_object ( $ childValue ) ) { foreach ( $ childValue as $ childChildName => $ childChildValue ) { $ childChildValue = is_object ( $ childChildValue ) || is_array ( $ childChildValue ) ? json_encode ( $ childChildValue ) : ( string ) $ childChildValue ; $ field = new ReadonlyField ( "{$childName}{$childChildName}" , "{$childName}: {$childChildName}" , $ childChildValue ) ; $ fields -> addFieldToTab ( 'Root.Main' , $ field ) ; } } else { $ childValue = is_object ( $ childValue ) || is_array ( $ childValue ) ? json_encode ( $ childValue ) : ( string ) $ childValue ; $ field = new ReadonlyField ( "{$childName}{$childValue}" , $ name . ':' . $ childName , $ childValue ) ; $ fields -> addFieldToTab ( 'Root.Main' , $ field ) ; } } } } } return $ fields ; }
|
For now just show a field that says this can t be edited
|
5,281
|
public static function fromArray ( array $ data ) { if ( ! array_key_exists ( 'client_id' , $ data ) ) throw new ClientConfigurationException ( 'Configuration file has no client_id set' ) ; if ( ! array_key_exists ( 'client_secret' , $ data ) ) throw new ClientConfigurationException ( 'Configuration file has no client_secret set' ) ; if ( ! array_key_exists ( 'site_token' , $ data ) ) throw new ClientConfigurationException ( 'Configuration file has no site_token set' ) ; $ baseUrl = ( ! array_key_exists ( 'api' , $ data ) ) ? null : $ data [ 'api' ] ; $ httpClientConfig = ( ! array_key_exists ( 'http_client' , $ data ) ) ? array ( ) : $ data [ 'http_client' ] ; $ clientConfig = new ClientConfig ( $ data [ 'client_id' ] , $ data [ 'client_secret' ] , $ data [ 'site_token' ] , $ baseUrl , $ httpClientConfig ) ; if ( array_key_exists ( 'cache_file' , $ data ) ) $ clientConfig -> setAccessTokenCacheFile ( $ data [ 'cache_file' ] ) ; return $ clientConfig ; }
|
creates a configuration from array
|
5,282
|
public static function fromFile ( $ filename ) { $ filename = realpath ( $ filename ) ; if ( $ filename === false ) throw new ClientConfigurationException ( 'Configuration file ' . $ filename . ' does not exists' ) ; return static :: fromArray ( include $ filename ) ; }
|
creates a configuration from a php file returning an array
|
5,283
|
public function getDefaultSchema ( ) : ? Builder { $ manager = DB :: getFacadeRoot ( ) ; if ( isset ( $ manager ) && ! is_null ( $ manager -> connection ( ) ) ) { return Schema :: getFacadeRoot ( ) ; } return $ manager ; }
|
Get a default schema value if any is available
|
5,284
|
public function addGetParam ( $ param , $ value = true ) { if ( ! is_scalar ( $ param ) ) { throw new \ Exception ( "Param name must be scalar" ) ; } if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; } $ this -> queryParams [ trim ( $ param ) ] = $ value ; return $ this ; }
|
Add a GET parameter
|
5,285
|
public function addPostParam ( $ param , $ value = true ) { if ( ! is_scalar ( $ param ) ) { throw new \ Exception ( "Param name must be scalar" ) ; } if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; } $ this -> postParams [ trim ( $ param ) ] = $ value ; return $ this ; }
|
Add a POST parameter
|
5,286
|
public function setSearchTerm ( $ searchTerm ) { if ( ! is_scalar ( $ searchTerm ) ) { throw new \ Exception ( "Search term must be a string" ) ; } $ this -> searchTerm = trim ( $ searchTerm ) ; return $ this ; }
|
Set a search term for the request
|
5,287
|
public function getGetParams ( ) { if ( isset ( $ this -> searchTerm ) ) { $ this -> queryParams [ 'q' ] = $ this -> searchTerm ; } return $ this -> queryParams ; }
|
Get the request GET params
|
5,288
|
public function toArray ( ) { $ params = [ ] ; if ( isset ( $ this -> searchTerm ) ) { $ params [ 'q' ] = $ this -> searchTerm ; } if ( isset ( $ this -> parameters ) ) { foreach ( $ this -> parameters as $ paramKey => $ paramVal ) { $ params [ $ paramKey ] = $ paramVal ; } } return $ params ; }
|
This should no longer be needed todo remove
|
5,289
|
public function bySystemReferenceTypeBySystemReferenceIdAndByOrganization ( $ systemReferenceType , $ systemReferenceId , $ organizationId , $ databaseConnectionName = null ) { if ( empty ( $ databaseConnectionName ) ) { $ databaseConnectionName = $ this -> databaseConnectionName ; } return $ this -> File -> setConnection ( $ databaseConnectionName ) -> where ( 'system_reference_type' , '=' , $ systemReferenceType ) -> where ( 'system_reference_id' , '=' , $ systemReferenceId ) -> where ( 'organization_id' , '=' , $ organizationId ) -> get ( ) ; }
|
Retrieve files by system reference type and system reference id
|
5,290
|
protected function widgetSelector ( \ Psc \ HTML \ Tag $ tag = NULL , $ subSelector = NULL ) { $ jQuery = \ Psc \ JS \ jQuery :: getClassSelector ( $ tag ? : $ this -> html ) ; if ( isset ( $ subSelector ) ) { $ jQuery .= sprintf ( ".find(%s)" , \ Psc \ JS \ Helper :: convertString ( $ subSelector ) ) ; } return $ this -> jsExpr ( $ jQuery ) ; }
|
denn das hier hat nix mit joose zu tun
|
5,291
|
public static function getEventLabels ( ) { return array ( self :: ENTRYSUBMIT , self :: KEYPRESS , self :: MOUSECLICK , self :: MOUSEOUT , self :: MOUSEOVER ) ; }
|
Get the possible event label names
|
5,292
|
public function getDbManager ( ) : ? DatabaseManager { if ( ! $ this -> hasDbManager ( ) ) { $ this -> setDbManager ( $ this -> getDefaultDbManager ( ) ) ; } return $ this -> dbManager ; }
|
Get db manager
|
5,293
|
public function initApiLogs ( $ overrideExisting = true ) { if ( null !== $ this -> collApiLogs && ! $ overrideExisting ) { return ; } $ this -> collApiLogs = new PropelObjectCollection ( ) ; $ this -> collApiLogs -> setModel ( 'ApiLog' ) ; }
|
Initializes the collApiLogs collection .
|
5,294
|
public function getApiLogs ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collApiLogsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collApiLogs || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collApiLogs ) { $ this -> initApiLogs ( ) ; } else { $ collApiLogs = ApiLogQuery :: create ( null , $ criteria ) -> filterByRemoteApp ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collApiLogsPartial && count ( $ collApiLogs ) ) { $ this -> initApiLogs ( false ) ; foreach ( $ collApiLogs as $ obj ) { if ( false == $ this -> collApiLogs -> contains ( $ obj ) ) { $ this -> collApiLogs -> append ( $ obj ) ; } } $ this -> collApiLogsPartial = true ; } $ collApiLogs -> getInternalIterator ( ) -> rewind ( ) ; return $ collApiLogs ; } if ( $ partial && $ this -> collApiLogs ) { foreach ( $ this -> collApiLogs as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collApiLogs [ ] = $ obj ; } } } $ this -> collApiLogs = $ collApiLogs ; $ this -> collApiLogsPartial = false ; } } return $ this -> collApiLogs ; }
|
Gets an array of ApiLog objects which contain a foreign key that references this object .
|
5,295
|
public function countApiLogs ( Criteria $ criteria = null , $ distinct = false , PropelPDO $ con = null ) { $ partial = $ this -> collApiLogsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collApiLogs || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collApiLogs ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getApiLogs ( ) ) ; } $ query = ApiLogQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByRemoteApp ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collApiLogs ) ; }
|
Returns the number of related ApiLog objects .
|
5,296
|
public function addApiLog ( ApiLog $ l ) { if ( $ this -> collApiLogs === null ) { $ this -> initApiLogs ( ) ; $ this -> collApiLogsPartial = true ; } if ( ! in_array ( $ l , $ this -> collApiLogs -> getArrayCopy ( ) , true ) ) { $ this -> doAddApiLog ( $ l ) ; if ( $ this -> apiLogsScheduledForDeletion and $ this -> apiLogsScheduledForDeletion -> contains ( $ l ) ) { $ this -> apiLogsScheduledForDeletion -> remove ( $ this -> apiLogsScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; }
|
Method called to associate a ApiLog object to this object through the ApiLog foreign key attribute .
|
5,297
|
public function initRemoteHistoryContaos ( $ overrideExisting = true ) { if ( null !== $ this -> collRemoteHistoryContaos && ! $ overrideExisting ) { return ; } $ this -> collRemoteHistoryContaos = new PropelObjectCollection ( ) ; $ this -> collRemoteHistoryContaos -> setModel ( 'RemoteHistoryContao' ) ; }
|
Initializes the collRemoteHistoryContaos collection .
|
5,298
|
public function getRemoteHistoryContaos ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collRemoteHistoryContaosPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRemoteHistoryContaos || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRemoteHistoryContaos ) { $ this -> initRemoteHistoryContaos ( ) ; } else { $ collRemoteHistoryContaos = RemoteHistoryContaoQuery :: create ( null , $ criteria ) -> filterByRemoteApp ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collRemoteHistoryContaosPartial && count ( $ collRemoteHistoryContaos ) ) { $ this -> initRemoteHistoryContaos ( false ) ; foreach ( $ collRemoteHistoryContaos as $ obj ) { if ( false == $ this -> collRemoteHistoryContaos -> contains ( $ obj ) ) { $ this -> collRemoteHistoryContaos -> append ( $ obj ) ; } } $ this -> collRemoteHistoryContaosPartial = true ; } $ collRemoteHistoryContaos -> getInternalIterator ( ) -> rewind ( ) ; return $ collRemoteHistoryContaos ; } if ( $ partial && $ this -> collRemoteHistoryContaos ) { foreach ( $ this -> collRemoteHistoryContaos as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collRemoteHistoryContaos [ ] = $ obj ; } } } $ this -> collRemoteHistoryContaos = $ collRemoteHistoryContaos ; $ this -> collRemoteHistoryContaosPartial = false ; } } return $ this -> collRemoteHistoryContaos ; }
|
Gets an array of RemoteHistoryContao objects which contain a foreign key that references this object .
|
5,299
|
public function countRemoteHistoryContaos ( Criteria $ criteria = null , $ distinct = false , PropelPDO $ con = null ) { $ partial = $ this -> collRemoteHistoryContaosPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRemoteHistoryContaos || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRemoteHistoryContaos ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getRemoteHistoryContaos ( ) ) ; } $ query = RemoteHistoryContaoQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByRemoteApp ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collRemoteHistoryContaos ) ; }
|
Returns the number of related RemoteHistoryContao objects .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.