idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
11,200
|
public function col_full_name ( string $ col , $ table = '' , $ escaped = false ) : ? string { return $ this -> language -> col_full_name ( $ col , $ table , $ escaped ) ; }
|
Return column s full name .
|
11,201
|
public function col_simple_name ( string $ col , bool $ escaped = false ) : ? string { return $ this -> language -> col_simple_name ( $ col , $ escaped ) ; }
|
Return the column s simple name .
|
11,202
|
public function get_tables ( string $ database = '' ) : ? array { if ( empty ( $ database ) ) { $ database = $ this -> current ; } return $ this -> _get_cache ( $ database , 'tables' ) ; }
|
Return tables names of a database as an array .
|
11,203
|
public function get_keys ( string $ table ) : ? array { if ( $ tmp = $ this -> _get_cache ( $ table ) ) { return [ 'keys' => $ tmp [ 'keys' ] , 'cols' => $ tmp [ 'cols' ] ] ; } return null ; }
|
Return the table s keys as an array indexed with the fields names .
|
11,204
|
public function get_insert ( array $ cfg ) : string { $ cfg [ 'kind' ] = 'INSERT' ; return $ this -> language -> get_insert ( $ this -> process_cfg ( $ cfg ) ) ; }
|
Returns the SQL code for an INSERT statement .
|
11,205
|
public function get_update ( array $ cfg ) : string { $ cfg [ 'kind' ] = 'UPDATE' ; return $ this -> language -> get_update ( $ this -> process_cfg ( $ cfg ) ) ; }
|
Returns the SQL code for an UPDATE statement .
|
11,206
|
public function get_delete ( array $ cfg ) : string { $ cfg [ 'kind' ] = 'DELETE' ; return $ this -> language -> get_delete ( $ this -> process_cfg ( $ cfg ) ) ; }
|
Returns the SQL code for a DELETE statement .
|
11,207
|
public function delete_index ( string $ table , string $ key ) : bool { return $ this -> language -> delete_index ( $ table , $ key ) ; }
|
Deletes index on a column of the table .
|
11,208
|
public function setLimits ( $ offset , $ limit , $ max = 0 , $ cutoff = 0 ) { $ this -> sphinx -> setLimits ( $ offset , $ limit , $ max , $ cutoff ) ; }
|
Set limits on the range and number of results returned .
|
11,209
|
public function setFilter ( $ attribute , $ values , $ exclude = false ) { $ this -> sphinx -> setFilter ( $ attribute , $ values , $ exclude ) ; }
|
Set the desired search filter .
|
11,210
|
public function search ( $ query , array $ indexes , array $ options = array ( ) , $ escapeQuery = true ) { if ( $ escapeQuery ) { $ query = $ this -> sphinx -> escapeString ( $ query ) ; } $ indexNames = '' ; foreach ( $ indexes as & $ label ) { if ( isset ( $ this -> indexes [ $ label ] ) ) { $ indexNames .= $ this -> indexes [ $ label ] . ' ' ; } } $ indexNames = trim ( $ indexNames ) ; if ( empty ( $ indexNames ) ) { return array ( ) ; } if ( isset ( $ options [ 'result_offset' ] ) && isset ( $ options [ 'result_limit' ] ) ) { $ this -> sphinx -> setLimits ( $ options [ 'result_offset' ] , $ options [ 'result_limit' ] ) ; } if ( isset ( $ options [ 'field_weights' ] ) ) { $ this -> sphinx -> setFieldWeights ( $ options [ 'field_weights' ] ) ; } $ results = $ this -> sphinx -> query ( $ query , $ indexNames ) ; if ( $ results === false || $ results [ 'status' ] !== SEARCHD_OK ) { if ( is_array ( $ results ) && $ results [ 'status' ] === SEARCHD_WARNING ) { $ errorText = $ this -> sphinx -> getLastWarning ( ) ; } else { $ errorText = $ this -> sphinx -> getLastError ( ) ; } throw new \ RuntimeException ( sprintf ( 'Searching index "%s" for "%s" failed with message "%s".' , $ label , $ query , $ errorText ) ) ; } return $ results ; }
|
Search for the specified query string .
|
11,211
|
public function addQuery ( $ query , array $ indexes ) { $ indexNames = '' ; foreach ( $ indexes as & $ label ) { if ( isset ( $ this -> indexes [ $ label ] ) ) { $ indexNames .= $ this -> indexes [ $ label ] . ' ' ; } } if ( ! empty ( $ indexNames ) ) { $ this -> sphinx -> addQuery ( $ query , $ indexNames ) ; } }
|
Adds a query to a multi - query batch using current settings .
|
11,212
|
public function getSnippet ( $ text , $ index , $ terms , $ options = array ( ) ) { $ results = $ this -> getSnippets ( array ( $ text ) , $ index , $ terms , $ options ) ; if ( $ results ) { return $ results [ 0 ] ; } return false ; }
|
Get snippet for text
|
11,213
|
public function getSnippets ( $ text , $ index , $ terms , $ options = array ( ) ) { return $ this -> sphinx -> BuildExcerpts ( $ text , $ index , $ terms , $ options ) ; }
|
Get snippets for array of text
|
11,214
|
public function resetAll ( ) { $ this -> sphinx -> ResetFilters ( ) ; $ this -> sphinx -> ResetGroupBy ( ) ; $ this -> sphinx -> ResetOverrides ( ) ; $ this -> sphinx -> SetSortMode ( SPH_SORT_RELEVANCE ) ; $ this -> resetLimits ( ) ; }
|
Reset filters group by overrides limits
|
11,215
|
public function setFilterFloatRange ( $ attribute , $ min , $ max , $ exclude = false ) { $ this -> sphinx -> SetFilterFloatRange ( $ attribute , $ min , $ max , $ exclude ) ; }
|
Set float range filter
|
11,216
|
public function setFilterRange ( $ attribute , $ min , $ max , $ exclude = false ) { $ this -> sphinx -> SetFilterRange ( $ attribute , $ min , $ max , $ exclude ) ; }
|
Set range filter
|
11,217
|
public function rotateAll ( ) { $ pb = $ this -> prepareProcessBuilder ( ) ; $ pb -> add ( '--all' ) ; $ indexer = $ pb -> getProcess ( ) ; $ indexer -> run ( ) ; if ( strstr ( $ indexer -> getOutput ( ) , 'FATAL:' ) || strstr ( $ indexer -> getOutput ( ) , 'ERROR:' ) ) { throw new \ RuntimeException ( sprintf ( 'Error rotating indexes: "%s".' , rtrim ( $ indexer -> getOutput ( ) ) ) ) ; } }
|
Rebuild and rotate all indexes .
|
11,218
|
protected function prepareProcessBuilder ( ) { $ pb = new ProcessBuilder ( ) ; $ pb -> inheritEnvironmentVariables ( ) ; if ( $ this -> sudo ) { $ pb -> add ( 'sudo' ) ; } $ pb -> add ( $ this -> bin ) ; if ( $ this -> config ) { $ pb -> add ( '--config' ) -> add ( $ this -> config ) ; } $ pb -> add ( '--rotate' ) ; return $ pb ; }
|
Prepare process builder
|
11,219
|
public static function createAbsolute ( $ url , array $ params = array ( ) ) { $ url = self :: addParams ( $ url , $ params ) ; $ url = ltrim ( $ url , '/' ) ; $ baseUrl = app ( ) -> request -> getBaseUrl ( ) ; return $ baseUrl . '/' . $ url ; }
|
Creates absolute url .
|
11,220
|
private static function addParams ( $ url , array $ params = array ( ) ) { $ cParams = count ( $ params ) ; if ( $ cParams > 0 ) { $ url .= '?' ; $ idx = 1 ; foreach ( $ params as $ key => $ value ) { $ url .= $ key . '=' . $ value ; if ( $ idx < $ cParams ) { $ url .= '&' ; } ++ $ idx ; } } return $ url ; }
|
Appends GET parameters to url .
|
11,221
|
private function writeAttributes ( $ file , $ fields ) { foreach ( $ fields as $ fieldName => $ field ) { fwrite ( $ file , " /**\n" ) ; fwrite ( $ file , " * $fieldName\n" ) ; fwrite ( $ file , " *\n" ) ; fwrite ( $ file , " * @var {$this->translateType($field->type)}\n" ) ; fwrite ( $ file , " */\n" ) ; fwrite ( $ file , " private \$$fieldName;\n" ) ; } }
|
Writes the list of attributes .
|
11,222
|
private function writeClass ( $ dir , $ tableName , ezcDbSchemaTable $ table ) { $ file = $ this -> openFile ( $ dir , $ tableName ) ; fwrite ( $ file , "/**\n" ) ; fwrite ( $ file , " * Data class $tableName.\n" ) ; fwrite ( $ file , " * Class to be used with eZ Components PersistentObject.\n" ) ; fwrite ( $ file , " */\n" ) ; fwrite ( $ file , "class {$this->prefix}$tableName\n" ) ; fwrite ( $ file , "{\n" ) ; $ this -> writeAttributes ( $ file , $ table -> fields ) ; fwrite ( $ file , "\n" ) ; $ this -> writeSetState ( $ file ) ; fwrite ( $ file , "\n" ) ; $ this -> writeGetState ( $ file , $ table -> fields ) ; fwrite ( $ file , "}\n" ) ; $ this -> closeFile ( $ file ) ; }
|
Writes a PHP class . This method writes a PHP class from a table definition .
|
11,223
|
private function openFile ( $ dir , $ name ) { $ filename = $ dir . DIRECTORY_SEPARATOR . strtolower ( $ this -> prefix ) . strtolower ( $ name ) . '.php' ; if ( file_exists ( $ filename ) && ( $ this -> overwrite === false || is_writable ( $ filename ) === false ) ) { throw new ezcBaseFileIoException ( $ filename , ezcBaseFileException :: WRITE , "File already exists or is not writeable. Use --overwrite to ignore existance." ) ; } $ file = @ fopen ( $ filename , 'w' ) ; if ( $ file === false ) { throw new ezcBaseFilePermissionException ( $ file , ezcBaseFileException :: WRITE ) ; } fwrite ( $ file , "<?php\n" ) ; fwrite ( $ file , "// Autogenerated class file\n" ) ; fwrite ( $ file , "\n" ) ; return $ file ; }
|
Open a file for writing a PersistentObject definition to . This method opens a file for writing a PersistentObject definition to and writes the basic PHP open tag to it .
|
11,224
|
public static function check ( $ permissions ) { if ( Schema :: hasTable ( 'laralum_permissions' ) ) { foreach ( $ permissions as $ permission ) { if ( ! self :: allCached ( ) -> contains ( 'slug' , $ permission [ 'slug' ] ) ) { Cache :: forget ( 'laralum_permissions' ) ; if ( ! self :: allCached ( ) -> contains ( 'slug' , $ permission [ 'slug' ] ) ) { Permission :: create ( [ 'name' => $ permission [ 'name' ] , 'slug' => $ permission [ 'slug' ] , 'description' => $ permission [ 'desc' ] , ] ) ; } } } } session ( [ 'laralum_permissions::mandatory' => array_merge ( static :: mandatory ( ) , $ permissions ) ] ) ; }
|
Checks if the permisions exists and if they dont they will be added .
|
11,225
|
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ this -> failWhenDisabled ( ) ; $ this -> failWhenStarted ( ) ; $ cookies = $ request -> getCookieParams ( ) ; $ session_id = $ cookies [ $ this -> name ] ?? '' ; if ( $ session_id != '' ) session_id ( $ session_id ) ; if ( session_start ( self :: SESSION_OPTIONS ) ) { session_name ( $ this -> name ) ; $ response = $ handler -> handle ( $ request ) ; $ this -> failWhenClosed ( ) ; $ session_id = session_id ( ) ; session_write_close ( ) ; return $ this -> withSessionCookie ( $ response , $ session_id ) ; } throw new SessionStartException ; }
|
Start the session handle the request and add the session cookie to the response .
|
11,226
|
private function withSessionCookie ( ResponseInterface $ response , string $ session_id ) : ResponseInterface { $ default = session_get_cookie_params ( ) ; $ default = array_change_key_case ( $ default , CASE_LOWER ) ; $ options = array_change_key_case ( $ this -> options , CASE_LOWER ) ; $ options = array_merge ( $ default , $ options ) ; if ( $ options [ 'lifetime' ] < 0 ) $ options [ 'lifetime' ] = 0 ; $ cookie = SetCookie :: create ( $ this -> name , $ session_id ) -> withMaxAge ( $ options [ 'lifetime' ] ) -> withPath ( $ options [ 'path' ] ) -> withDomain ( $ options [ 'domain' ] ) -> withSecure ( $ options [ 'secure' ] ) -> withHttpOnly ( $ options [ 'httponly' ] ) ; if ( $ options [ 'lifetime' ] > 0 ) { $ cookie = $ cookie -> withExpires ( time ( ) + $ options [ 'lifetime' ] ) ; } return FigResponseCookies :: set ( $ response , $ cookie ) ; }
|
Attach a session cookie with the given sesison id to the given response .
|
11,227
|
protected function createResponse ( PHPExcel $ excel , $ fileName ) { $ writer = new PHPExcel_Writer_Excel2007 ( $ excel ) ; ob_start ( ) ; $ writer -> save ( 'php://output' ) ; $ content = ob_get_clean ( ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-Type' , 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment;filename="' . $ fileName . '"' ) ; $ response -> headers -> set ( 'Cache-Control' , 'max-age=0' ) ; $ response -> setContent ( $ content ) ; return $ response ; }
|
Generates a response object for a PHPExcel object .
|
11,228
|
public static function haveSameKeys ( array $ array1 , array $ array2 ) { return self :: hasAllKeys ( $ array1 , array_keys ( $ array2 ) ) && self :: hasAllKeys ( $ array2 , array_keys ( $ array1 ) ) ? true : false ; }
|
Checks if two arrays have all equal keys
|
11,229
|
public static function haveSameValues ( $ array1 , $ array2 ) { return self :: hasAllValues ( $ array1 , $ array2 ) && self :: hasAllValues ( $ array2 , $ array1 ) ? true : false ; }
|
Check if two arrays have all equal values
|
11,230
|
public static function gen ( $ password ) { return crypt ( $ password , self :: $ algo . self :: $ cost . '$' . self :: uniqueSalt ( ) ) ; }
|
this will be used to generate a hash
|
11,231
|
public static function getComposerMap ( ) { $ composerMap = array ( ) ; foreach ( self :: getComposers ( ) as $ composer ) $ composerMap [ call_user_func ( array ( $ composer , "getKind" ) ) ] = $ composer ; return $ composerMap ; }
|
Returns a map from all composer kinds to class names .
|
11,232
|
public static function fromKind ( $ kind ) { $ composerMap = self :: getComposerMap ( ) ; if ( ! array_key_exists ( $ kind , $ composerMap ) ) throw new ComposerException ( "no composer found for \"$kind\"" ) ; $ class = $ composerMap [ $ kind ] ; return new $ class ( ) ; }
|
Creates a composer from a kind .
|
11,233
|
public function routes ( ) { Route :: get ( 'countries/{id}' , function ( $ id ) { $ request = request ( ) ; return CountryStore :: country ( $ id , $ request ) ; } ) -> name ( 'country' ) ; Route :: get ( 'countries' , function ( ) { $ request = request ( ) ; return CountryStore :: countries ( $ request ) ; } ) -> name ( 'countries' ) ; Route :: get ( 'administrative_areas/{id}' , function ( $ id ) { $ request = request ( ) ; return CountryStore :: administrativeArea ( $ id , $ request ) ; } ) -> name ( 'administrative_area' ) ; Route :: get ( 'cities/{city_id}' , function ( $ city_id ) { $ request = request ( ) ; return CountryStore :: city ( $ city_id , $ request ) ; } ) -> name ( 'city' ) ; }
|
Set routes for country API
|
11,234
|
public function country ( $ country_id , Request $ request = null ) { $ country = Country :: with ( 'zone' ) -> find ( $ country_id ) ; if ( $ request ) { $ included = [ ] ; $ query = $ country -> getInlcudeResources ( $ request -> include ) ; if ( $ query ) { $ collection = new Collection ( $ query , str_singular ( $ request -> include ) ) ; $ included = $ collection -> toArray ( ) ; } $ links = $ request ? [ 'self' => $ request -> url ( ) ] : [ ] ; return $ this -> respondWithItem ( $ country , 'country' , $ links , $ included ) ; } return $ country ; }
|
Get Country item . Optional include administrative areas
|
11,235
|
public function countries ( Request $ request = null ) { $ query = Country :: with ( 'zone' ) ; if ( $ request ) { $ resource = new Collection ( $ query , 'country' , $ request ) ; return $ this -> respondWithCollection ( $ resource ) ; } return $ query -> get ( ) ; }
|
Get Country list
|
11,236
|
public function administrativeArea ( $ admin_area_id , Request $ request = null ) { $ admin_area = AdministrativeArea :: find ( $ admin_area_id ) ; if ( $ request ) { $ included = [ ] ; if ( $ request -> has ( 'include' ) && AdministrativeArea :: isIncludable ( $ request -> include ) ) { $ cities = $ admin_area -> cities ( ) -> getQuery ( ) ; $ cities_included = new Collection ( $ cities , 'city' ) ; $ included = $ cities_included -> toArray ( ) ; } $ links = $ request ? [ 'self' => $ request -> url ( ) ] : [ ] ; return $ this -> respondWithItem ( $ admin_area , 'administrative_area' , $ links , $ included ) ; } return $ admin_area ; }
|
Get Administrative area item optional include cities
|
11,237
|
public function administrativeAreas ( $ country_id , Request $ request = null ) { $ query = AdministrativeArea :: where ( 'country_id' , $ country_id ) -> with ( 'country' ) ; if ( $ request ) { $ resource = new Collection ( $ query , 'administrative_area' , $ request ) ; return $ this -> respondWithCollection ( $ resource ) ; } return $ query -> get ( ) ; }
|
Get Administrative areas collection of a country given
|
11,238
|
public function city ( $ city_id , Request $ request = null ) { $ city = City :: find ( $ city_id ) ; if ( $ request ) { $ included = [ ] ; $ query = $ city -> getInlcudeResources ( $ request -> include ) ; if ( $ query ) { $ collection = new Collection ( $ query , $ request -> include ) ; $ included = $ collection -> toArray ( ) ; } $ links = $ request ? [ 'self' => $ request -> url ( ) ] : [ ] ; return $ this -> respondWithItem ( $ city , 'city' , $ links , $ included ) ; } return $ city ; }
|
Get city item optional include administrative division .
|
11,239
|
public function cities ( $ country_id , Request $ request = null ) { $ query = City :: with ( [ 'administrativeArea' => function ( $ q ) use ( $ country_id ) { $ q -> where ( 'country_id' , $ country_id ) ; } ] ) -> with ( 'administrativeArea.country' ) ; if ( $ request ) { $ resource = new Collection ( $ query , 'city' , $ request ) ; return $ this -> respondWithCollection ( $ resource ) ; } return $ query -> get ( ) ; }
|
Get country cities
|
11,240
|
protected function checkArgumentInDocBlock ( ) { $ validator = new IsArgumentInDocBlockValidator ( ) ; $ validator -> initialize ( $ this -> context ) ; return $ validator -> validate ( $ this -> validationValue , new IsArgumentInDocBlock ) ; }
|
Check if argument is inside docblock .
|
11,241
|
protected function checkArgumentNameMatchParam ( ) { $ validator = new DoesArgumentNameMatchParamValidator ; $ validator -> initialize ( $ this -> context ) ; return $ validator -> validate ( $ this -> validationValue , new DoesArgumentNameMatchParam ) ; }
|
Check if argument matches parameter .
|
11,242
|
protected function checkArgumentTypehintMatchParam ( ) { $ validator = new DoesArgumentTypehintMatchParamValidator ; $ validator -> initialize ( $ this -> context ) ; return $ validator -> validate ( $ this -> validationValue , new DoesArgumentTypehintMatchParam ) ; }
|
Check if argument typehint matches parameter .
|
11,243
|
protected function checkParamsExists ( ) { $ validator = new DoesParamsExistsValidator ( ) ; $ validator -> initialize ( $ this -> context ) ; return $ validator -> validate ( $ this -> validationValue , new DoesParamsExists ) ; }
|
Check if parameter exists for argument .
|
11,244
|
public static function getEnvNameByHost ( string $ defaultEnv = null , string $ hostname = null ) : string { $ hostname = $ hostname ? : gethostname ( ) ; if ( ! $ hostname ) { return $ defaultEnv ; } foreach ( self :: $ host2env as $ kw => $ env ) { if ( false !== strpos ( $ hostname , $ kw ) ) { return $ env ; } } return $ defaultEnv ; }
|
get Env Name By Host
|
11,245
|
public static function getEnvNameByDomain ( string $ defaultEnv = null , string $ domain = null ) : string { $ domain = $ domain ? : PhpHelper :: serverParam ( 'HTTP_HOST' ) ; if ( ! $ domain ) { return $ defaultEnv ; } foreach ( self :: $ domain2env as $ kw => $ env ) { if ( false !== strpos ( $ domain , $ kw ) ) { return $ env ; } } return $ defaultEnv ; }
|
get Env Name By Domain
|
11,246
|
public function delete ( ) { try { if ( is_null ( $ id = Input :: get ( 'id' ) ) ) { throw new Exception ( 'Invalid notification id provided' ) ; } $ this -> stack -> deleteById ( $ id ) ; } catch ( Exception $ ex ) { Log :: alert ( $ ex ) ; return new JsonResponse ( [ 'message' => trans ( 'antares/notifications::messages.sidebar.unable_to_delete_notification_item' ) ] , 500 ) ; } }
|
Deletes item from sidebar
|
11,247
|
public function read ( ) { try { $ this -> stack -> markAsRead ( from_route ( 'type' , 'notifications' ) ) ; return new JsonResponse ( '' , 200 ) ; } catch ( Exception $ ex ) { Log :: alert ( $ ex ) ; return new JsonResponse ( [ 'message' => trans ( 'antares/notifications::messages.sidebar.unable_to_mark_notifications_as_read' ) ] , 500 ) ; } }
|
Marks notification item as read
|
11,248
|
public function init ( $ file ) { try { $ this -> load ( $ file ) ; } catch ( Exceptions \ FileNotExists $ e ) { $ this -> create ( $ file ) ; } }
|
Attempts loading a file if its not there it create its .
|
11,249
|
public function load ( $ file ) { if ( ! $ this -> fs -> exists ( $ file ) ) { throw new Exceptions \ FileNotExists ( $ file ) ; } $ this -> file = $ file ; $ this -> info -> load ( $ file ) ; $ this -> extension = $ this -> info -> extension ; $ this -> directory = $ this -> info -> directory ; $ this -> filename = $ this -> info -> filename ; $ this -> extracter -> load ( $ file , $ this -> extension ) -> extract ( ) ; $ this -> params = $ this -> extracter -> params ( ) ; }
|
Loads the file and its details
|
11,250
|
public function saveAs ( $ extension = NULL ) { $ extension = ( ! is_null ( $ extension ) ? $ extension : $ this -> extension ) ; $ converter = $ this -> extracter -> converter ( ) ; $ converter -> setExtension ( $ extension ) ; $ data = $ converter -> toNative ( $ this -> params ) ; $ this -> rename ( NULL , $ extension ) ; $ this -> fs -> dumpFile ( $ this -> file , $ data ) ; }
|
Save as a different extension
|
11,251
|
public function rename ( $ file = NULL , $ extension = NULL ) { $ target = ( ! is_null ( $ file ) ? $ this -> filename : $ this -> extension ) ; $ replacement = ( ! is_null ( $ file ) ? $ file . '.' . $ this -> extension : $ extension ) ; $ this -> file = str_replace ( $ target , $ replacement , $ this -> file ) ; }
|
Renames a file or changes files extension
|
11,252
|
public function save ( ) { $ converter = $ this -> extracter -> converter ( ) ; $ data = $ converter -> toNative ( $ this -> params ) ; $ this -> fs -> dumpFile ( $ this -> file , $ data ) ; }
|
Saves the current params to the file
|
11,253
|
public function wp_title ( $ title , $ sep , $ location ) { if ( ! empty ( $ this -> title ) ) { $ array = [ $ this -> title ] ; $ sep = ' ' . trim ( $ sep ) . ' ' ; if ( 'right' == $ location ) { $ array [ ] = $ sep ; } else { array_unshift ( $ array , $ sep ) ; } $ title = implode ( '' , $ array ) ; } return $ title ; }
|
Filter wp title
|
11,254
|
public function notify ( NotificationInterface $ notification , $ level = self :: INFO ) { if ( ! $ this -> handlers ) { $ this -> addHandler ( new NullHandler ( ) ) ; } foreach ( $ this -> getHandlers ( ) as $ handler ) { if ( $ handler -> shouldHandle ( $ notification , $ level ) ) { if ( false === $ handler -> handle ( $ notification , $ level ) ) { return false ; } } } return true ; }
|
Handles notification for every handler
|
11,255
|
public function log ( $ level , $ message , array $ context = [ ] ) { return $ this -> notify ( new DetailedNotification ( $ message , '' , $ context ) , $ level ) ; }
|
Adds a new notification message to the queue as an attribute aware notification
|
11,256
|
protected function _generateFiles ( ) { if ( $ this -> feature && ! $ this -> isSelectedFeature ( $ this -> feature ) ) { $ this -> logFile -> log ( null , "did not add runtime information because \"$this->feature\" is not selected" ) ; return ; } $ this -> files [ ] = fphp \ File \ TemplateFile :: fromSpecification ( fphp \ Specification \ TemplateSpecification :: fromArrayAndSettings ( array ( "source" => "Runtime.php.template" , "target" => $ this -> target , "rules" => array ( array ( "assign" => "class" , "to" => $ this -> class ) , array ( "assign" => "getter" , "to" => $ this -> getter ) , array ( "assign" => "selectedFeatures" , "to" => $ this -> encodeFeatureNames ( $ this -> selectedArtifacts ) ) , array ( "assign" => "deselectedFeatures" , "to" => $ this -> encodeFeatureNames ( $ this -> deselectedArtifacts ) ) ) ) , Settings :: inDirectory ( __DIR__ ) ) ) ; }
|
Generates the runtime file . Internally this uses a template file and assigns the given variables . You can override this to add runtime information for other languages . If a feature was supplied only generates if that feature is selected .
|
11,257
|
public function traceRuntimeCalls ( $ files , $ productLine ) { $ runtimeCalls = array ( ) ; foreach ( $ files as $ file ) { $ content = $ file -> getContent ( ) ; if ( $ content instanceof fphp \ File \ StoredFileContent ) { $ fileSource = $ content -> getFileSource ( ) ; $ content = file_get_contents ( $ fileSource ) ; } else { $ fileSource = "(text file)" ; $ content = $ content -> getSummary ( ) ; } foreach ( explode ( "\n" , $ content ) as $ idx => $ line ) if ( strstr ( $ line , "$this->class::$this->getter" ) ) { preg_match ( "/$this->class::$this->getter\(.*?[\"'](.*?)[\"'].*?\)/" , $ line , $ matches ) ; try { $ feature = $ productLine -> getFeature ( $ matches [ 1 ] ) ; } catch ( fphp \ Model \ ModelException $ e ) { throw new RuntimeGeneratorException ( "invalid runtime feature \"$matches[1]\"" ) ; } $ runtimeCalls [ ] = new fphp \ Artifact \ TracingLink ( "runtime" , $ productLine -> getArtifact ( $ feature ) , new fphp \ Artifact \ LinePlace ( $ fileSource , $ idx + 1 ) , new fphp \ Artifact \ LinePlace ( $ file -> getTarget ( ) , $ idx + 1 ) ) ; } } return $ runtimeCalls ; }
|
Returns tracing links for all calls of the runtime class .
|
11,258
|
public function generateXml ( ) { $ xml = $ this -> getUpdate ( ) -> asSimplexml ( ) ; $ removeInstructions = $ xml -> xpath ( "//remove" ) ; if ( is_array ( $ removeInstructions ) ) { foreach ( $ removeInstructions as $ infoNode ) { if ( ! $ this -> checkConditionals ( $ infoNode , false ) ) { continue ; } $ blockName = trim ( ( string ) $ infoNode [ 'name' ] ) ; if ( $ blockName ) { $ ignoreNodes = $ xml -> xpath ( "//block[@name='" . $ blockName . "'] | //reference[@name='" . $ blockName . "']" ) ; if ( is_array ( $ ignoreNodes ) ) { foreach ( $ ignoreNodes as $ ignoreNode ) { $ ignoreNode [ 'ignore' ] = true ; } } } } } $ this -> setXml ( $ xml ) ; return $ this ; }
|
Layout XML generation
|
11,259
|
public function generateBlocks ( $ parent = null ) { if ( $ parent instanceof Mage_Core_Model_Layout_Element ) { if ( ! $ this -> checkConditionals ( $ parent ) ) { return ; } $ this -> processOutputAttribute ( $ parent ) ; } parent :: generateBlocks ( $ parent ) ; }
|
Create layout blocks hierarchy from layout xml configuration
|
11,260
|
protected function _generateBlock ( $ node , $ parent ) { if ( $ node instanceof Mage_Core_Model_Layout_Element ) { if ( ! $ this -> checkConditionals ( $ node ) ) { return $ this ; } } return parent :: _generateBlock ( $ node , $ parent ) ; }
|
Add block object to layout based on xml node data
|
11,261
|
protected function _generateAction ( $ node , $ parent ) { if ( $ node instanceof Mage_Core_Model_Layout_Element ) { if ( ! $ this -> checkConditionals ( $ node ) ) { return $ this ; } } $ method = ( string ) $ node [ 'method' ] ; if ( ! empty ( $ node [ 'block' ] ) ) { $ parentName = ( string ) $ node [ 'block' ] ; } else { $ parentName = $ parent -> getBlockName ( ) ; } $ _profilerKey = 'BLOCK ACTION: ' . $ parentName . ' -> ' . $ method ; Varien_Profiler :: start ( $ _profilerKey ) ; if ( ! empty ( $ parentName ) ) { $ block = $ this -> getBlock ( $ parentName ) ; } if ( ! empty ( $ block ) ) { $ args = ( array ) $ node -> children ( ) ; $ jsonArgs = ( isset ( $ node [ 'json' ] ) ? explode ( ' ' , ( string ) $ node [ 'json' ] ) : [ ] ) ; $ jsonHelper = Mage :: helper ( 'core' ) ; $ translateArgs = ( isset ( $ node [ 'translate' ] ) ? explode ( ' ' , ( string ) $ node [ 'translate' ] ) : [ ] ) ; $ translateHelper = Mage :: helper ( isset ( $ node [ 'module' ] ) ? ( string ) $ node [ 'module' ] : 'core' ) ; $ args = $ this -> processActionArgs ( $ args , $ jsonArgs , $ jsonHelper , $ translateArgs , $ translateHelper ) ; call_user_func_array ( [ $ block , $ method ] , $ args ) ; } Varien_Profiler :: stop ( $ _profilerKey ) ; return $ this ; }
|
Convert an action node into a method call on the parent block
|
11,262
|
protected function getHelperMethodValue ( $ helperMethodString , $ args = null ) { $ helperName = explode ( '/' , ( string ) $ helperMethodString ) ; $ helperMethod = array_pop ( $ helperName ) ; $ helperName = implode ( '/' , $ helperName ) ; $ helperArgs = [ ] ; if ( ! is_array ( $ args ) ) { $ helperArgs [ ] = $ args ; } else { $ helperArgs = $ args ; } return call_user_func_array ( [ Mage :: helper ( $ helperName ) , $ helperMethod ] , $ helperArgs ) ; }
|
Gets the value of a helper method from the helper method string
|
11,263
|
protected function processOutputAttribute ( Mage_Core_Model_Layout_Element $ node ) { if ( isset ( $ node [ 'output' ] ) ) { $ blockName = ( string ) $ node [ 'name' ] ; if ( empty ( $ blockName ) ) { return ; } $ method = trim ( ( string ) $ node [ 'output' ] ) ; if ( empty ( $ method ) ) { $ this -> removeOutputBlock ( $ blockName ) ; } else { $ this -> addOutputBlock ( $ blockName , $ method ) ; } } }
|
Process the output attribute of a node
|
11,264
|
protected function checkConditionals ( Mage_Core_Model_Layout_Element $ node , $ aclDefault = true ) { return $ this -> checkConfigConditional ( $ node ) && ( $ aclDefault ? $ this -> checkAclConditional ( $ node , $ aclDefault ) : ! $ this -> checkAclConditional ( $ node , $ aclDefault ) ) && $ this -> checkHelperConditional ( $ node ) ; }
|
Checks all conditionals for a given layout node
|
11,265
|
public function getDup ( $ contador ) { $ dup = $ this -> getElementsByTagName ( 'dup' ) -> item ( $ contador ) ; return self :: createByXml ( $ dup -> C14N ( ) ) ; }
|
Pega a propriedade do Dup .
|
11,266
|
public function onFormSuccess ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; $ result = $ this -> createResult ( $ form ) ; if ( $ form -> getStoreResults ( ) ) { $ this -> storeResult ( $ form , $ result ) ; } if ( $ form -> getSendMail ( ) ) { $ this -> sendMail ( $ form , $ result ) ; } $ successUrl = $ form -> getSuccessUrl ( ) ; if ( $ successUrl != null ) { $ redirectResponse = new RedirectResponse ( $ successUrl ) ; $ redirectResponse -> send ( ) ; } }
|
Default handling for the form success event . This includes storage of the result sending a confirmation mail and redirecting to the success URL while respecting the form settings .
|
11,267
|
public function createResult ( Form $ form ) { $ result = new Result ( ) ; $ result -> setDatetimeAdded ( new \ DateTime ( ) ) ; $ viewData = $ form -> getSf2Form ( ) -> getViewData ( ) ; foreach ( $ form -> getFields ( ) as $ field ) { $ entry = new Entry ( ) ; $ entry -> setField ( $ field ) ; $ entry -> setValue ( $ viewData [ 'field_' . $ field -> getId ( ) ] ) ; $ result -> addEntry ( $ entry ) ; } return $ result ; }
|
Creates the result object from the user s input .
|
11,268
|
public function storeResult ( Form $ form , Result $ result ) { $ entityManager = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; $ form -> addResult ( $ result ) ; $ entityManager -> persist ( $ form ) ; $ entityManager -> flush ( ) ; }
|
Stores the user input as a result object .
|
11,269
|
public function sendMail ( Form $ form , Result $ result ) { $ message = \ Swift_Message :: newInstance ( ) -> setSubject ( $ form -> getMailSubject ( ) ) -> setTo ( array ( $ form -> getMailRecipientEmail ( ) => $ form -> getMailRecipientName ( ) ) ) -> setBody ( $ this -> container -> get ( 'templating' ) -> render ( 'NetvliesFormBundle:Mail:result.html.twig' , array ( 'content' => $ form -> getMailBody ( ) , 'entries' => $ result -> getEntries ( ) , ) ) , 'text/html' ) ; if ( $ form -> getMailSenderName ( ) != null && $ form -> getMailSenderEmail ( ) != null ) { $ message -> setFrom ( array ( $ form -> getMailSenderEmail ( ) => $ form -> getMailSenderName ( ) ) ) ; } $ this -> container -> get ( 'mailer' ) -> send ( $ message ) ; $ transport = $ this -> container -> get ( 'mailer' ) -> getTransport ( ) ; if ( ! $ transport instanceof \ Swift_Transport_SpoolTransport ) { return ; } $ spool = $ transport -> getSpool ( ) ; if ( ! $ spool instanceof \ Swift_MemorySpool ) { return ; } $ spool -> flushQueue ( $ this -> container -> get ( 'swiftmailer.transport.real' ) ) ; }
|
Sends a mail containing the form values to the contact e - mail address specified .
|
11,270
|
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ appConfig = $ serviceLocator -> get ( 'config' ) ; $ config = array_key_exists ( 'log' , $ appConfig ) ? $ appConfig [ 'log' ] : array ( ) ; $ class = array_key_exists ( 'class' , $ config ) ? $ config [ 'class' ] : 'Zend\Log\Logger' ; $ logger = new $ class ( $ config ) ; return $ logger ; }
|
Creates a Logger service
|
11,271
|
private function processModules ( DependencyInjectionContainer $ dic , array $ modules , array & $ config ) { $ dependencyGraph = new ModuleDependencyGraph ( ) ; $ dependencyGraph -> addModules ( $ modules ) ; $ modules = $ dependencyGraph -> getSortedModuleList ( ) ; foreach ( $ modules as $ module ) { $ this -> loadModuleConfiguration ( $ module , $ config ) ; } foreach ( $ modules as $ module ) { $ module -> configureDependencyInjection ( $ dic , $ config [ $ module -> getModuleKey ( ) ] , $ config ) ; } }
|
Process modules after initial loading .
|
11,272
|
private function loadModule ( $ moduleClass , array & $ modules , array $ moduleList , DependencyInjectionContainer $ dic ) { $ module = $ dic -> make ( $ moduleClass ) ; if ( ! $ module instanceof Module ) { throw new ConfigurationException ( get_class ( $ module ) . ' was configured as a module, but doesn\'t implement ' . Module :: class ) ; } if ( ! \ in_array ( $ module , $ modules ) ) { $ dic -> share ( $ module ) ; $ this -> loadRequiredModules ( $ module , $ modules , $ moduleList , $ dic ) ; $ modules [ ] = $ module ; } }
|
Load a module by class name .
|
11,273
|
private function loadRequiredModules ( Module $ module , & $ modules , array $ moduleList , DependencyInjectionContainer $ dic ) { foreach ( $ module -> getRequiredModules ( ) as $ requiredModule ) { if ( ! \ in_array ( $ requiredModule , $ moduleList ) ) { $ this -> loadModule ( $ requiredModule , $ modules , $ moduleList , $ dic ) ; if ( $ module instanceof RequiredModuleAwareModule ) { $ module -> addRequiredModule ( $ dic -> make ( $ requiredModule ) ) ; } } } }
|
Load the modules a certain module requires .
|
11,274
|
private function loadModuleConfiguration ( Module $ module , array & $ config ) { $ key = $ module -> getModuleKey ( ) ; if ( ! isset ( $ config [ $ key ] ) ) { $ config [ $ key ] = array ( ) ; } $ module -> loadConfiguration ( $ config [ $ key ] , $ config ) ; }
|
Load the configuration for a specific module .
|
11,275
|
public function addRule ( Rule $ rule ) { $ this -> addReason ( $ rule -> getId ( ) , array ( 'rule' => $ rule , 'job' => $ rule -> getJob ( ) , ) ) ; }
|
Add a rule as a reason
|
11,276
|
protected function jobToText ( $ job ) { switch ( $ job [ 'cmd' ] ) { case 'install' : $ packages = $ this -> pool -> whatProvides ( $ job [ 'packageName' ] , $ job [ 'constraint' ] ) ; if ( ! $ packages ) { return 'No package found to satisfy install request for ' . $ job [ 'packageName' ] . $ this -> constraintToText ( $ job [ 'constraint' ] ) ; } return 'Installation request for ' . $ job [ 'packageName' ] . $ this -> constraintToText ( $ job [ 'constraint' ] ) . ' -> satisfiable by ' . $ this -> getPackageList ( $ packages ) . '.' ; case 'update' : return 'Update request for ' . $ job [ 'packageName' ] . $ this -> constraintToText ( $ job [ 'constraint' ] ) . '.' ; case 'remove' : return 'Removal request for ' . $ job [ 'packageName' ] . $ this -> constraintToText ( $ job [ 'constraint' ] ) . '' ; } if ( isset ( $ job [ 'constraint' ] ) ) { $ packages = $ this -> pool -> whatProvides ( $ job [ 'packageName' ] , $ job [ 'constraint' ] ) ; } else { $ packages = array ( ) ; } return 'Job(cmd=' . $ job [ 'cmd' ] . ', target=' . $ job [ 'packageName' ] . ', packages=[' . $ this -> getPackageList ( $ packages ) . '])' ; }
|
Turns a job into a human readable description
|
11,277
|
public function getTemplateHtmlAndScript ( ) { $ html = '' ; $ scripts = [ ] ; foreach ( $ this -> fields ( ) as $ field ) { $ html .= $ field -> render ( ) ; if ( $ field -> getScript ( ) ) { $ scripts [ ] = array_pop ( Merchant :: $ script ) ; } } return [ $ html , implode ( "\r\n" , $ scripts ) ] ; }
|
Get the html and script of template .
|
11,278
|
protected function formatField ( Field $ field ) { $ column = $ field -> column ( ) ; $ elementName = $ elementClass = $ errorKey = [ ] ; $ key = $ this -> key ? : 'new_' . static :: DEFAULT_KEY_NAME ; if ( is_array ( $ column ) ) { foreach ( $ column as $ k => $ name ) { $ errorKey [ $ k ] = sprintf ( '%s.%s.%s' , $ this -> relationName , $ key , $ name ) ; $ elementName [ $ k ] = sprintf ( '%s[%s][%s]' , $ this -> relationName , $ key , $ name ) ; $ elementClass [ $ k ] = [ $ this -> relationName , $ name ] ; } } else { $ errorKey = sprintf ( '%s.%s.%s' , $ this -> relationName , $ key , $ column ) ; $ elementName = sprintf ( '%s[%s][%s]' , $ this -> relationName , $ key , $ column ) ; $ elementClass = [ $ this -> relationName , $ column ] ; } return $ field -> setErrorKey ( $ errorKey ) -> setElementName ( $ elementName ) -> setElementClass ( $ elementClass ) ; }
|
Set errorKey elementName elementClass for fields inside hasmany fields .
|
11,279
|
public static function encryptOpenssl ( $ textToEncrypt , string $ secretHash = null , string $ password = '' ) : ? string { if ( ! $ secretHash ) { $ secretHash = self :: $ salt ; } if ( $ length = openssl_cipher_iv_length ( self :: $ method ) ) { $ iv = substr ( md5 ( self :: $ prefix . $ password ) , 0 , $ length ) ; return openssl_encrypt ( $ textToEncrypt , self :: $ method , $ secretHash , true , $ iv ) ; } return null ; }
|
Encrypt string using openSSL module
|
11,280
|
public static function decryptOpenssl ( $ textToDecrypt , string $ secretHash = null , string $ password = '' ) : ? string { if ( ! $ secretHash ) { $ secretHash = self :: $ salt ; } if ( $ length = openssl_cipher_iv_length ( self :: $ method ) ) { $ iv = substr ( md5 ( self :: $ prefix . $ password ) , 0 , $ length ) ; return openssl_decrypt ( $ textToDecrypt , self :: $ method , $ secretHash , true , $ iv ) ; } return null ; }
|
Decrypt string using openSSL module
|
11,281
|
public function upload ( string $ projectKey , string $ ext , string $ filename , array $ params ) { if ( ! file_exists ( $ filename ) ) { throw new Exception \ InvalidArgumentException ( 'file ' . $ filename . ' not found' ) ; } if ( ! isset ( $ params [ 'locale_id' ] ) ) { throw new Exception \ InvalidArgumentException ( 'locale_id is missing in params' ) ; } $ postData = [ [ 'name' => 'file' , 'content' => file_get_contents ( $ filename ) , 'filename' => basename ( $ filename ) ] , [ 'name' => 'file_format' , 'content' => $ ext ] , [ 'name' => 'locale_id' , 'content' => $ params [ 'locale_id' ] ] , ] ; if ( isset ( $ params [ 'update_translations' ] ) ) { $ postData [ ] = [ 'name' => 'update_translations' , 'content' => $ params [ 'update_translations' ] ] ; } if ( isset ( $ params [ 'tags' ] ) ) { $ postData [ ] = [ 'name' => 'tags' , 'content' => $ params [ 'tags' ] ] ; } $ response = $ this -> httpPostRaw ( sprintf ( '/api/v2/projects/%s/uploads' , $ projectKey ) , $ postData , [ 'Content-Type' => 'application/x-www-form-urlencoded' , ] ) ; if ( ! $ this -> hydrator ) { return $ response ; } if ( $ response -> getStatusCode ( ) !== 200 && $ response -> getStatusCode ( ) !== 201 ) { $ this -> handleErrors ( $ response ) ; } return $ this -> hydrator -> hydrate ( $ response , Uploaded :: class ) ; }
|
Upload a locale .
|
11,282
|
public function request ( $ method , $ absUrl , $ params , $ headers ) { $ curl = curl_init ( ) ; $ method = strtolower ( $ method ) ; $ opts = array ( ) ; if ( $ method == 'get' ) { $ opts [ CURLOPT_HTTPGET ] = 1 ; if ( count ( $ params ) > 0 ) { $ encoded = self :: urlEncode ( $ params ) ; $ absUrl = "$absUrl?$encoded" ; } } elseif ( $ method == 'post' ) { $ opts [ CURLOPT_POST ] = 1 ; $ opts [ CURLOPT_POSTFIELDS ] = json_encode ( $ params ) ; } elseif ( $ method == 'delete' ) { $ opts [ CURLOPT_CUSTOMREQUEST ] = 'DELETE' ; if ( count ( $ params ) > 0 ) { $ encoded = self :: urlEncode ( $ params ) ; $ absUrl = "$absUrl?$encoded" ; } } else { throw new Error ( "Unrecognized method $method" ) ; } $ rheaders = array ( ) ; $ headerCallback = function ( $ curl , $ header_line ) use ( & $ rheaders ) { if ( strpos ( $ header_line , ":" ) === false ) { return strlen ( $ header_line ) ; } list ( $ key , $ value ) = explode ( ":" , trim ( $ header_line ) , 2 ) ; $ rheaders [ trim ( $ key ) ] = trim ( $ value ) ; return strlen ( $ header_line ) ; } ; array_push ( $ headers , 'Expect: ' ) ; $ opts [ CURLOPT_URL ] = $ absUrl ; $ opts [ CURLOPT_RETURNTRANSFER ] = true ; $ opts [ CURLOPT_CONNECTTIMEOUT ] = 80 ; $ opts [ CURLOPT_TIMEOUT ] = 30 ; $ opts [ CURLOPT_HEADERFUNCTION ] = $ headerCallback ; $ opts [ CURLOPT_HTTPHEADER ] = $ headers ; curl_setopt_array ( $ curl , $ opts ) ; $ rbody = curl_exec ( $ curl ) ; if ( $ rbody === false ) { $ errno = curl_errno ( $ curl ) ; $ message = curl_error ( $ curl ) ; curl_close ( $ curl ) ; $ this -> handleCurlError ( $ errno , $ message ) ; } $ rcode = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; curl_close ( $ curl ) ; return array ( json_decode ( $ rbody ) , $ rcode , $ rheaders ) ; }
|
Make the request
|
11,283
|
private function handleCurlError ( $ errno , $ message ) { switch ( $ errno ) { case CURLE_COULDNT_CONNECT : case CURLE_COULDNT_RESOLVE_HOST : case CURLE_OPERATION_TIMEOUTED : $ msg = "Could not connect" ; break ; case CURLE_SSL_CACERT : case CURLE_SSL_PEER_CERTIFICATE : $ msg = "Could not verify SSL certificate." ; break ; default : $ msg = "Unexpected curl error." ; } $ msg .= "\n\n(Network error [errno $errno]: $message)" ; throw new \ LeaseCloud \ Error ( $ msg ) ; }
|
Throw an exception with message indicating type of http error
|
11,284
|
public function pop ( ) { $ keys = array_keys ( $ this -> queues ) ; for ( $ this -> queueCounter ; isset ( $ keys [ $ this -> queueCounter ] ) ; $ this -> queueCounter ++ ) { $ queue = $ this -> queues [ $ keys [ $ this -> queueCounter ] ] ; $ message = $ queue -> pop ( ) ; if ( $ message !== null ) { $ this -> queueCounter ++ ; $ this -> processedMessages ++ ; return $ message ; } if ( ( count ( $ this -> queues ) - 1 ) === $ this -> queueCounter ) { $ this -> queueCounter = 0 ; if ( $ this -> processedMessages === 0 ) { return null ; } $ this -> processedMessages = 0 ; } } return null ; }
|
Returns the next message from each queue until all are empty
|
11,285
|
public function loadCustomerGroupConfigFile ( ModuleToggleActivationEvent $ event ) { $ event -> setModule ( ModuleQuery :: create ( ) -> findPk ( $ event -> getModuleId ( ) ) ) ; if ( $ event -> getModule ( ) -> getActivate ( ) === BaseModule :: IS_NOT_ACTIVATED ) { $ this -> configurationFileHandler -> loadConfigurationFile ( $ event -> getModule ( ) ) ; } }
|
Load customer group definitions
|
11,286
|
protected function getFileDescriptor ( $ element ) { $ fileDescriptor = $ element instanceof FileDescriptor ? $ element : $ element -> getFile ( ) ; if ( ! $ fileDescriptor instanceof FileDescriptor ) { throw new \ UnexpectedValueException ( 'An element should always have a file associated with it' ) ; } return $ fileDescriptor ; }
|
Retrieves the File Descriptor from the given element .
|
11,287
|
function reindex ( $ mode , $ post_id , $ message , $ subject , $ poster_id , $ forum_id ) { global $ config , $ phpbb_root_path , $ phpEx ; $ search_type = basename ( $ config [ 'search_type' ] ) ; if ( ! file_exists ( $ phpbb_root_path . 'phpbb/search/' . $ search_type . '.' . $ phpEx ) ) { trigger_error ( 'NO_SUCH_SEARCH_MODULE' , E_USER_ERROR ) ; } require_once ( "{$phpbb_root_path}phpbb/search/$search_type.$phpEx" ) ; $ search_type = "\\phpbb\\search\\" . $ search_type ; $ error = false ; $ search = new $ search_type ( $ error ) ; if ( $ error ) { trigger_error ( $ error ) ; } $ search -> index ( $ mode , $ post_id , $ message , $ subject , $ poster_id , $ forum_id ) ; }
|
Reindex post in search
|
11,288
|
private function from_notes ( array $ messages , $ simple = true ) { if ( ! empty ( $ messages ) ) { foreach ( $ messages as $ idx => $ mess ) { if ( empty ( $ mess [ 'id_note' ] ) ) { unset ( $ messages [ $ idx ] ) ; continue ; } $ note = $ this -> notes -> get ( $ mess [ 'id_note' ] ) ; $ note = [ 'id' => $ mess [ 'id' ] , 'title' => $ note [ 'title' ] , 'content' => $ note [ 'content' ] ] ; if ( $ simple ) { $ messages [ $ idx ] = $ note ; } else { $ messages [ $ idx ] = \ bbn \ x :: merge_arrays ( $ messages [ $ idx ] , $ note ) ; } } } return $ messages ; }
|
Gets internal messages info from notes archive
|
11,289
|
public function insert ( $ imess ) { $ cfg = & $ this -> class_cfg ; if ( empty ( $ imess [ 'id_option' ] ) ) { $ perm = new \ bbn \ user \ permissions ( ) ; $ imess [ 'id_option' ] = $ perm -> is ( self :: BBN_DEFAULT_PERM ) ; } if ( ! empty ( $ imess [ 'id_option' ] ) && ! empty ( $ imess [ 'title' ] ) && ! empty ( $ imess [ 'content' ] ) && ! empty ( $ this -> _id_type ( ) ) && ( $ id_note = $ this -> notes -> insert ( $ imess [ 'title' ] , $ imess [ 'content' ] , $ this -> _id_type ( ) ) ) && $ this -> db -> insert ( $ cfg [ 'table' ] , [ $ cfg [ 'arch' ] [ 'imessages' ] [ 'id_note' ] => $ id_note , $ cfg [ 'arch' ] [ 'imessages' ] [ 'id_option' ] => $ imess [ 'id_option' ] , $ cfg [ 'arch' ] [ 'imessages' ] [ 'id_user' ] => $ imess [ 'id_user' ] ? : NULL , $ cfg [ 'arch' ] [ 'imessages' ] [ 'id_group' ] => $ imess [ 'id_group' ] ? : NULL , $ cfg [ 'arch' ] [ 'imessages' ] [ 'start' ] => $ imess [ 'start' ] ? : NULL , $ cfg [ 'arch' ] [ 'imessages' ] [ 'end' ] => $ imess [ 'end' ] ? : NULL ] ) ) { return $ this -> db -> last_id ( ) ; } return false ; }
|
Inserts a new page s internal message
|
11,290
|
public function get ( string $ id_option , string $ id_user , $ simple = true ) { $ cfg = & $ this -> class_cfg ; $ now = date ( 'Y-m-d H:i:s' ) ; $ id_group = $ this -> db -> select_one ( 'bbn_users' , 'id_group' , [ 'id' => $ id_user ] ) ; $ messages = $ this -> db -> get_rows ( " SELECT {$cfg['table']}.* FROM {$cfg['tables']['users']} RIGHT JOIN {$cfg['table']} ON {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']} WHERE ( {$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ? ) AND ( {$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ? ) AND ( {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ? OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ? OR ( {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL AND {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL ) ) AND {$cfg['table']}.{$cfg['arch']['imessages']['id_option']} = ? AND ( {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0 )" , $ now , $ now , hex2bin ( $ id_user ) , hex2bin ( $ id_group ) , hex2bin ( $ id_option ) ) ; return $ this -> from_notes ( $ messages , $ simple ) ; }
|
Gets the page s internal messages of an user
|
11,291
|
public function set_hidden ( string $ id_imess , string $ id_user ) { $ cfg = & $ this -> class_cfg ; if ( ! empty ( $ id_imess ) && ! empty ( $ id_user ) ) { return ! ! $ this -> db -> insert_update ( $ cfg [ 'tables' ] [ 'users' ] , [ $ cfg [ 'arch' ] [ 'users' ] [ 'id_imessage' ] => $ id_imess , $ cfg [ 'arch' ] [ 'users' ] [ 'id_user' ] => $ id_user , $ cfg [ 'arch' ] [ 'users' ] [ 'hidden' ] => 1 , $ cfg [ 'arch' ] [ 'users' ] [ 'moment' ] => date ( 'Y-m-d H:i:s' ) , ] , [ $ cfg [ 'arch' ] [ 'users' ] [ 'id_imessage' ] => $ id_imess , $ cfg [ 'arch' ] [ 'users' ] [ 'id_user' ] => $ id_user ] ) ; } return false ; }
|
Sets an user s internal message as visible
|
11,292
|
public function unset_hidden ( string $ id_imess , string $ id_user ) { $ cfg = & $ this -> class_cfg ; if ( ! empty ( $ id_imess ) && ! empty ( $ id_user ) ) { return ! ! $ this -> db -> update_ignore ( $ cfg [ 'tables' ] [ 'users' ] , [ $ cfg [ 'arch' ] [ 'users' ] [ 'id_imessage' ] => $ id_imess , $ cfg [ 'arch' ] [ 'users' ] [ 'id_user' ] => $ id_user , $ cfg [ 'arch' ] [ 'users' ] [ 'hidden' ] => 0 , $ cfg [ 'arch' ] [ 'users' ] [ 'moment' ] => date ( 'Y-m-d H:i:s' ) , ] , [ $ cfg [ 'arch' ] [ 'users' ] [ 'id_imessage' ] => $ id_imess , $ cfg [ 'arch' ] [ 'users' ] [ 'id_user' ] => $ id_user ] ) ; } return false ; }
|
Sets an user s internal message as not visible
|
11,293
|
public function get_by_user ( string $ id_user ) { $ cfg = & $ this -> class_cfg ; $ now = date ( 'Y-m-d H:i:s' ) ; $ id_group = $ this -> db -> select_one ( 'bbn_users' , 'id_group' , [ 'id' => $ id_user ] ) ; $ messages = $ this -> db -> get_rows ( " SELECT {$cfg['table']}.* FROM {$cfg['tables']['users']} RIGHT JOIN {$cfg['table']} ON {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_user']} AND {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']} WHERE ( {$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ? ) AND ( {$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ? ) AND ( ( {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ? OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ? ) OR ( {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL ) ) AND ( {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0 )" , $ now , $ now , hex2bin ( $ id_user ) , hex2bin ( $ id_group ) ) ; return $ this -> from_notes ( $ messages ) ; }
|
Gets all user s internal messages
|
11,294
|
public function check ( array $ insert , bool $ throw = true ) : bool { foreach ( $ this -> schema as $ key => $ rules ) { $ result = $ this -> processRules ( $ key , explode ( '|' , $ rules ) , $ insert ) ; if ( ! $ result [ 'status' ] && $ throw ) { throw new InvalidArgumentException ( sprintf ( $ result [ 'message' ] , $ key ) ) ; } } return $ result [ 'status' ] ?? true ; }
|
Check if given array is matching the schema .
|
11,295
|
public static function createFromFile ( string $ path , bool $ json = false ) : Schema { static :: fileExists ( $ path ) ; $ schema = $ json ? json_decode ( file_get_contents ( $ path ) , true ) : include $ path ; if ( ! is_array ( $ schema ) ) { throw new InvalidArgumentException ( '[createFromFile] method requires file that return a php array or json.' ) ; } return new static ( $ schema ) ; }
|
Create new Schema instance based on file .
|
11,296
|
private function processRules ( string $ key , array $ rules , array $ insert ) : array { $ status = true ; if ( ! isset ( $ insert [ $ key ] ) ) { $ status = false ; $ message = 'Schema key [%s] not present on insert.' ; } do { $ r = array_shift ( $ rules ) ; $ method = 'checkRule' . ucfirst ( $ r ) ; if ( ! in_array ( $ r , $ this -> rules ) ) { continue ; } if ( ! $ this -> { $ method } ( $ insert [ $ key ] ) ) { $ status = false ; $ message = $ this -> messages ( ) [ $ r ] ; break ; } } while ( count ( $ rules ) ) ; return compact ( 'status' , 'message' ) ; }
|
Parse each rules for given key of insert .
|
11,297
|
public function value ( ) { if ( is_null ( $ this -> value ) ) { if ( is_null ( $ this -> elem ) ) { $ this -> value = '' ; } else { $ this -> value = $ this -> elem -> textContent ; } } return $ this -> value ; }
|
Retorna o valor .
|
11,298
|
public function pad ( $ num , $ char = '0' , $ dir = STR_PAD_LEFT ) { $ this -> value = str_pad ( $ this -> value ( ) , $ num , $ char , $ dir ) ; return $ this ; }
|
Aplicar PAD .
|
11,299
|
private function inspectElementForVersioned ( \ SimpleXMLElement $ element , array & $ config , $ meta ) { foreach ( $ element as $ mapping ) { $ mappingDoctrine = $ mapping ; $ mapping = $ mapping -> children ( self :: GEDMO_NAMESPACE_URI ) ; $ isAssoc = $ this -> _isAttributeSet ( $ mappingDoctrine , 'field' ) ; $ field = $ this -> _getAttribute ( $ mappingDoctrine , $ isAssoc ? 'field' : 'name' ) ; if ( isset ( $ mapping -> versioned ) ) { if ( $ isAssoc && ! $ meta -> associationMappings [ $ field ] [ 'isOwningSide' ] ) { throw new InvalidMappingException ( "Cannot version [{$field}] as it is not the owning side in object - {$meta->name}" ) ; } $ config [ 'versioned' ] [ ] = $ field ; } } }
|
Searches mappings on element for versioned fields .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.