idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
59,200
public function compare ( DocumentationEntity $ other ) { $ v1 = $ this -> getVersion ( ) ; $ v2 = $ other -> getVersion ( ) ; $ dots = substr_count ( $ v1 , '.' ) - substr_count ( $ v2 , '.' ) ; while ( $ dots > 0 ) { $ dots -- ; $ v2 .= '.99999' ; } while ( $ dots < 0 ) { $ dots ++ ; $ v1 .= '.99999' ; } return versi...
Returns an integer value based on if a given version is the latest version . Will return - 1 for if the version is older 0 if versions are the same and 1 if the version is greater than .
59,201
protected function _initWeight ( Zend_Search_Lucene_Interface $ reader ) { if ( $ this -> _weight !== null ) { return $ this -> _weight ; } $ this -> createWeight ( $ reader ) ; $ sum = $ this -> _weight -> sumOfSquaredWeights ( ) ; $ queryNorm = $ reader -> getSimilarity ( ) -> queryNorm ( $ sum ) ; $ this -> _weight ...
Constructs an initializes a Weight for a _top - level_query_ .
59,202
protected function getUserImage ( array $ response , AccessToken $ token ) { $ guid = $ token -> getResourceOwnerId ( ) ; $ url = 'https://social.yahooapis.com/v1/user/' . $ guid . '/profile/image/' . $ this -> imageSize . '?format=json' ; $ request = $ this -> getAuthenticatedRequest ( 'get' , $ url , $ token ) ; $ re...
Get user image from provider
59,203
protected function getUserImageUrl ( array $ response , AccessToken $ token ) { $ image = $ this -> getUserImage ( $ response , $ token ) ; if ( isset ( $ image [ 'image' ] [ 'imageUrl' ] ) ) { return $ image [ 'image' ] [ 'imageUrl' ] ; } return null ; }
Get user image url from provider if available
59,204
public function withSpecialMark ( $ mark , string $ name = 'default' ) : self { $ this -> special_marks [ $ name ] = $ mark ; return $ this ; }
Mark this object
59,205
protected function makeResult ( $ response , $ method ) { if ( $ method != 'HEAD' && isset ( $ response -> headers -> { 'content-length' } ) && strlen ( $ response -> body ) != $ response -> headers -> { 'content-length' } ) { throw new SagException ( 'Unexpected end of packet.' ) ; } if ( $ method == 'HEAD' ) { if ( $...
Used by the concrete HTTP adapters this abstracts out the generic task of turning strings from the net into response objects .
59,206
public function setRWTimeout ( $ seconds , $ microseconds ) { if ( ! is_int ( $ microseconds ) || $ microseconds < 0 ) { throw new SagException ( 'setRWTimeout() expects $microseconds to be an integer >= 0.' ) ; } if ( ! is_int ( $ seconds ) || ( ( ! $ microseconds && $ seconds < 1 ) || ( $ microseconds && $ seconds < ...
Set how long we should wait for an HTTP request to be executed .
59,207
public function setTimeoutsFromArray ( $ arr ) { if ( ! is_array ( $ arr ) ) { throw SagException ( 'Expected an array and got something else.' ) ; } if ( is_int ( $ arr [ 'open' ] ) ) { $ this -> setOpenTimeout ( $ arr [ 'open' ] ) ; } if ( is_int ( $ arr [ 'rwSeconds' ] ) ) { if ( is_int ( $ arr [ 'rwMicroseconds' ] ...
A utility function that sets the different timeout values based on an associative array .
59,208
private function makeFollowAdapter ( $ parts ) { if ( empty ( $ parts [ 'host' ] ) || ( $ parts [ 'host' ] == $ this -> host && $ parts [ 'port' ] == $ this -> port && $ parts [ 'scheme' ] == $ this -> proto ) ) { return $ this ; } if ( empty ( $ parts [ 'port' ] ) ) { $ parts [ 'port' ] = ( $ parts [ 'scheme' ] == 'ht...
Used when we need to create a new adapter to follow a redirect because cURL can t .
59,209
public function multiple ( ) : self { $ unique_array = array_unique ( $ this -> getArrayCopy ( ) ) ; return new ArrayMap ( array_diff_assoc ( $ this -> getArrayCopy ( ) , $ unique_array ) ) ; }
Get duplicate values in an array
59,210
public function put ( $ element ) { $ nodeId = count ( $ this -> _heap ) ; $ parentId = ( $ nodeId - 1 ) >> 1 ; while ( $ nodeId != 0 && $ this -> _less ( $ element , $ this -> _heap [ $ parentId ] ) ) { $ this -> _heap [ $ nodeId ] = $ this -> _heap [ $ parentId ] ; $ nodeId = $ parentId ; $ parentId = ( $ nodeId - 1 ...
Add element to the queue
59,211
public function pop ( ) { if ( count ( $ this -> _heap ) == 0 ) { return null ; } $ top = $ this -> _heap [ 0 ] ; $ lastId = count ( $ this -> _heap ) - 1 ; $ nodeId = 0 ; $ childId = 1 ; if ( $ lastId > 2 && $ this -> _less ( $ this -> _heap [ 2 ] , $ this -> _heap [ 1 ] ) ) { $ childId = 2 ; } while ( $ childId < $ l...
Removes and return least element of the queue
59,212
public function VersionWarning ( ) { $ page = $ this -> owner -> getPage ( ) ; if ( ! $ page ) { return false ; } $ entity = $ page -> getEntity ( ) ; if ( ! $ entity ) { return false ; } $ versions = $ this -> owner -> getManifest ( ) -> getAllVersionsOfEntity ( $ entity ) ; if ( $ entity -> getIsStable ( ) ) { return...
Check to see if the currently accessed version is out of date or perhaps a future version rather than the stable edition .
59,213
public function nextTerm ( ) { while ( ( $ termStream = $ this -> _termsStreamQueue -> pop ( ) ) !== null ) { if ( $ this -> _termsStreamQueue -> top ( ) === null || $ this -> _termsStreamQueue -> top ( ) -> currentTerm ( ) -> key ( ) != $ termStream -> currentTerm ( ) -> key ( ) ) { $ this -> _lastTerm = $ termStream ...
Scans term streams and returns next term
59,214
public function addField ( Zend_Search_Lucene_Field $ field ) { if ( ! isset ( $ this -> _fields [ $ field -> name ] ) ) { $ fieldNumber = count ( $ this -> _fields ) ; $ this -> _fields [ $ field -> name ] = new Zend_Search_Lucene_Index_FieldInfo ( $ field -> name , $ field -> isIndexed , $ fieldNumber , $ field -> st...
Add field to the segment
59,215
public function addFieldInfo ( Zend_Search_Lucene_Index_FieldInfo $ fieldInfo ) { if ( ! isset ( $ this -> _fields [ $ fieldInfo -> name ] ) ) { $ fieldNumber = count ( $ this -> _fields ) ; $ this -> _fields [ $ fieldInfo -> name ] = new Zend_Search_Lucene_Index_FieldInfo ( $ fieldInfo -> name , $ fieldInfo -> isIndex...
Add fieldInfo to the segment
59,216
public function addStoredFields ( $ storedFields ) { if ( ! isset ( $ this -> _fdxFile ) ) { $ this -> _fdxFile = $ this -> _directory -> createFile ( $ this -> _name . '.fdx' ) ; $ this -> _fdtFile = $ this -> _directory -> createFile ( $ this -> _name . '.fdt' ) ; $ this -> _files [ ] = $ this -> _name . '.fdx' ; $ t...
Add stored fields information
59,217
public function initializeDictionaryFiles ( ) { $ this -> _tisFile = $ this -> _directory -> createFile ( $ this -> _name . '.tis' ) ; $ this -> _tisFile -> writeInt ( ( int ) 0xFFFFFFFD ) ; $ this -> _tisFile -> writeLong ( 0 ) ; $ this -> _tisFile -> writeInt ( self :: $ indexInterval ) ; $ this -> _tisFile -> writeI...
Create dicrionary frequency and positions files and write necessary headers
59,218
protected function _dumpTermDictEntry ( Zend_Search_Lucene_Storage_File $ dicFile , & $ prevTerm , Zend_Search_Lucene_Index_Term $ term , & $ prevTermInfo , Zend_Search_Lucene_Index_TermInfo $ termInfo ) { if ( isset ( $ prevTerm ) && $ prevTerm -> field == $ term -> field ) { $ matchedBytes = 0 ; $ maxBytes = min ( st...
Dump Term Dictionary segment file entry . Used to write entry to . tis or . tii files
59,219
protected function _generateCFS ( ) { $ cfsFile = $ this -> _directory -> createFile ( $ this -> _name . '.cfs' ) ; $ cfsFile -> writeVInt ( count ( $ this -> _files ) ) ; $ dataOffsetPointers = array ( ) ; foreach ( $ this -> _files as $ fileName ) { $ dataOffsetPointers [ $ fileName ] = $ cfsFile -> tell ( ) ; $ cfsF...
Generate compound index file
59,220
public function getDocument ( ) { if ( ! $ this -> _document instanceof Zend_Search_Lucene_Document ) { $ this -> _document = $ this -> _index -> getDocument ( $ this -> id ) ; } return $ this -> _document ; }
Return the document object for this hit
59,221
protected function withBulk ( array $ data = [ ] ) { if ( ! $ this -> isArray ( $ data ) ) { return ; } foreach ( $ data [ 'data' ] as $ index => $ element ) { $ row = $ this -> data -> addChild ( 'row' ) ; $ row -> addAttribute ( 'no' , ++ $ index ) ; foreach ( $ element as $ key => $ value ) { $ child = $ row -> addC...
One or more elements in data array .
59,222
protected function withoutBulk ( array $ data = [ ] ) { if ( $ this -> isArray ( $ data ) ) { return ; } $ row = $ this -> data -> addChild ( 'row' ) ; $ row -> addAttribute ( 'no' , 1 ) ; foreach ( $ data [ 'data' ] as $ key => $ value ) { $ child = $ row -> addChild ( 'FL' , $ value ) ; $ child -> addAttribute ( 'val...
Only one element in data array . For BC .
59,223
public function setHTTPAdapter ( $ type = null ) { if ( ! $ type ) { $ type = extension_loaded ( "curl" ) ? self :: $ HTTP_CURL : self :: $ HTTP_NATIVE_SOCKETS ; } if ( $ type === $ this -> httpAdapterType ) { return true ; } $ prevDecode = null ; $ prevTimeouts = null ; if ( $ this -> httpAdapter ) { $ prevDecode = $ ...
Set which HTTP library you want to use for communicating with CouchDB .
59,224
public function get ( $ url ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( strpos ( $ url , '/' ) !== 0 ) { $ url = "/$url" ; } $ url = "/{$this->db}$url" ; if ( $ this -> staleDefault ) { $ url = self :: setURLParameter ( $ url , 'stale' , 'ok' ) ; } $ response = null ; if ( $ ...
Performs an HTTP GET operation for the supplied URL . The database name you provided is automatically prepended to the URL so you only need to give the portion of the URL that comes after the database name .
59,225
public function head ( $ url ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( strpos ( $ url , '/' ) !== 0 ) { $ url = "/$url" ; } if ( $ this -> staleDefault ) { $ url = self :: setURLParameter ( $ url , 'stale' , 'ok' ) ; } return $ this -> procPacket ( 'HEAD' , "/{$this->db}$ur...
Performs an HTTP HEAD operation for the supplied document . This operation does not try to read from a provided cache and does not cache its results .
59,226
public function delete ( $ id , $ rev ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( ! is_string ( $ id ) || ! is_string ( $ rev ) || empty ( $ id ) || empty ( $ rev ) ) { throw new SagException ( 'delete() expects two strings.' ) ; } $ url = "/{$this->db}/$id" ; if ( $ this -> ...
DELETE s the specified document .
59,227
public function put ( $ id , $ data ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( ! is_string ( $ id ) ) { throw new SagException ( 'put() expected a string for the doc id.' ) ; } if ( ! isset ( $ data ) || ( ! is_object ( $ data ) && ! is_string ( $ data ) && ! is_array ( $ da...
PUT s the data to the document .
59,228
public function post ( $ data , $ path = null ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( ! isset ( $ data ) || ( ! is_string ( $ data ) && ! is_object ( $ data ) && ! is_array ( $ data ) ) ) { throw new SagException ( 'post() needs an object for data.' ) ; } if ( ! is_string...
POST s the provided document . When using a SagCache the created document and response are not cached .
59,229
public function bulk ( $ docs , $ allOrNothing = false ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( ! is_array ( $ docs ) ) { throw new SagException ( 'bulk() expects an array for its first argument' ) ; } if ( ! is_bool ( $ allOrNothing ) ) { throw new SagException ( 'bulk() ...
Bulk pushes documents to the database .
59,230
public function copy ( $ srcID , $ dstID , $ dstRev = null ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified' ) ; } if ( empty ( $ srcID ) || ! is_string ( $ srcID ) ) { throw new SagException ( 'copy() got an invalid source ID' ) ; } if ( empty ( $ dstID ) || ! is_string ( $ dstID ) ) { throw...
COPY s the document .
59,231
public function getAllDocs ( $ incDocs = false , $ limit = null , $ startKey = null , $ endKey = null , $ keys = null , $ descending = false , $ skip = 0 ) { if ( ! $ this -> db ) { throw new SagException ( 'No database specified.' ) ; } $ qry = array ( ) ; if ( $ incDocs !== false ) { if ( ! is_bool ( $ incDocs ) ) { ...
Gets all the documents in the database with _all_docs . Its results will not be cached by SagCache .
59,232
public function replicate ( $ src , $ target , $ continuous = false , $ createTarget = null , $ filter = null , $ filterQueryParams = null ) { if ( empty ( $ src ) || ! is_string ( $ src ) ) { throw new SagException ( 'replicate() is missing a source to replicate from.' ) ; } if ( empty ( $ target ) || ! is_string ( $ ...
Starts a replication job between two databases independently of which database you set with Sag .
59,233
private function procPacket ( $ method , $ url , $ data = null , $ headers = array ( ) ) { if ( $ data && ! is_string ( $ data ) ) { throw new SagException ( 'Unexpected data format. Please report this bug.' ) ; } if ( $ this -> pathPrefix && is_string ( $ this -> pathPrefix ) ) { $ url = $ this -> pathPrefix . $ url ;...
The main driver - does all the socket and protocol work .
59,234
protected function extractMetaData ( ZipArchive $ package ) { $ coreProperties = array ( ) ; $ relations = simplexml_load_string ( $ package -> getFromName ( "_rels/.rels" ) ) ; foreach ( $ relations -> Relationship as $ rel ) { if ( $ rel [ "Type" ] == Zend_Search_Lucene_Document_OpenXml :: SCHEMA_COREPROPERTIES ) { $...
Extract metadata from document
59,235
protected function encodeMessage ( $ msg ) { $ encodings = array ( 9 => '&#009;' , 10 => '&#010;' , 13 => '&#013;' , 32 => '&#032;' , 34 => '&quot;' , 39 => '&apos;' , ) ; $ ret = array ( ) ; for ( $ j = 0 ; $ j < strlen ( $ msg ) ; $ j ++ ) { $ str = $ msg [ $ j ] ; $ asci = ord ( $ str ) ; if ( isset ( $ encodings [ ...
Encodes the message according to doc
59,236
protected function buildGetCreditPayload ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="ISO-8859-1"?>' . '<!DOCTYPE REQUESTCREDIT SYSTEM "http://127.0.0.1:80/psms/dtd/requestcredit.dtd">' . '<REQUESTCREDIT></REQUESTCREDIT>' ) ; $ xml -> addAttribute ( 'USERNAME' , $ this -> username ) ; $ xml -> ...
Constructs valid XML for sending SMS - CR credit request service
59,237
protected function buildGetStatusPayload ( $ messageId ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="ISO-8859-1"?>' . '<!DOCTYPE STATUSREQUEST SYSTEM "http://127.0.0.1:80/psms/dtd/requeststatusv12.dtd">' . '<STATUSREQUEST VER="1.2"></STATUSREQUEST>' ) ; $ user = $ xml -> addChild ( 'USER' ) ; $ us...
Constructs valid XML for sending SMS - SR request service
59,238
protected function buildSendSmsPayload ( array $ data = array ( ) ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="ISO-8859-1"?>' . '<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1:80/psms/dtd/messagev12.dtd">' . '<MESSAGE VER="1.2"></MESSAGE>' ) ; $ user = $ xml -> addChild ( 'USER' ) ; foreach ( array (...
Constructs valid XML for sending SMS - MT message
59,239
public static function binary ( $ name , $ value ) { return new self ( $ name , $ value , '' , true , false , false , true ) ; }
Constructs a Binary String valued Field that is not tokenized nor indexed but is stored in the index for return with hits .
59,240
public static function text ( $ name , $ value , $ encoding = '' ) { return new self ( $ name , $ value , $ encoding , true , true , true ) ; }
Constructs a String - valued Field that is tokenized and indexed and is stored in the index for return with hits . Useful for short text fields like title or subject . Term vector will not be stored for this field .
59,241
public static function unStored ( $ name , $ value , $ encoding = '' ) { return new self ( $ name , $ value , $ encoding , false , true , true ) ; }
Constructs a String - valued Field that is tokenized and indexed but that is not stored in the index .
59,242
public function getUtf8Value ( ) { if ( strcasecmp ( $ this -> encoding , 'utf8' ) == 0 || strcasecmp ( $ this -> encoding , 'utf-8' ) == 0 ) { return $ this -> value ; } else { return ( PHP_OS != 'AIX' ) ? iconv ( $ this -> encoding , 'UTF-8' , $ this -> value ) : iconv ( 'ISO8859-1' , 'UTF-8' , $ this -> value ) ; } ...
Get field value in UTF - 8 encoding
59,243
private static function _floatToByte ( $ f ) { if ( $ f <= 0.0 ) { return 0 ; } $ lowIndex = 0 ; $ highIndex = 255 ; while ( $ highIndex >= $ lowIndex ) { $ mid = ( $ highIndex + $ lowIndex ) >> 1 ; $ delta = $ f - self :: $ _normTable [ $ mid ] ; if ( $ delta < 0 ) { $ highIndex = $ mid - 1 ; } elseif ( $ delta > 0 ) ...
Float to byte conversion
59,244
public function idf ( $ input , Zend_Search_Lucene_Interface $ reader ) { if ( ! is_array ( $ input ) ) { return $ this -> idfFreq ( $ reader -> docFreq ( $ input ) , $ reader -> count ( ) ) ; } else { $ idf = 0.0 ; foreach ( $ input as $ term ) { $ idf += $ this -> idfFreq ( $ reader -> docFreq ( $ term ) , $ reader -...
Computes a score factor for a simple term or a phrase .
59,245
private function _parseRichText ( $ is = null ) { $ value = array ( ) ; if ( isset ( $ is -> t ) ) { $ value [ ] = ( string ) $ is -> t ; } else { foreach ( $ is -> r as $ run ) { $ value [ ] = ( string ) $ run -> t ; } } return implode ( '' , $ value ) ; }
Parse rich text XML
59,246
private function _loadDelFile ( ) { if ( $ this -> _delGen == - 1 ) { return null ; } else if ( $ this -> _delGen == 0 ) { return $ this -> _loadPre21DelFile ( ) ; } else { return $ this -> _load21DelFile ( ) ; } }
Load detetions file
59,247
private function _loadPre21DelFile ( ) { require_once 'Zend/Search/Lucene/Exception.php' ; try { $ delFile = $ this -> _directory -> getFileObject ( $ this -> _name . '.del' ) ; $ byteCount = $ delFile -> readInt ( ) ; $ byteCount = ceil ( $ byteCount / 8 ) ; $ bitCount = $ delFile -> readInt ( ) ; if ( $ bitCount == 0...
Load pre - 2 . 1 detetions file
59,248
private function _load21DelFile ( ) { $ delFile = $ this -> _directory -> getFileObject ( $ this -> _name . '_' . base_convert ( $ this -> _delGen , 10 , 36 ) . '.del' ) ; $ format = $ delFile -> readInt ( ) ; if ( $ format == ( int ) 0xFFFFFFFF ) { if ( extension_loaded ( 'bitset' ) ) { $ deletions = bitset_empty ( ) ...
Load 2 . 1 + format detetions file
59,249
public function openCompoundFile ( $ extension , $ shareHandler = true ) { if ( ( $ extension == '.fdx' || $ extension == '.fdt' ) && $ this -> _usesSharedDocStore ) { $ fdxFName = $ this -> _sharedDocStoreOptions [ 'segment' ] . '.fdx' ; $ fdtFName = $ this -> _sharedDocStoreOptions [ 'segment' ] . '.fdt' ; if ( ! $ t...
Opens index file stoted within compound index file
59,250
public function compoundFileLength ( $ extension ) { if ( ( $ extension == '.fdx' || $ extension == '.fdt' ) && $ this -> _usesSharedDocStore ) { $ filename = $ this -> _sharedDocStoreOptions [ 'segment' ] . $ extension ; if ( ! $ this -> _sharedDocStoreOptions [ 'isCompound' ] ) { return $ this -> _directory -> fileLe...
Get compound file length
59,251
public function getFieldNum ( $ fieldName ) { foreach ( $ this -> _fields as $ field ) { if ( $ field -> name == $ fieldName ) { return $ field -> number ; } } return - 1 ; }
Returns field index or - 1 if field is not found
59,252
private function _deletedCount ( ) { if ( $ this -> _deleted === null ) { return 0 ; } if ( extension_loaded ( 'bitset' ) ) { return count ( bitset_to_array ( $ this -> _deleted ) ) ; } else { return count ( $ this -> _deleted ) ; } }
Returns number of deleted documents .
59,253
private function _getFieldPosition ( $ fieldNum ) { return isset ( $ this -> _fieldsDicPositions [ $ fieldNum ] ) ? $ this -> _fieldsDicPositions [ $ fieldNum ] : $ fieldNum ; }
Get field position in a fields dictionary
59,254
private function _loadDictionaryIndex ( ) { if ( $ this -> _directory -> fileExists ( $ this -> _name . '.sti' ) ) { $ stiFile = $ this -> _directory -> getFileObject ( $ this -> _name . '.sti' ) ; $ stiFileData = $ stiFile -> readBytes ( $ this -> _directory -> fileLength ( $ this -> _name . '.sti' ) ) ; if ( ( $ unse...
Load terms dictionary index
59,255
private function _loadNorm ( $ fieldNum ) { if ( $ this -> _hasSingleNormFile ) { $ normfFile = $ this -> openCompoundFile ( '.nrm' ) ; $ header = $ normfFile -> readBytes ( 3 ) ; $ headerFormatVersion = $ normfFile -> readByte ( ) ; if ( $ header != 'NRM' || $ headerFormatVersion != ( int ) 0xFF ) { require_once 'Zend...
Load normalizatin factors from an index file
59,256
public function norm ( $ id , $ fieldName ) { $ fieldNum = $ this -> getFieldNum ( $ fieldName ) ; if ( ! ( $ this -> _fields [ $ fieldNum ] -> isIndexed ) ) { return null ; } if ( ! isset ( $ this -> _norms [ $ fieldNum ] ) ) { $ this -> _loadNorm ( $ fieldNum ) ; } return Zend_Search_Lucene_Search_Similarity :: decod...
Returns normalization factor for specified documents
59,257
public function normVector ( $ fieldName ) { $ fieldNum = $ this -> getFieldNum ( $ fieldName ) ; if ( $ fieldNum == - 1 || ! ( $ this -> _fields [ $ fieldNum ] -> isIndexed ) ) { $ similarity = Zend_Search_Lucene_Search_Similarity :: getDefault ( ) ; return str_repeat ( chr ( $ similarity -> encodeNorm ( $ similarity ...
Returns norm vector encoded in a byte string
59,258
public function writeChanges ( ) { $ latestDelGen = $ this -> _detectLatestDelGen ( ) ; if ( ! $ this -> _deletedDirty ) { if ( $ latestDelGen == $ this -> _delGen ) { return ; } else if ( $ latestDelGen > $ this -> _delGen ) { $ this -> _delGen = $ latestDelGen ; $ this -> _deleted = $ this -> _loadDelFile ( ) ; retur...
Write changes if it s necessary .
59,259
public function lock ( Request $ request ) { $ cacheKey = $ this -> getCacheKey ( $ request ) ; if ( isset ( $ this -> locks [ $ cacheKey ] ) ) { return false ; } $ this -> locks [ $ cacheKey ] = $ this -> lockFactory -> createLock ( $ cacheKey ) ; return $ this -> locks [ $ cacheKey ] -> acquire ( ) ; }
Locks the cache for a given Request .
59,260
public function isLocked ( Request $ request ) { $ cacheKey = $ this -> getCacheKey ( $ request ) ; if ( ! isset ( $ this -> locks [ $ cacheKey ] ) ) { return false ; } return $ this -> locks [ $ cacheKey ] -> isAcquired ( ) ; }
Returns whether or not a lock exists .
59,261
public function cleanup ( ) { try { foreach ( $ this -> locks as $ lock ) { $ lock -> release ( ) ; } } catch ( LockReleasingException $ e ) { } finally { $ this -> locks = [ ] ; } }
Release all locks .
59,262
public function invalidateTags ( array $ tags ) { if ( ! $ this -> cache instanceof TagAwareAdapterInterface ) { throw new \ RuntimeException ( 'Cannot invalidate tags on a cache implementation that does not implement the TagAwareAdapterInterface.' ) ; } try { return $ this -> cache -> invalidateTags ( $ tag...
The tags are set from the header configured in cache_tags_header .
59,263
private function autoPruneExpiredEntries ( ) { if ( 0 === $ this -> options [ 'prune_threshold' ] ) { return ; } $ item = $ this -> cache -> getItem ( self :: COUNTER_KEY ) ; $ counter = ( int ) $ item -> get ( ) ; if ( $ counter > $ this -> options [ 'prune_threshold' ] ) { $ this -> prune ( ) ; $ counter = 0 ; } else...
Increases a counter every time an item is stored to the cache and then prunes expired cache entries if a configurable threshold is reached . This only happens during write operations so cache retrieval is not slowed down .
59,264
private function restoreResponse ( array $ cacheData ) { $ body = null ; if ( isset ( $ cacheData [ 'headers' ] [ 'x-content-digest' ] [ 0 ] ) ) { $ item = $ this -> cache -> getItem ( $ cacheData [ 'headers' ] [ 'x-content-digest' ] [ 0 ] ) ; if ( $ item -> isHit ( ) ) { $ body = $ item -> get ( ) ; } } return new Res...
Restores a Response from the cached data .
59,265
public function debug ( ) { $ query = $ this -> pdo -> prepare ( <<<SQLSELECT *FROM robotstxt__cache1WHERE base = :base;SQL ) ; $ query -> bindValue ( 'base' , $ this -> base , \ PDO :: PARAM_STR ) ; $ query -> execute ( ) ; return $ query -> rowCount ( ) > 0 ? $ query -> fetch ( \ PDO :: FETCH_ASSOC ) : [ ] ; }
Debug - Get raw data
59,266
private function markAsActive ( $ workerID = 0 ) { if ( $ workerID == 0 ) { $ query = $ this -> pdo -> prepare ( <<<SQLUPDATE robotstxt__cache1SET worker = NULLWHERE base = :base AND worker = 0;SQL ) ; $ query -> bindValue ( 'base' , $ this -> base , \ PDO :: PARAM_STR ) ; return $ query -> execute ( ) ; } return true ...
Mark robots . txt as active
59,267
public function refresh ( ) { $ client = new UriClient ( $ this -> base , $ this -> curlOptions , $ this -> byteLimit ) ; $ effective = $ client -> getEffectiveUri ( ) ; if ( $ effective == $ this -> base ) { $ effective = null ; } $ statusCode = $ client -> getStatusCode ( ) ; $ nextUpdate = $ client -> nextUpdate ( )...
Update the robots . txt
59,268
private function displacePush ( $ nextUpdate ) { $ query = $ this -> pdo -> prepare ( <<<SQLSELECT validUntil, UNIX_TIMESTAMP()FROM robotstxt__cache1WHERE base = :base;SQL ) ; $ query -> bindValue ( 'base' , $ this -> base , \ PDO :: PARAM_STR ) ; $ query -> execute ( ) ; if ( $ query -> rowCount ( ) > 0 ) { $ row = ...
Displace push timestamp
59,269
public function updateCache ( ) { if ( $ this -> updateAttempted ) { return ; } $ this -> updateAttempted = true ; $ this -> metadata = $ this -> downloadMetadata ( ) ; if ( $ this -> metadata === null ) { return ; } $ expires = time ( ) + 24 * 60 * 60 ; if ( $ this -> metadata -> validUntil !== null && $ this -> metad...
Attempt to update our cache file .
59,270
public function getMetadata ( ) { if ( $ this -> metadata !== null ) { return $ this -> metadata ; } if ( ! $ this -> aggregator -> isCacheValid ( $ this -> cacheId , $ this -> cacheTag ) ) { $ this -> updateCache ( ) ; if ( $ this -> metadata !== null ) { return $ this -> metadata ; } } $ cacheFile = $ this -> aggrega...
Retrieve the metadata file .
59,271
public function setError ( $ code , $ node , $ message = '' ) { $ this -> errorCode = $ code ; $ this -> errorNode = $ node ; $ this -> errorMessage = $ message ; }
Sets error .
59,272
protected function setup_storage ( ) { $ storage = $ this -> get_option ( 'storage' ) ; if ( 'option' === $ storage ) { $ storage = Option_Storage :: get_instance ( ) ; } elseif ( 'thememod' === $ storage ) { $ storage = Theme_Mod_Storage :: get_instance ( ) ; } elseif ( is_string ( $ storage ) && is_subclass_of ( $ st...
Setup the field storage .
59,273
protected function setup_data ( ) { if ( ! $ storage = $ this -> get_storage ( ) ) { return ; } $ _hash = spl_object_hash ( $ storage ) ; if ( $ storage instanceof Deferred_Storage && ! isset ( static :: $ storages_was_read [ $ _hash ] ) ) { $ storage -> read ( ) ; static :: $ storages_was_read [ $ _hash ] = true ; } $...
Setup field data from the storage .
59,274
public function get_value ( ) { if ( $ this -> group && null === $ this -> value ) { return $ this -> value = $ this -> get_value_in_group ( ) ; } return $ this -> value ; }
Gets the field value .
59,275
protected function get_value_in_group ( ) { $ id = $ this -> get_id ( ) ; $ data = $ this -> group -> get_value ( ) ; return is_array ( $ data ) && isset ( $ data [ $ this -> group -> index ] [ $ id ] ) ? $ data [ $ this -> group -> index ] [ $ id ] : null ; }
Returns current value in group .
59,276
public function get_sanitization_value ( $ value ) { if ( $ this -> is_repeatable ( ) && is_callable ( $ sanitizer = $ this -> get_option ( 'sanitization_cb' ) ) ) { $ sanitized = is_array ( $ value ) ? array_map ( $ sanitizer , $ value ) : [ ] ; return Utils :: filter_blank ( $ sanitized ) ; } return $ this -> sanitiz...
Perform the sanitization a given value .
59,277
private function getExtension ( UploadedFile $ file ) : ? string { $ originalName = $ file -> getClientOriginalName ( ) ; if ( $ extension = pathinfo ( $ originalName , PATHINFO_EXTENSION ) ) { return strtolower ( $ extension ) ; } if ( $ extension = $ file -> guessExtension ( ) ) { return strtolower ( $ extension ) ; ...
Guess the extension of the given file .
59,278
public function save_file ( Request $ request ) { $ filepath = $ request -> input ( 'filepath' ) ; $ filedata = $ request -> input ( 'filedata' ) ; $ data = file_put_contents ( base_path ( $ filepath ) , $ filedata ) ; return response ( ) -> json ( [ 'success' => true ] ) ; }
Save file content
59,279
public function register ( ) { $ builder = $ this -> get_builder ( ) ; foreach ( $ this -> get_builder_config ( ) as $ key => $ value ) { $ builder -> set_option ( $ key , $ value ) ; } ( new Loader ( $ builder ) ) -> fire ( ) ; }
Register the box .
59,280
public function get_builder_config ( ) { $ vars = Arr :: except ( get_object_vars ( $ this ) , [ 'sections' , 'containers' , 'properties' , 'builder' , '_form' ] ) ; return array_merge ( $ vars , $ this -> properties ) ; }
Returns the form builder config .
59,281
public function get_property ( $ key ) { return isset ( $ this -> properties [ $ key ] ) ? $ this -> properties [ $ key ] : null ; }
Get box property .
59,282
private function getInlineValue ( $ header , $ part , $ delimiter = ";" ) { foreach ( array_map ( 'trim' , explode ( $ delimiter , $ header ) ) as $ string ) { if ( stripos ( $ string , $ part . '=' ) === 0 ) { return trim ( explode ( '=' , $ string , 2 ) [ 1 ] ) ; } } return false ; }
Get inline header variable value
59,283
private function buildCleanParam ( $ array ) { $ result = [ ] ; foreach ( $ array as $ param => $ paths ) { foreach ( $ paths as $ path ) { $ result [ ] = self :: DIRECTIVE_CLEAN_PARAM . ':' . $ param . ' ' . $ path ; } } return $ result ; }
Clean - param
59,284
private function buildUserAgent ( $ array ) { $ result = [ ] ; foreach ( $ array as $ userAgent => $ rules ) { $ rules = $ this -> arrayMergeRecursiveEx ( self :: TEMPLATE_SUB , $ rules ) ; $ result = array_merge ( $ result , [ self :: DIRECTIVE_USER_AGENT . ':' . $ userAgent ] , $ this -> buildString ( $ rules [ self ...
User - agent
59,285
private function buildVisitTime ( $ array ) { $ result = [ ] ; foreach ( $ array as $ pair ) { $ result [ ] = self :: DIRECTIVE_VISIT_TIME . ':' . $ pair [ 'from' ] . '-' . $ pair [ 'to' ] ; } return $ result ; }
Visit - time
59,286
private function buildRequestRate ( $ array ) { $ result = [ ] ; foreach ( $ array as $ pair ) { $ string = self :: DIRECTIVE_REQUEST_RATE . ':' . $ pair [ 'ratio' ] ; if ( isset ( $ pair [ 'from' ] ) && isset ( $ pair [ 'to' ] ) ) { $ string .= ' ' . $ pair [ 'from' ] . '-' . $ pair [ 'to' ] ; } $ result [ ] = $ strin...
Request - rate
59,287
public function cron ( $ timeLimit = self :: CRON_EXEC_TIME , $ workerID = self :: WORKER_ID ) { $ start = microtime ( true ) ; $ workerID = $ this -> setWorkerID ( $ workerID ) ; $ log = [ ] ; $ lastCount = - 1 ; while ( count ( $ log ) > $ lastCount && ( empty ( $ timeLimit ) || $ timeLimit > ( microtime ( true ) - $...
Process the update queue
59,288
public function clean ( $ delay = self :: CLEAN_DELAY ) { $ delay += self :: CACHE_TIME ; $ query = $ this -> pdo -> prepare ( <<<SQLDELETE FROM robotstxt__cache1WHERE nextUpdate < (UNIX_TIMESTAMP() - :delay);SQL ) ; $ query -> bindValue ( 'delay' , $ delay , \ PDO :: PARAM_INT ) ; return $ query -> execute ( ) ; }
Clean the cache table
59,289
protected function _prepareLayout ( ) { $ this -> buttonList -> remove ( 'save' ) ; $ this -> buttonList -> remove ( 'delete' ) ; $ this -> buttonList -> remove ( 'reset' ) ; $ this -> buttonList -> add ( 'send' , [ 'label' => __ ( 'Send mail ...' ) , 'onclick' => "setLocation('{$this->getUrl('*/*/send', ...
Prepare the layout .
59,290
public function getTimeSleepUntil ( ) { if ( $ this -> delay == 0 ) { return 0 ; } $ query = $ this -> pdo -> prepare ( <<<SQLSELECT delayUntil, UNIX_TIMESTAMP()FROM robotstxt__delay0WHERE base = :base AND userAgent = :userAgent;SQL ) ; $ query -> bindValue ( 'base' , $ this -> base , \ PDO :: PARAM_STR ) ; $ query -...
Timestamp with milliseconds
59,291
private function increment ( ) { $ query = $ this -> pdo -> prepare ( <<<SQLINSERT INTO robotstxt__delay0 (base, userAgent, delayUntil, lastDelay)VALUES (:base, :userAgent, (UNIX_TIMESTAMP(CURTIME(6)) + :delay) * 1000000, :delay * 1000000)ON DUPLICATE KEY UPDATE delayUntil = GREATEST((UNIX_TIMESTAMP(CURTIME(6)) + :del...
Set new delayUntil timestamp
59,292
public function execute ( $ cronjobId ) { $ cronjob = $ this -> cronjobTable -> get ( $ cronjobId ) ; if ( empty ( $ cronjob ) ) { throw new StatusCode \ NotFoundException ( 'Could not find cronjob' ) ; } if ( $ cronjob [ 'status' ] == Table \ Cronjob :: STATUS_DELETED ) { throw new StatusCode \ GoneException ( 'Cronjo...
Executes a specific cronjob
59,293
private function writeCronFile ( ) { if ( empty ( $ this -> cronFile ) ) { return false ; } if ( ! is_file ( $ this -> cronFile ) ) { return false ; } if ( ! is_writable ( $ this -> cronFile ) ) { return false ; } return file_put_contents ( $ this -> cronFile , $ this -> generateCron ( ) ) ; }
Writes the cron file
59,294
public function pay ( $ points , ContextInterface $ context ) { $ this -> userTable -> payPoints ( $ context -> getUser ( ) -> getId ( ) , $ points ) ; $ this -> usageTable -> create ( [ 'route_id' => $ context -> getRouteId ( ) , 'user_id' => $ context -> getUser ( ) -> getId ( ) , 'app_id' => $ context -> getApp ( ) ...
Method which is called in case a user visits a route which cost a specific amount of points . This method decreases the points from the user account
59,295
public function credit ( $ points , UserContext $ context ) { $ this -> userTable -> creditPoints ( $ context -> getUserId ( ) , $ points ) ; $ this -> eventDispatcher -> dispatch ( PlanEvents :: CREDIT , new CreditedEvent ( $ points , $ context ) ) ; }
Method which is called in case the user has bought new points . It adds the points to the user account
59,296
public function getMessage ( ) { if ( ! empty ( parent :: getMessage ( ) ) ) { return parent :: getMessage ( ) ; } return $ this -> _storage -> loadMessage ( $ this ) ; }
Every mailing is associated to a real message
59,297
public function getAttachments ( ) { if ( ! empty ( parent :: getAttachments ( ) ) ) { return parent :: getAttachments ( ) ; } $ attachments = $ this -> _storage -> getAttachments ( $ this ) ; $ this -> setAttachments ( $ attachments ) ; return $ attachments ; }
A mail can have zero to n associated attachments . An Attachment is a meta description to get information and access to binary data
59,298
public function getTags ( ) { $ value = $ this -> getData ( 'tags' ) ; if ( ! empty ( $ decoded = json_decode ( $ value , true ) ) ) { return $ decoded ; } return [ ] ; }
Get tags used for mail Tags are stored as json string in database
59,299
public function updateWithTransport ( $ transport ) { $ this -> setSubject ( $ transport -> getMessage ( ) -> getSubject ( ) ) -> setMessage ( $ transport -> getMessage ( ) ) -> setRecipients ( $ transport -> getMessage ( ) -> getRecipients ( ) ) -> setId ( null ) ; return $ this ; }
Update mail data with information created while transport init