idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
12,000
|
public function getCountriesArray ( ) { $ return = json_decode ( $ this -> Country ) ; if ( empty ( $ return ) && isset ( $ this -> Country ) ) { $ return = [ $ this -> Country ] ; } return $ return ; }
|
Return an array of all associated countries
|
12,001
|
protected function getSpecification ( $ file , $ settings , $ artifact ) { return fphp \ Specification \ ChunkSpecification :: fromArrayAndSettings ( $ file , $ settings ) ; }
|
Returns a chunk specification from a plain settings array .
|
12,002
|
protected function compileJsonUpdateColumn ( $ key , JsonExpression $ value ) { $ path = explode ( '->' , $ key ) ; $ field = $ this -> wrapValue ( array_shift ( $ path ) ) ; $ accessor = '"$.' . implode ( '.' , $ path ) . '"' ; return "{$field} = json_set({$field}, {$accessor}, {$value->getValue()})" ; }
|
Prepares a JSON column being updated using the JSON_SET function .
|
12,003
|
public function parseGitAttributesLine ( $ line ) { $ parts = preg_split ( '#\s+#' , $ line ) ; if ( count ( $ parts ) != 2 ) { return null ; } if ( $ parts [ 1 ] === 'export-ignore' ) { return $ this -> generatePattern ( $ parts [ 0 ] ) ; } }
|
Callback parser which finds export - ignore rules in git attribute lines
|
12,004
|
public function hasData ( ) { if ( count ( $ this -> files ) >= 1 ) { if ( $ this -> files [ 0 ] === 'php://stdin' || filesize ( $ this -> files [ 0 ] ) > 0 ) { return true ; } } return false ; }
|
Returns whether the file set contains files
|
12,005
|
private function openFile ( $ isFirst = false ) { if ( $ this -> fp != null ) { fclose ( $ this -> fp ) ; $ this -> fp = null ; } $ file = $ isFirst ? current ( $ this -> files ) : next ( $ this -> files ) ; while ( $ this -> fp == null && $ file !== false ) { if ( $ file === 'php://stdin' || file_exists ( $ file ) ) { $ fp = fopen ( $ file , 'r' ) ; if ( $ fp !== false ) { $ this -> fp = $ fp ; return true ; } } $ file = next ( $ this -> files ) ; } return false ; }
|
Opens the next file in the set and returns true on success .
|
12,006
|
public function export ( ) { $ messages = implode ( "\n" , array_map ( [ $ this , 'formatMessage' ] , $ this -> messages ) ) . "\n" ; $ stdout = fopen ( 'php://stdout' , 'w' ) ; if ( $ stdout === false ) { throw new InvalidConfigException ( 'Unable to open stdout stream' ) ; } fwrite ( $ stdout , $ messages ) ; fclose ( $ stdout ) ; }
|
Write yii logs to stdout
|
12,007
|
public static function enterScope ( $ scope ) { if ( ! is_scalar ( $ scope ) ) { throw new \ InvalidArgumentException ( "Only scalars allowed as scope identifiers" ) ; } array_push ( self :: $ scope , $ scope ) ; list ( $ call ) = debug_backtrace ( 0 ) ; array_push ( self :: $ scopeChange , $ call ) ; }
|
Keeps track of scope
|
12,008
|
private function _make_power_operation ( $ sid , $ action ) { $ data = $ this -> _data ; $ data [ 'sid' ] = $ sid ; $ data [ 'action' ] = $ action ; try { return $ this -> _make_request ( self :: POWER_OP_URL , $ data , 'POST' ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( 'Something gone wrong' , 0 , $ e ) ; } return true ; }
|
Perform the power operation on the server
|
12,009
|
private static function fixHttpHeaderField ( $ header ) { if ( ! is_array ( $ header ) ) { $ header = explode ( "\r\n" , $ header ) ; } uasort ( $ header , function ( $ el ) { return preg_match ( '{^content-type}i' , $ el ) ? 1 : - 1 ; } ) ; return $ header ; }
|
A bug in PHP prevents the headers from correctly being sent when a content - type header is present and NOT at the end of the array
|
12,010
|
public function stop_track ( $ id_task , $ message = false , $ id_user = false ) { $ ok = false ; $ now = time ( ) ; if ( ( $ active_track = $ this -> get_active_track ( $ id_user ) ) && ( $ active_track [ 'id_task' ] === $ id_task ) ) { $ ok = true ; if ( ! empty ( $ message ) && ! ( $ id_note = $ this -> comment ( $ id_task , [ 'title' => _ ( 'Report tracker' ) . ' ' . date ( 'd M Y H:i' , strtotime ( $ active_track [ 'start' ] ) ) . ' - ' . date ( 'd M Y H:i' , $ now ) , 'text' => $ message ] ) ) ) { $ ok = false ; } if ( $ ok ) { $ ok = $ this -> db -> update ( 'bbn_tasks_sessions' , [ 'length' => $ now - strtotime ( $ active_track [ 'start' ] ) , 'id_note' => $ id_note ? : NULL ] , [ 'id' => $ active_track [ 'id' ] ] ) ; } } return ( bool ) $ ok ; }
|
Stops a track .
|
12,011
|
public function getRootId ( ) { if ( empty ( $ this -> hierarchy ) ) { throw new Exception \ LogicException ( 'The root item does not exist.' ) ; } reset ( $ this -> hierarchy ) ; $ id = key ( $ this -> hierarchy ) ; return $ id ; }
|
Returns the identifier of the root item
|
12,012
|
public function get ( array $ path ) { $ current = & $ this -> hierarchy ; foreach ( $ path as $ childId ) { if ( ! isset ( $ current [ $ childId ] ) ) { return [ ] ; } $ current = & $ current [ $ childId ] ; } return $ current ; }
|
Gets hierarchy by the path
|
12,013
|
public function remove ( array $ path ) { $ current = & $ this -> hierarchy ; $ pathLength = count ( $ path ) ; for ( $ i = 0 ; $ i < $ pathLength ; $ i ++ ) { if ( ! isset ( $ current [ $ path [ $ i ] ] ) ) { break ; } if ( $ i === $ pathLength - 1 ) { unset ( $ current [ $ path [ $ i ] ] ) ; break ; } $ current = & $ current [ $ path [ $ i ] ] ; } }
|
Removes the item from the hierarchy
|
12,014
|
public function createService ( ServiceLocatorInterface $ viewHelperManager ) { $ serviceLocator = $ viewHelperManager -> getServiceLocator ( ) ; $ config = $ serviceLocator -> has ( 'config' ) ? $ serviceLocator -> get ( 'config' ) : array ( ) ; if ( isset ( $ config [ 'dojo' ] ) ) { $ this -> config ( $ config [ 'dojo' ] ) ; } $ application = $ serviceLocator -> get ( 'application' ) ; $ debug = $ application -> getRequest ( ) -> getQuery ( 'debug' ) ; if ( $ debug !== null ) { $ this -> setDebug ( $ debug == 'true' ) ; } return $ this ; }
|
Create and configure service
|
12,015
|
public function setDebug ( $ flag = true ) { $ this -> debug = $ this -> getSession ( ) -> debug = ( bool ) $ flag ; if ( true == $ this -> debug ) { if ( isset ( $ this -> options [ 'debugOptions' ] ) && is_array ( $ this -> options [ 'debugOptions' ] ) ) { $ this -> initializeOptions ( $ this -> options [ 'debugOptions' ] ) ; } } else { $ this -> initializeOptions ( $ this -> options ) ; } }
|
Set debug flag
|
12,016
|
public function initialize ( ) { if ( true == $ this -> initialized ) { return ; } $ this -> initialized = true ; if ( $ this -> isEnabled ( ) ) { $ headScript = $ this -> getView ( ) -> plugin ( 'headScript' ) ; $ headScript -> prependFile ( $ this -> src ) ; $ options = array ( ) ; foreach ( array ( 'async' , 'parseOnLoad' ) as $ property ) { if ( null !== $ this -> $ property ) { $ options [ $ property ] = $ this -> $ property ; } } if ( ! empty ( $ this -> packages ) ) { $ options [ 'packages' ] = array_values ( $ this -> packages ) ; } if ( ! empty ( $ options ) ) { $ headScript -> prependScript ( "dojoConfig=" . json_encode ( $ options ) . ";" ) ; } if ( ! empty ( $ this -> modules ) ) { $ require = 'require(["' . implode ( '", "' , $ this -> modules ) . '"]);' ; $ headScript -> appendScript ( $ require ) ; } } }
|
Add Dojo configuration to HeadScript . Should only be called once .
|
12,017
|
private function getFolderContent ( $ dir ) { $ finder = Finder :: create ( ) -> ignoreVCS ( false ) -> ignoreDotFiles ( false ) -> depth ( 0 ) -> in ( $ dir ) ; return iterator_to_array ( $ finder ) ; }
|
Returns the folder content excluding dotfiles
|
12,018
|
public function import ( $ page , $ areaHandle , SimpleXMLElement $ blockNode ) { parent :: import ( $ page , $ areaHandle , $ blockNode ) ; }
|
Runs when a block is being imported .
|
12,019
|
public function add ( $ element , $ index = null ) { if ( $ index === null ) { $ this -> array [ $ this -> count ( ) ] = $ element ; } else { array_splice ( $ this -> array , $ index , 0 , $ element ) ; } return $ this ; }
|
Adds an element to that array
|
12,020
|
protected function doSort ( & $ array , $ cmp , callable $ usort , callable $ sort ) { if ( is_callable ( $ cmp ) ) { $ usort ( $ array , $ cmp ) ; } else if ( $ cmp instanceof Comparator ) { $ usort ( $ array , function ( $ a , $ b ) use ( $ cmp ) { return $ cmp -> compare ( $ a , $ b ) ; } ) ; } else { $ sort ( $ array ) ; } }
|
Internal sort function
|
12,021
|
public function find ( ) { if ( func_num_args ( ) == 1 ) { $ callback = func_get_arg ( 0 ) ; } else { $ query = func_get_arg ( 0 ) ; $ callback = func_get_arg ( 1 ) ; } foreach ( $ this -> array as $ element ) { $ return = func_num_args ( ) == 1 ? $ callback ( $ element ) : $ callback ( $ element , $ query ) ; if ( $ return ) { return $ element ; } } return null ; }
|
Searches the array with a given callback and returns the first element if found .
|
12,022
|
public function findLast ( ) { if ( func_num_args ( ) == 1 ) { $ callback = func_get_arg ( 0 ) ; } else { $ query = func_get_arg ( 0 ) ; $ callback = func_get_arg ( 1 ) ; } $ reverse = array_reverse ( $ this -> array , true ) ; foreach ( $ reverse as $ element ) { $ return = func_num_args ( ) == 1 ? $ callback ( $ element ) : $ callback ( $ element , $ query ) ; if ( $ return ) { return $ element ; } } return null ; }
|
Searches the array with a given callback and returns the last element if found .
|
12,023
|
public function findAll ( ) { if ( func_num_args ( ) == 1 ) { $ callback = func_get_arg ( 0 ) ; } else { $ query = func_get_arg ( 0 ) ; $ callback = func_get_arg ( 1 ) ; } $ array = [ ] ; foreach ( $ this -> array as $ k => $ element ) { $ return = func_num_args ( ) == 1 ? $ callback ( $ element ) : $ callback ( $ element , $ query ) ; if ( $ return ) { $ array [ $ k ] = $ element ; } } return new static ( $ array ) ; }
|
Searches the array with a given callback and returns all matching elements .
|
12,024
|
protected function registerPlugin ( $ name = '' ) { $ view = $ this -> getView ( ) ; if ( $ this -> clientOptions !== false ) { $ options = empty ( $ this -> clientOptions ) ? '' : Json :: encode ( $ this -> clientOptions ) ; $ js = "$(document).foundation({ '$name' : { $options } });" ; $ view -> registerJs ( $ js ) ; } if ( ! empty ( $ this -> clientFireMethods ) ) { $ js = [ ] ; foreach ( $ this -> clientFireMethods as $ method ) { $ js [ ] = "$(document).foundation('$name', '$method');" ; } $ view -> registerJs ( implode ( "\n" , $ js ) ) ; } }
|
Registers a specific Foundation plugin and call related methods
|
12,025
|
public function resolveOptions ( $ blockType , array $ options = [ ] ) { $ resolver = $ this -> getOptionResolver ( $ blockType ) ; return $ resolver -> resolve ( $ options ) ; }
|
Returns the combination of the default options for the given block type and the passed options
|
12,026
|
public function write ( ) { $ data = array ( ) ; $ dumper = new ArrayDumper ( ) ; foreach ( $ this -> getCanonicalPackages ( ) as $ package ) { $ data [ ] = $ dumper -> dump ( $ package ) ; } $ this -> file -> write ( $ data ) ; }
|
Writes writable repository .
|
12,027
|
public function append ( $ middleware , $ priority = 0 ) : Server { return $ this -> appendOnCondition ( $ middleware , $ this -> buildAlwaysTrue ( ) , $ priority ) ; }
|
Always adds a middleware to the stack .
|
12,028
|
public function appendOnPath ( $ middleware , string $ path , $ priority = 0 ) : Server { return $ this -> appendOnCondition ( $ middleware , $ this -> buildPathCondition ( $ path ) , $ priority ) ; }
|
Adds a middleware to the stack only if the request path matches .
|
12,029
|
public function appendOnCondition ( $ middleware , callable $ condition , $ priority = 0 ) : Server { if ( ! is_array ( $ middleware ) ) { $ middleware = [ $ middleware ] ; } foreach ( $ middleware as $ mw ) { $ this -> stack [ $ priority ] [ ] = [ $ condition , $ mw ] ; } return $ this ; }
|
Adds a middleware to the stack only if the condition returns true .
|
12,030
|
protected function setup_components ( ) { $ this -> load_components ( ) ; $ components = $ this -> get_components ( ) ; $ this -> set_component_parents ( $ components ) ; foreach ( $ components as $ component ) { if ( method_exists ( $ component , 'init' ) ) { $ component -> init ( ) ; } } }
|
Setup components and run init
|
12,031
|
protected function get_components ( ) { $ components = ( new \ ReflectionClass ( $ this ) ) -> getProperties ( ) ; $ components = array_map ( function ( $ property ) { return $ property -> name ; } , $ components ) ; $ components = array_filter ( $ components , [ $ this , 'is_component' ] ) ; $ components = array_map ( function ( $ component ) { $ getter = "get_{$component}" ; return $ this -> $ getter ( ) ; } , $ components ) ; return $ components ; }
|
Get all components with a getter and that uses the Component trait
|
12,032
|
protected function load ( $ component , $ args = [ ] ) { $ args = ( array ) $ args ; if ( ! property_exists ( $ this , $ component ) ) { return false ; } $ class = $ this -> $ component ; if ( ! is_string ( $ class ) ) { return false ; } if ( ! class_exists ( $ class ) ) { throw new \ Exception ( sprintf ( 'Can not find class "%s" for Component "%s" in parent Component "%s"' , $ class , $ component , __CLASS__ ) ) ; } $ this -> $ component = $ this -> container -> create ( $ class , $ args ) ; return true ; }
|
Load any property on the current component based on its string value as the class via the container
|
12,033
|
public function toSql ( Connection $ connection , Grammar $ grammar ) { $ this -> addImpliedCommands ( ) ; $ statements = [ ] ; foreach ( $ this -> commands as $ command ) { $ method = 'compile' . ucfirst ( $ command -> name ) ; if ( method_exists ( $ grammar , $ method ) ) { if ( ! is_null ( $ sql = $ grammar -> { $ method } ( $ this , $ command , $ connection ) ) ) { $ statements = array_merge ( $ statements , ( array ) $ sql ) ; } } } return $ statements ; }
|
Get the raw SQL statements for the blueprint .
|
12,034
|
public function render ( ) { $ items = [ 'header' => $ this -> header , 'description' => $ this -> description , 'breadcrumb' => $ this -> breadcrumb , 'content' => $ this -> build ( ) , ] ; return view ( 'merchant::content' , $ items ) -> render ( ) ; }
|
Render this content .
|
12,035
|
public function getToolTipTemplate ( $ field ) { if ( array_key_exists ( $ field , $ this -> toolTips ( ) ) ) { $ toolTip = Html :: tag ( 'span' , "{label}" , [ 'data-content' => $ this -> toolTips ( ) [ $ field ] , 'data-toggle' => 'popover' , 'data-trigger' => 'hover' , 'style' => 'cursor:help; border-bottom: 1px dashed #888' ] ) ; return "$toolTip \n{input}\n{hint}\n{error}" ; } return "{label}\n{input}\n{hint}\n{error}" ; }
|
Generate the tool tip template to use in form .
|
12,036
|
public function import ( $ modelName , $ defaultValues = [ ] , $ updateMultipleModel = false , $ queryConfigs = [ ] ) { $ isSuccessful = true ; $ sheetData = $ this -> arrayFromExcel ; $ this -> header = array_shift ( $ sheetData ) ; foreach ( $ sheetData as $ record ) { if ( $ updateMultipleModel ) { $ parentId = $ this -> getParentId ( $ queryConfigs [ 'parentModel' ] , $ queryConfigs [ 'parentKey' ] , $ record , $ modelName , $ defaultValues ) ; $ childModel = new $ queryConfigs [ 'childModel' ] ; foreach ( $ queryConfigs [ 'childModelArray' ] as $ key => $ value ) { if ( ! is_array ( $ value ) ) { $ childModel -> $ value = $ this -> getCellValue ( $ value , $ childModel , $ record , $ key , false ) ; } else { $ childModel -> $ value [ 'attribute' ] = $ this -> getCellValue ( $ value , $ childModel , $ record , $ key , false ) ; } } $ childModel -> $ queryConfigs [ 'childForeignKey' ] = $ parentId ; $ childModel -> save ( ) ; } else { $ isSuccessful = $ this -> createModel ( $ modelName , $ defaultValues , $ record ) ; } } return $ isSuccessful ; }
|
Import the excel to the model using active record
|
12,037
|
public function getCellValue ( $ value , $ model , $ record , $ key , $ isParent = true ) { if ( $ isParent ) { if ( isset ( $ model -> importSafeAttributes ( ) [ $ value ] ) && is_array ( $ model -> importSafeAttributes ( ) [ $ value ] ) ) { $ array = $ model -> importSafeAttributes ( ) [ $ value ] ; return $ array [ 'model' ] :: find ( ) -> andWhere ( [ $ array [ 'fieldName' ] => $ record [ $ key ] ] ) -> one ( ) -> id ; } return isset ( $ record [ $ key ] ) ? $ record [ $ key ] : '' ; } if ( ! is_array ( $ value ) ) { return $ record [ array_search ( $ key , $ this -> header ) ] ; } return $ value [ 'model' ] :: find ( ) -> andWhere ( [ $ value [ 'fieldName' ] => $ record [ array_search ( $ key , $ this -> header ) ] ] ) -> one ( ) -> id ; }
|
Get excel cell value . If the import safe attributes has the model declared it will grab the id from that model instead of the cell value
|
12,038
|
public function callbackFunction ( $ route = null , $ parameters = [ ] ) { if ( $ route === null || ! is_string ( $ route ) ) { $ uri = $ this -> request -> getUri ( ) ; } else { $ uri = $ this -> router -> generate ( $ route , $ parameters , Router :: ABSOLUTE_URL ) ; } $ result = parse_url ( $ uri ) ; if ( isset ( $ result [ 'query' ] ) ) { parse_str ( $ result [ 'query' ] , $ query ) ; $ query = array_diff_key ( $ query , [ 'callback' => null ] ) ; } else { return $ uri ; } return $ result [ 'scheme' ] . '://' . ( isset ( $ result [ 'user' ] ) ? $ result [ 'user' ] : '' ) . ( isset ( $ result [ 'pass' ] ) ? ':' . $ result [ 'pass' ] . '@' : '' ) . $ result [ 'host' ] . ( isset ( $ result [ 'port' ] ) ? ':' . $ result [ 'port' ] : '' ) . ( isset ( $ result [ 'path' ] ) ? $ result [ 'path' ] : '' ) . ( $ query != [ ] ? '?' . http_build_query ( $ query ) : '' ) . ( isset ( $ result [ 'fragment' ] ) ? '#' . $ result [ 'fragment' ] : '' ) ; }
|
Removes callbacks from query
|
12,039
|
protected function getCommandsByName ( Blueprint $ blueprint , $ name ) { return array_filter ( $ blueprint -> getCommands ( ) , function ( $ value ) use ( $ name ) { return $ value -> name === $ name ; } ) ; }
|
Get all of the commands with a given name .
|
12,040
|
public function activate ( Composer $ composer , IOInterface $ io , $ pluginName ) { $ plugin = $ this -> prepare ( __FUNCTION__ , $ composer , $ io , $ pluginName ) ; if ( $ plugin ) { $ result = $ this -> wp ( function ( ) use ( $ plugin ) { wp_cache_set ( 'plugins' , [ ] , 'plugins' ) ; return activate_plugin ( $ plugin ) ; } ) ; $ this -> succeeded ( __FUNCTION__ , $ pluginName , $ result === null ) ; } }
|
Activate a plugin .
|
12,041
|
public function deactivate ( Composer $ composer , IOInterface $ io , $ pluginName ) { $ plugin = $ this -> prepare ( __FUNCTION__ , $ composer , $ io , $ pluginName ) ; if ( $ plugin ) { $ result = $ this -> wp ( function ( ) use ( $ plugin ) { return deactivate_plugins ( $ plugin ) ; } ) ; $ this -> succeeded ( __FUNCTION__ , $ pluginName , $ result === null ) ; } }
|
Deactivate a plugin .
|
12,042
|
public function uninstall ( Composer $ composer , IOInterface $ io , $ pluginName ) { $ plugin = $ this -> prepare ( __FUNCTION__ , $ composer , $ io , $ pluginName ) ; if ( $ plugin ) { $ result = $ this -> wp ( function ( ) use ( $ plugin ) { return uninstall_plugin ( $ plugin ) ; } ) ; $ this -> succeeded ( __FUNCTION__ , $ pluginName , $ result === true || $ result === null ) ; } }
|
Uninstall a plugin .
|
12,043
|
protected function prepare ( $ action , Composer $ composer , IOInterface $ io , $ pluginName ) { $ this -> composer = $ composer ; $ this -> io = $ io ; if ( $ this -> isPluginExcluded ( $ action , $ pluginName ) ) { return $ this -> excluded ( $ action , $ pluginName ) && false ; } $ plugin = $ this -> getPlugin ( $ pluginName ) ; if ( ! $ plugin ) { return $ this -> failed ( $ action , $ pluginName ) && false ; } $ this -> executing ( $ action , $ pluginName ) ; return $ plugin ; }
|
Prepare plugin interaction .
|
12,044
|
protected function getPlugin ( $ plugin ) { $ path = $ this -> plugin -> getPublicDirectory ( ) . '/plugins/' . $ plugin ; if ( file_exists ( $ path ) && is_dir ( $ path ) ) { $ files = scandir ( $ path ) ; foreach ( $ files as $ file ) { $ pattern = defined ( 'HHVM_VERSION' ) ? '/\.(php|hh)$/' : '/\.php$/' ; if ( preg_match ( $ pattern , $ file ) ) { $ content = file_get_contents ( $ path . '/' . $ file ) ; if ( preg_match ( '/\/\*(?!.*\*\/.*Plugin Name).*Plugin Name/si' , $ content ) ) { return $ plugin . '/' . $ file ; } } } } if ( file_exists ( $ path . '.php' ) ) { return $ plugin . '.php' ; } if ( defined ( 'HHVM_VERSION' ) && file_exists ( $ path . '.hh' ) ) { return $ plugin . '.hh' ; } return false ; }
|
Get the main plugin file for a plugin .
|
12,045
|
protected function executing ( $ action , $ plugin ) { $ this -> io -> write ( ' - ' . ucfirst ( $ this -> getActionExecuting ( $ action ) ) . ' plugin <info>' . $ plugin . '</info>' ) ; $ this -> io -> write ( '' ) ; }
|
Write action executing .
|
12,046
|
protected function wp ( Closure $ cmd ) { $ cmd = new ReflectionFunction ( $ cmd ) ; $ code = implode ( array_slice ( file ( $ cmd -> getFileName ( ) ) , ( $ startLine = $ cmd -> getStartLine ( ) - 1 ) , $ cmd -> getEndLine ( ) - $ startLine ) ) ; preg_match ( '/\\{(.*)\\}/s' , $ code , $ body ) ; $ vars = $ cmd -> getStaticVariables ( ) ; $ cmd = trim ( preg_replace_callback ( '/return(?:;|\s((?:[^;(]*(?:\(.*\))?)+);)/s' , function ( $ matches ) { if ( ! empty ( $ matches [ 1 ] ) ) { return "return print 'OUTPUT>>>' . serialize({$matches[1]});" ; } return "return print 'OUTPUT>>>' . serialize(null);" ; } , $ body [ 1 ] ) ) ; $ config = [ '__host' => env ( 'DB_HOST' , 'localhost' ) , '__name' => env ( 'DB_NAME' , 'homestead' ) , '__user' => env ( 'DB_USER' , 'homestead' ) , '__pass' => env ( 'DB_PASS' , 'secret' ) , '__abspath' => $ this -> plugin -> getPublicDirectory ( ) . '/wp/' , '__wp' => dirname ( __FILE__ ) . '/wordpress.php' , ] ; $ config = serialize ( $ config ) ; $ vars = serialize ( $ vars ) ; $ p = new PhpProcess ( "<?php extract(unserialize('$config')); try { \$db = new PDO('mysql:host=' . \$__host . ';dbname=' . \$__name, \$__user, \$__pass); } catch (PDOException \$e) { if (\$__host == 'localhost') { \$__host = '127.0.0.1'; } \$db = new PDO('mysql:host=' . \$__host . ';port=33060;dbname=' . \$__name, \$__user, \$__pass); \$__host = \$__host . ':33060'; } catch (PDOException \$e) { return; } define('DB_HOST', \$__host); define('ABSPATH', \$__abspath); \$_SERVER = [ 'HTTP_HOST' => 'http://mysite.com', 'SERVER_NAME' => 'http://mysite.com', 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET' ]; //require the WP bootstrap require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-load.php'; extract(unserialize('$vars')); $cmd " ) ; $ p -> run ( ) ; if ( preg_match ( '/OUTPUT>>>(.*)$/s' , $ p -> getOutput ( ) , $ matches ) ) { return unserialize ( $ matches [ 1 ] ) ; } }
|
Run a closure in the WordPress environment .
|
12,047
|
public function store ( $ contentId ) { $ content = $ this -> repository -> getById ( $ contentId ) ; if ( ! empty ( $ content ) ) { $ this -> authorize ( 'create' , $ content ) ; $ this -> authorize ( 'update' , $ content ) ; if ( $ content -> type != 'category' ) { $ input = $ this -> validator -> validate ( 'create' ) ; $ route = $ this -> repository -> createRoute ( $ content , $ input [ 'lang_code' ] , $ input [ 'url' ] ) ; return $ this -> respondWithSuccess ( $ route , new RouteTransformer ) ; } else { throw new RepositoryValidationException ( "You can't change category url" , 500 ) ; } } return $ this -> respondNotFound ( ) ; }
|
Stores newly created route for specified content entity in database .
|
12,048
|
public static function lazyConnection ( $ dsn , $ name = false ) { Eresus_Kernel :: log ( __METHOD__ , LOG_DEBUG , '("%s", %s)' , $ dsn , $ name ) ; self :: $ lazyConnectionDSNs [ $ name ] = $ dsn ; }
|
Configures lazy connection to DB
|
12,049
|
public static function configureObject ( $ name ) { Eresus_Kernel :: log ( __METHOD__ , LOG_DEBUG , '(%s)' , $ name ) ; if ( ! isset ( self :: $ lazyConnectionDSNs [ $ name ] ) ) { throw new Eresus_DB_Exception ( 'DSN for lazy connection "' . $ name . '" not found' ) ; } $ dsn = self :: $ lazyConnectionDSNs [ $ name ] ; $ db = self :: connect ( $ dsn , $ name ) ; return $ db ; }
|
eZ Components lazy init
|
12,050
|
public function subst ( $ query ) { foreach ( $ this -> values as $ key => $ value ) { $ query = preg_replace ( "/$key(\s|,|$)/" , "$value$1" , $ query ) ; } return $ query ; }
|
Substitute values in query
|
12,051
|
public function takeSnapShot ( $ user_agent = 'Surebert Kamera' , $ options = Array ( ) ) { $ ch = curl_init ( $ this -> url . '/jpg/1/image.jpg?timestamp=' . time ( ) ) ; curl_setopt ( $ ch , CURLOPT_HTTPAUTH , CURLAUTH_DIGEST ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , $ this -> uname . ':' . $ this -> pass ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , 2 ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , $ user_agent ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , 2 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; foreach ( $ options as $ k => $ v ) { curl_setopt ( $ ch , $ k , $ v ) ; } return curl_exec ( $ ch ) ; }
|
Retrives a current snapshot
|
12,052
|
public function saveSnapshot ( $ dir ) { if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0775 , true ) ; } $ jpeg = $ this -> takeSnapShot ( ) ; $ file = $ dir . '/' . date ( 'Y_m_d_H_i_s' ) . '.jpg' ; if ( file_put_contents ( $ file , $ jpeg ) ) { return $ file ; } return '' ; }
|
Retrieves and stores a snapshot by date
|
12,053
|
protected function checkEnvironment ( InputInterface $ input , OutputInterface $ output ) { $ env = $ input -> getParameterOption ( [ '--env' , '-e' ] , getenv ( 'SYMFONY_ENV' ) ? : 'dev' ) ; if ( 'test' != $ env ) { $ output -> writeln ( '<bg=red> </bg=red> <fg=red>Warning, make sure your tests are being run against testing environments</fg=red>' ) ; } return $ this ; }
|
Check environment . If not test add a notice
|
12,054
|
private function sanitize ( $ filename ) { $ filename = preg_replace ( '/[^A-Za-z0-9\-\._]/' , '.' , ( string ) $ filename ) ; return trim ( substr ( preg_replace ( '/[_\.\-]{2,}/' , '.' , $ filename ) , 0 , 40 ) , '._-' ) ; }
|
Sanitizes filename .
|
12,055
|
public function pane ( ) { global $ step ; require_privs ( 'rah_backup' ) ; $ steps = array ( 'browser' => false , 'create' => true , 'download' => true , 'multi_edit' => true , ) ; if ( ! $ step || ! bouncer ( $ step , $ steps ) || ! has_privs ( 'rah_backup_' . $ step ) ) { $ step = 'browser' ; } $ this -> $ step ( ) ; }
|
Delivers panels .
|
12,056
|
public function head ( ) { global $ event , $ theme ; if ( $ event != 'rah_backup' ) { return ; } gTxtScript ( array ( 'rah_backup_confirm_backup' , ) ) ; $ msg = array ( 'backup' => escape_js ( $ theme -> announce_async ( gTxt ( 'rah_backup_taking' ) ) ) , 'error' => escape_js ( $ theme -> announce_async ( gTxt ( 'rah_backup_task_error' ) ) ) , ) ; $ js = <<<EOF $(function () { $('.rah_backup_take').on('click', function (e) { e.preventDefault(); var obj = $(this), href, spinner; if (obj.hasClass('disabled') || !verify(textpattern.gTxt('rah_backup_confirm_backup'))) { return false; } $.globalEval('{$msg['backup']}'); spinner = $('<span> <span class="spinner"></span> </span>'); href = obj.attr('href'); obj.addClass('disabled').attr('href', '#').after(spinner); $.ajax('index.php', { data: href.substr(1) + '&app_mode=async', dataType: 'script', timeout: 1800000 }).fail(function () { $.globalEval('{$msg['error']}'); }).always(function () { obj.removeClass('disabled').attr('href', href); spinner.remove(); }); }); });EOF ; echo script_js ( $ js ) ; }
|
Adds the panel s CSS and JavaScript to the < ; head> ; .
|
12,057
|
private function create ( ) { try { callback_event ( 'rah_backup.backup' ) ; } catch ( Rah_Backup_Exception $ e ) { $ this -> browser ( array ( $ e -> getMessage ( ) , E_ERROR ) ) ; return ; } catch ( Exception $ e ) { $ this -> browser ( array ( txpspecialchars ( $ e -> getMessage ( ) ) , E_ERROR ) ) ; return ; } $ this -> browser ( gTxt ( 'rah_backup_done' ) ) ; }
|
The panel that creates new backups .
|
12,058
|
private function download ( ) { $ file = ( string ) gps ( 'file' ) ; try { $ backups = $ this -> getBackups ( ) ; } catch ( Exception $ e ) { } if ( empty ( $ backups ) || ! isset ( $ backups [ $ file ] ) ) { $ this -> browser ( array ( gTxt ( 'rah_backup_can_not_download' ) , E_ERROR ) ) ; return ; } extract ( $ backups [ $ file ] ) ; @ ini_set ( 'zlib.output_compression' , 'Off' ) ; @ set_time_limit ( 0 ) ; @ ignore_user_abort ( true ) ; ob_clean ( ) ; header ( 'Content-Description: File Download' ) ; header ( 'Content-Type: application/octet-stream' ) ; header ( 'Content-Disposition: attachment; filename="' . $ name . '"; size="' . $ size . '"' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Expires: 0' ) ; header ( 'Cache-Control: private' ) ; header ( 'Content-Length: ' . $ size ) ; ob_flush ( ) ; flush ( ) ; if ( $ f = fopen ( $ path , 'rb' ) ) { while ( ! feof ( $ f ) && connection_status ( ) == 0 ) { echo fread ( $ f , 1024 * 64 ) ; ob_flush ( ) ; flush ( ) ; } fclose ( $ f ) ; } exit ; }
|
Streams backups for downloading .
|
12,059
|
private function multi_edit ( ) { extract ( psa ( array ( 'selected' , 'edit_method' , ) ) ) ; require_privs ( 'rah_backup_' . ( ( string ) $ edit_method ) ) ; if ( ! is_string ( $ edit_method ) || empty ( $ selected ) || ! is_array ( $ selected ) ) { $ this -> browser ( array ( gTxt ( 'rah_backup_select_something' ) , E_WARNING ) ) ; return ; } $ method = 'multi_option_' . $ edit_method ; if ( ! method_exists ( $ this , $ method ) ) { $ method = 'browse' ; } $ this -> $ method ( ) ; }
|
Multi - edit handler .
|
12,060
|
private function multi_option_delete ( ) { $ selected = ps ( 'selected' ) ; $ deleted = array ( ) ; try { foreach ( $ this -> getBackups ( ) as $ name => $ file ) { if ( in_array ( $ name , $ selected , true ) ) { $ deleted [ $ name ] = $ file [ 'path' ] ; @ unlink ( $ file [ 'path' ] ) ; } } } catch ( Exception $ e ) { } callback_event ( 'rah_backup.deleted' , '' , 0 , array ( 'files' => $ deleted , ) ) ; $ this -> browser ( gTxt ( 'rah_backup_removed' ) ) ; }
|
Deletes selected backups .
|
12,061
|
private function getBackups ( $ sort = 'name' , $ direction = 'asc' , $ offset = 0 , $ limit = null ) { $ directory = txpath . '/' . get_pref ( 'rah_backup_path' ) ; if ( ! get_pref ( 'rah_backup_path' ) || ! file_exists ( $ directory ) || ! is_dir ( $ directory ) || ! is_readable ( $ directory ) ) { throw new Rah_Backup_Exception ( gTxt ( 'rah_backup_dir_not_readable' , array ( '{path}' => $ directory ) ) ) ; } $ order = $ files = array ( ) ; $ sort_crit = array ( 'name' => SORT_REGULAR , 'ext' => SORT_REGULAR , 'date' => SORT_NUMERIC , 'size' => SORT_NUMERIC , 'type' => SORT_NUMERIC , ) ; if ( ! is_string ( $ sort ) || ! isset ( $ sort_crit [ $ sort ] ) ) { $ sort = 'name' ; } foreach ( new DirectoryIterator ( $ directory ) as $ file ) { if ( ! $ file -> isFile ( ) || ! preg_match ( '/^[a-z0-9\-_\.]+\.(sql\.gz|tar\.gz)$/i' , $ file -> getFilename ( ) ) ) { continue ; } $ backup = array ( 'path' => $ file -> getPathname ( ) , 'name' => $ file -> getFilename ( ) , 'ext' => $ file -> getExtension ( ) , 'date' => $ file -> getMTime ( ) , 'size' => $ file -> getSize ( ) , 'type' => self :: BACKUP_FILESYSTEM , 'readable' => $ file -> isReadable ( ) , 'writable' => $ file -> isWritable ( ) , ) ; if ( preg_match ( '/\.sql\.gz$/i' , $ backup [ 'name' ] ) ) { $ backup [ 'type' ] = self :: BACKUP_DATABASE ; } $ files [ $ backup [ 'name' ] ] = $ backup ; $ order [ $ backup [ 'name' ] ] = $ backup [ $ sort ] ; } if ( ! $ files ) { return array ( ) ; } array_multisort ( $ order , $ sort_crit [ $ sort ] , $ files ) ; if ( $ direction === 'desc' ) { $ files = array_reverse ( $ files ) ; } return array_slice ( $ files , $ offset , $ limit ) ; }
|
Gets a list of backups .
|
12,062
|
public function injectStylesAndScripts ( array $ params , PageLayoutController $ ref ) : string { $ jsCallbackFunction = null ; if ( $ ref -> MOD_SETTINGS [ 'function' ] === '2' ) { $ jsCallbackFunction = 'function(ColumnLayout) { ColumnLayout.settings.isTranslationView = true; }' ; } $ ref -> getModuleTemplate ( ) -> getPageRenderer ( ) -> loadRequireJsModule ( 'TYPO3/CMS/ColumnLayout/ColumnLayout' , $ jsCallbackFunction ) ; $ ref -> getModuleTemplate ( ) -> getPageRenderer ( ) -> addCssFile ( 'EXT:column_layout/Resources/Public/Css/column_layout.css' ) ; $ ref -> getModuleTemplate ( ) -> getPageRenderer ( ) -> addCssInlineBlock ( 'column-layout' , implode ( LF , $ this -> inlineStyles ) , true ) ; return '' ; }
|
Hook for header rendering of the PageLayoutController to inject stylesheet required for custom column layout display .
|
12,063
|
protected function skipRendering ( PageLayoutView & $ parentObject , array $ row ) : bool { $ tsConf = $ parentObject -> modTSconfig [ 'column_layout' ] ?? [ ] ; return ( $ tsConf [ 'hidePreview' ] ?? false || empty ( $ row [ 'tx_column_layout_column_config' ] ) || $ tsConf [ 'disabled' ] ?? false ) ; }
|
Checks if the rendering of the column markup should be skipped .
|
12,064
|
public function get ( ) { if ( ! isset ( $ this -> request -> args [ 0 ] ) ) { exit ; } $ url = $ this -> request -> args [ 0 ] ; $ query_string = http_build_query ( $ this -> request -> get ) ; $ destination_url = $ url . ( $ query_string ? '?' . $ query_string : '' ) ; if ( $ this -> onBeforeGet ( $ destination_url ) === false ) { return false ; } if ( $ this -> log_to_file ) { $ logger = new \ sb \ Logger \ CommandLine ( ) ; $ log_name = preg_replace ( "~[^\w+]~" , "_" , get_called_class ( ) ) ; $ logger -> { $ log_name } ( json_encode ( [ "ip" => \ sb \ Gateway :: $ remote_addr , "url" => $ destination_url , "get" => $ query_string , "post" => $ this -> request -> post ] ) ) ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ destination_url ) ; curl_setopt ( $ ch , CURLOPT_HEADERFUNCTION , array ( $ this , 'headerCallBack' ) ) ; curl_setopt ( $ ch , CURLOPT_USERAGENT , $ this -> agent ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this -> timeout ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , $ this -> timeout ) ; if ( count ( $ this -> request -> post ) ) { curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ this -> request -> post ) ; } curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; if ( $ this -> ignore_ssl_errors ) { curl_setopt ( $ ch , CURLOPT_SSL_VERIFYHOST , false ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; } foreach ( $ this -> curl_opts as $ key => $ val ) { curl_setopt ( $ ch , $ key , $ val ) ; } return curl_exec ( $ ch ) ; }
|
proxies request and responds
|
12,065
|
protected function headerCallBack ( $ ch , $ data ) { if ( ! is_null ( $ data ) ) { if ( preg_match ( "~^HTTP/.*? 404~" , $ data ) ) { header ( trim ( $ data ) ) ; while ( ob_get_level ( ) > 0 ) { ob_end_flush ( ) ; } } if ( preg_match ( "~^Content-disposition~" , $ data ) ) { header ( str_replace ( "filename=" , 'filename="' , trim ( $ data ) ) . '"' ) ; while ( ob_get_level ( ) > 0 ) { ob_end_flush ( ) ; } } if ( preg_match ( "~^Content-Type~i" , $ data ) ) { header ( trim ( $ data ) ) ; while ( ob_get_level ( ) > 0 ) { ob_end_flush ( ) ; } } } return strlen ( $ data ) ; }
|
Called to process headers from URL being proxied
|
12,066
|
function auth ( $ proxy = NULL , $ attr = array ( ) , array $ reqd = NULL ) { $ fw = Base :: instance ( ) ; $ root = $ fw -> get ( 'SCHEME' ) . '://' . $ fw -> get ( 'HOST' ) ; if ( empty ( $ this -> args [ 'trust_root' ] ) ) $ this -> args [ 'trust_root' ] = $ root . $ fw -> get ( 'BASE' ) . '/' ; if ( empty ( $ this -> args [ 'return_to' ] ) ) $ this -> args [ 'return_to' ] = $ root . $ _SERVER [ 'REQUEST_URI' ] ; $ this -> args [ 'mode' ] = 'checkid_setup' ; if ( $ this -> url = $ this -> discover ( $ proxy ) ) { if ( $ attr ) { $ this -> args [ 'ns.ax' ] = 'http://openid.net/srv/ax/1.0' ; $ this -> args [ 'ax.mode' ] = 'fetch_request' ; foreach ( $ attr as $ key => $ val ) $ this -> args [ 'ax.type.' . $ key ] = $ val ; $ this -> args [ 'ax.required' ] = is_string ( $ reqd ) ? $ reqd : implode ( ',' , $ reqd ) ; } $ var = array ( ) ; foreach ( $ this -> args as $ key => $ val ) $ var [ 'openid.' . $ key ] = $ val ; $ fw -> reroute ( $ this -> url . '?' . http_build_query ( $ var ) ) ; } return FALSE ; }
|
Initiate OpenID authentication sequence ; Return FALSE on failure or redirect to OpenID provider URL
|
12,067
|
public function send ( Message $ message ) { $ buildMessage = $ this -> buildMessage ( $ message ) ; $ this -> streamSocket -> connect ( ) ; $ bytesSend = $ this -> streamSocket -> write ( $ buildMessage ) ; if ( strlen ( $ buildMessage ) !== $ bytesSend ) { $ this -> streamSocket -> disconnect ( ) ; throw new ConnectionExceptionImpl ( ) ; } usleep ( self :: SEND_INTERVAL ) ; }
|
Send a message without waiting on response .
|
12,068
|
public static function check ( ) { return ( \ is_object ( self :: $ db ) && \ is_object ( self :: $ dbs ) && self :: $ db -> check ( ) && self :: $ dbs -> check ( ) ) ; }
|
Checks if the initialization has been all right
|
12,069
|
public function deserialize ( StringLiteral $ data ) { $ data = json_decode ( $ data -> toNative ( ) , $ this -> assoc ) ; if ( null === $ data ) { throw new NotWellFormedException ( 'Invalid JSON' ) ; } return $ data ; }
|
Decodes a JSON string into a generic PHP object .
|
12,070
|
public function login ( $ serviceName , AbstractUser $ response ) { $ userId = $ this -> repo -> getUserIdBySocialId ( $ response -> id , $ serviceName ) ; if ( auth ( ) -> check ( ) ) { $ user = auth ( ) -> user ( ) ; if ( $ userId ) { session ( ) -> put ( 'url.intended' , route ( 'connectedServices' ) ) ; throw new SocialException ( trans ( 'gzero-social::common.service_already_connected_message' , [ 'service_name' => title_case ( $ serviceName ) ] ) ) ; } else { $ this -> repo -> addUserSocialAccount ( $ user , $ serviceName , $ response ) ; } } else { if ( $ userId ) { $ this -> auth -> loginUsingId ( $ userId ) ; } else { $ user = $ this -> repo -> createNewUser ( $ serviceName , $ response ) ; $ this -> auth -> login ( $ user ) ; session ( ) -> put ( 'showWelcomePage' , true ) ; session ( ) -> put ( 'url.intended' , route ( 'account.welcome' , [ 'method' => title_case ( $ serviceName ) ] ) ) ; } } }
|
Login using social service .
|
12,071
|
public static function getUrlStatusCode ( $ url ) { $ epi_curl_checker = EpiCurl :: getInstance ( ) ; $ url_check = $ epi_curl_checker -> addURL ( $ url ) ; return $ url_check -> code ; }
|
This function obtains an HTTP status code from a given URL .
|
12,072
|
public function prepare ( $ command , array $ arguments = array ( ) ) { $ commandline = $ command ; foreach ( $ arguments as $ option => $ value ) { if ( is_bool ( $ value ) ) { if ( $ value === true ) { $ commandline .= ' ' . $ option ; } } else { $ seperator = ' ' ; if ( ! is_integer ( $ option ) ) { $ commandline .= ' ' . $ option ; if ( substr ( $ option , - 1 , 1 ) == '=' ) { $ seperator = '' ; } } $ commandline .= $ seperator . ProcessUtils :: escapeArgument ( $ value ) ; } } return $ commandline ; }
|
Prepares a commandline
|
12,073
|
protected function addChild ( $ mom_node , $ name , $ value = '' ) { return $ this -> oai_pmh -> addChild ( $ mom_node , $ name , $ value ) ; }
|
A worker function for easily adding a newly created node to current XML Doc .
|
12,074
|
protected function create_regObject ( $ group , $ key , $ originatingSource ) { $ regObj_node = $ this -> addChild ( $ this -> working_node , 'registryObject' ) ; $ regObj_node -> setAttribute ( 'group' , $ group ) ; $ this -> addChild ( $ regObj_node , 'key' , $ key ) ; $ this -> addChild ( $ regObj_node , 'originatingSource' , $ originatingSource ) ; $ this -> working_node = $ regObj_node ; }
|
Create a single registryObject node . Each set has its own structure but they all have an attribute of group a key node and an originatingSource node . The newly created node will be used as the working node .
|
12,075
|
protected function create_dcs_node ( $ set_name , $ set_type ) { $ this -> working_node = $ this -> addChild ( $ this -> working_node , $ set_name ) ; $ this -> working_node -> setAttribute ( 'type' , $ set_type ) ; }
|
RIF - CS node is the content node of RIF - CS metadata node which starts from regObjects . Each set supportted in RIF - CS has its own content model . The created node will be used as the root node of this record for following nodes will be created .
|
12,076
|
protected function leadGIF ( ) { $ exif = exif_imagetype ( $ this -> file ) === IMAGETYPE_GIF ; if ( $ exif ) { return $ this -> closeCase ( "gif" , "image/gif" ) ; } return null ; }
|
Checks if thise file is a GIF .
|
12,077
|
protected function leadJPG ( ) { $ exif = exif_imagetype ( $ this -> file ) === IMAGETYPE_JPEG ; if ( $ exif ) { return $ this -> closeCase ( "jpg" , "image/jpg" ) ; } return null ; }
|
Checks if thise file is a JPG .
|
12,078
|
protected function leadPNG ( ) { $ exif = exif_imagetype ( $ this -> file ) === IMAGETYPE_PNG ; if ( $ exif ) { return $ this -> closeCase ( "png" , "image/png" ) ; } return null ; }
|
Checks if thise file is a PNG .
|
12,079
|
protected function leadSWF ( ) { $ exif = exif_imagetype ( $ this -> file ) ; $ flash = ( $ exif === IMAGETYPE_SWF || $ exif === IMAGETYPE_SWC ) ; if ( $ exif ) { return $ this -> closeCase ( "swf" , "application/x-shockwave-flash" ) ; } return null ; }
|
Checks if the file is a SWF .
|
12,080
|
public function getAdapter ( ) { if ( $ this -> repositoryAdapter instanceof AdapterInterface ) { return $ this -> repositoryAdapter ; } foreach ( $ this -> adapters as $ adapterClass ) { if ( class_exists ( $ adapterClass ) === false || in_array ( 'Accompli\Chrono\Adapter\AdapterInterface' , class_implements ( $ adapterClass ) ) === false ) { continue ; } $ adapter = new $ adapterClass ( $ this -> repositoryUrl , $ this -> repositoryDirectory , $ this -> processExecutor ) ; if ( $ adapter -> supportsRepository ( ) ) { return $ adapter ; } } }
|
Returns the supported adapter for the repository .
|
12,081
|
public function onKernelTerminate ( PostResponseEvent $ event ) { if ( ! $ event -> getRequest ( ) -> hasSession ( ) ) { return ; } $ session = $ event -> getRequest ( ) -> getSession ( ) ; $ this -> registry -> refreshLastUsed ( $ session -> getId ( ) , $ session -> getMetadataBag ( ) -> getLastUsed ( ) ) ; }
|
Refresh the last used timestamp for the given session if registered .
|
12,082
|
public function exec ( $ command , $ timeout = 30 , $ with_login_env = true ) { stream_set_timeout ( $ this -> shell , $ timeout ) ; if ( $ with_login_env ) { $ command = 'bash -l ' . $ command ; } return fwrite ( $ this -> shell , $ command . PHP_EOL ) ; }
|
Execute a command on the interactive shell
|
12,083
|
public function get ( $ format ) { if ( ! array_key_exists ( $ format , $ this -> encoders ) ) { throw new \ RuntimeException ( sprintf ( 'The expression encoder for "%s" formatting was not found.' , $ format ) ) ; } return $ this -> encoders [ $ format ] ; }
|
Returns the encoder for the given format
|
12,084
|
public function handle ( NotificationInterface $ notification , $ level ) { if ( $ notification instanceof AttributeAwareInterface ) { $ options = $ notification -> attributes ( ) ; } else { $ options = [ ] ; } if ( $ notification instanceof TitleAwareInterface ) { $ options [ 'header' ] = $ notification -> title ( ) ; } $ variable = [ 'message' => $ notification -> message ( ) , 'type' => isset ( $ this -> levelMapping [ $ level ] ) ? $ this -> levelMapping [ $ level ] : self :: STANDARD , 'options' => $ options ] ; $ current = $ this -> smarty -> getTemplateVars ( $ this -> var ) ; if ( ! $ current ) { $ this -> smarty -> assign ( $ this -> var , [ $ variable ] ) ; } else { $ this -> smarty -> append ( $ this -> var , $ variable ) ; } return true ; }
|
Handle a notification .
|
12,085
|
public static function inline ( $ value , $ options = array ( ) ) { $ filter = new static ( ) ; $ filter -> setOptions ( $ options ) ; return $ filter -> filter ( $ value ) ; }
|
Static function to execute filter
|
12,086
|
public static function cleanFileName ( $ str ) { preg_match ( '~\.\w{1,4}$~' , $ str , $ ext ) ; $ str = preg_replace ( '~\.\w{1,4}$~' , '' , $ str ) ; return str_replace ( Array ( ' ' , '.' , '-' ) , "_" , $ str ) . $ ext [ 0 ] ; }
|
Cleans up file names and removes extraneous spaces symbols etc
|
12,087
|
public static function stripMicrosoftChars ( $ str ) { $ chars = array ( chr ( 133 ) => '...' , chr ( 145 ) => "'" , chr ( 146 ) => "'" , chr ( 147 ) => '"' , chr ( 148 ) => '"' , chr ( 149 ) => '*' , chr ( 150 ) => '-' , chr ( 151 ) => '-' , chr ( 165 ) => '*' , chr ( 201 ) => '...' , chr ( 208 ) => '-' , chr ( 209 ) => '-' , chr ( 210 ) => '"' , chr ( 211 ) => '"' , chr ( 212 ) => '\'' , chr ( 213 ) => '\'' , ) ; return strtr ( $ str , $ chars ) ; }
|
Removes microsoft characters and replace them with their ascii counterparts
|
12,088
|
public static function truncate ( $ str , $ maxlength = 20 ) { if ( strlen ( $ str ) > $ maxlength ) { $ str = substr ( $ str , 0 , $ maxlength - 3 ) . '...' ; } return $ str ; }
|
Truncates a string to a certain length and right padswith ...
|
12,089
|
protected function getConverter ( InputInterface $ input ) { $ converter = parent :: getConverter ( $ input ) ; $ this -> configureConverterFromInputOptions ( $ converter , $ input ) ; return $ converter ; }
|
Returns and configures the converter for this operation .
|
12,090
|
public function generateHeaders ( ) { if ( $ this -> contentDisposition !== null && ( $ this -> contentDisposition instanceof ezcMailContentDispositionHeader ) ) { $ cdHeader = $ this -> contentDisposition ; $ cd = "{$cdHeader->disposition}" ; if ( $ cdHeader -> fileName !== null ) { $ fileInfo = null ; if ( $ cdHeader -> fileNameCharSet !== null ) { $ fileInfo .= "*0*=\"{$cdHeader->fileNameCharSet}" ; if ( $ cdHeader -> fileNameLanguage !== null ) { $ fileInfo .= "'{$cdHeader->fileNameLanguage}'" ; } else { $ fileInfo .= "''" ; } } if ( $ fileInfo !== null ) { $ cd .= "; filename{$fileInfo}{$cdHeader->fileName}\"" ; } else { $ cd .= "; filename=\"{$cdHeader->fileName}\"" ; } } if ( $ cdHeader -> creationDate !== null ) { $ cd .= "; creation-date=\"{$cdHeader->creationDate}\"" ; } if ( $ cdHeader -> modificationDate !== null ) { $ cd .= "; modification-date=\"{$cdHeader->modificationDate}\"" ; } if ( $ cdHeader -> readDate !== null ) { $ cd .= "; read-date=\"{$cdHeader->readDate}\"" ; } if ( $ cdHeader -> size !== null ) { $ cd .= "; size={$cdHeader->size}" ; } foreach ( $ cdHeader -> additionalParameters as $ addKey => $ addValue ) { $ cd .= "; {$addKey}=\"{$addValue}\"" ; } $ this -> setHeader ( 'Content-Disposition' , $ cd ) ; } $ text = "" ; foreach ( $ this -> headers -> getCaseSensitiveArray ( ) as $ header => $ value ) { if ( is_array ( $ value ) ) { $ value = $ value [ 0 ] ; } $ charset = $ this -> getHeaderCharset ( $ header ) ; switch ( strtolower ( $ charset ) ) { case 'us-ascii' : $ value = ezcMailHeaderFolder :: foldAny ( $ value ) ; break ; case 'iso-8859-1' : case 'iso-8859-2' : case 'iso-8859-3' : case 'iso-8859-4' : case 'iso-8859-5' : case 'iso-8859-6' : case 'iso-8859-7' : case 'iso-8859-8' : case 'iso-8859-9' : case 'iso-8859-10' : case 'iso-8859-11' : case 'iso-8859-12' : case 'iso-8859-13' : case 'iso-8859-14' : case 'iso-8859-15' : case 'iso-8859-16' : case 'windows-1250' : case 'windows-1251' : case 'windows-1252' : case 'utf-8' : if ( strpbrk ( $ value , "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false ) { $ value = ezcMailHeaderFolder :: foldAny ( $ value ) ; break ; } default : $ preferences = array ( 'input-charset' => $ charset , 'output-charset' => $ charset , 'line-length' => ezcMailHeaderFolder :: getLimit ( ) , 'scheme' => 'Q' , 'line-break-chars' => ezcMailTools :: lineBreak ( ) ) ; $ value = iconv_mime_encode ( 'dummy' , $ value , $ preferences ) ; $ value = substr ( $ value , 7 ) ; $ this -> setHeader ( $ header , $ value , $ charset ) ; break ; } if ( in_array ( strtolower ( $ header ) , $ this -> excludeHeaders ) === false ) { $ text .= "$header: $value" . ezcMailTools :: lineBreak ( ) ; } } return $ text ; }
|
Returns the headers set for this part as a RFC 822 string .
|
12,091
|
public function deleteDirectory ( string $ path , bool $ withFiles = false ) { if ( $ path == '*' ) $ this -> abort ( 'Can not delete "*", please specify folder or file.' ) ; $ files = glob ( $ path . '/*' ) ; foreach ( $ files as $ file ) { if ( is_file ( $ file ) && ! $ withFiles ) return ; is_dir ( $ file ) ? $ this -> deleteDirectory ( $ file , $ withFiles ) : unlink ( $ file ) ; } if ( is_dir ( $ path ) ) try { rmdir ( $ path ) ; $ this -> info ( 'Deleting folder: ' . $ path ) ; } catch ( \ Exception $ e ) { $ this -> comment ( 'Can not delete ' . $ path . ', it might contain hidden files, such as .gitignore' ) ; } }
|
Deleting existing folder
|
12,092
|
public function getToReplace ( array $ ignoreSymbols ) : array { if ( empty ( $ ignoreSymbols ) ) return $ this -> toReplace ; return array_diff ( $ this -> toReplace , $ ignoreSymbols ) ; }
|
Get replaceable symbols
|
12,093
|
protected function stringWithUnderscore ( string $ string , array $ ignoreToReplace = [ ] ) { return str_replace ( $ this -> getToReplace ( $ ignoreToReplace ) , '_' , trim ( $ string , '/' ) ) ; }
|
Get string in underscore
|
12,094
|
protected function stringWithDash ( string $ string , array $ ignoreToReplace = [ ] ) { return str_replace ( $ this -> getToReplace ( $ ignoreToReplace ) , '-' , trim ( $ string , '/' ) ) ; }
|
Get string in dash
|
12,095
|
protected function stringOnly ( string $ string , array $ ignoreToReplace = [ ] ) { return str_replace ( $ this -> getToReplace ( $ ignoreToReplace ) , '' , trim ( $ string , '/' ) ) ; }
|
Remove all items from string
|
12,096
|
public function iShouldGetALogEntry ( $ string ) { $ found = false ; foreach ( explode ( "\n" , $ this -> getOutput ( ) ) as $ line ) { if ( trim ( $ line ) == $ string ) { $ found = true ; } } if ( ! $ found ) { throw new \ Exception ( "Actual output is:\n" . $ this -> getOutput ( ) ) ; } }
|
Verifies whether one of the log entries is the same as the given .
|
12,097
|
public function iShouldGetALogEntryContaining ( $ string ) { $ found = false ; foreach ( explode ( "\n" , $ this -> getOutput ( ) ) as $ line ) { if ( strpos ( trim ( $ line ) , $ string ) !== false ) { $ found = true ; } } if ( ! $ found ) { throw new \ Exception ( "Actual output is:\n" . $ this -> getOutput ( ) ) ; } }
|
Verifies whether a log entry contains the given substring .
|
12,098
|
public function iRunPhpDocumentorAgainstTheFile ( $ file_path ) { $ tmp = self :: getTmpFolder ( ) ; $ fullPath = __DIR__ . '/../../' . $ file_path ; $ this -> iRunPhpdoc ( "-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force" ) ; }
|
Runs phpDocumentor with only the file that is provided in this command .
|
12,099
|
public function iRunPhpDocumentorWith ( PyStringNode $ code , $ extraParameters = '' ) { $ tmp = self :: getTmpFolder ( ) ; $ file = tempnam ( $ tmp , 'pdb' ) ; file_put_contents ( $ file , $ code ) ; $ this -> iRunPhpdoc ( "-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters" ) ; unlink ( $ file ) ; }
|
Parses the given PHP code with phpDocumentor .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.