idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
226,000
private function getFirstAdminPerClass ( $ class ) { $ code = null ; $ admins = $ this -> adminPool -> getAdminClasses ( ) ; foreach ( $ admins as $ key => $ value ) { if ( $ key === $ class ) { $ code = current ( $ value ) ; break ; } } return $ code === null ? $ this -> adminPool -> getAdminByClass ( $ class ) : $ th...
Gets the first admin when there are multiple definitions .
226,001
public function getResults ( $ repository , $ pattern , $ language = null , $ max = 15 ) { $ queryResults = $ this -> findRecords ( $ repository , $ pattern , $ language ) ; $ results = array ( ) ; foreach ( $ queryResults as $ record ) { $ admin = $ this -> getFirstAdminPerClass ( get_class ( $ record ) ) ; if ( ! $ a...
Get the result suggestions for the passed pattern
226,002
public function getOne ( $ repository , $ id ) { $ repoConfig = $ this -> repos [ $ repository ] ; return $ this -> doctrine -> getRepository ( $ repoConfig [ 'repository' ] ) -> find ( $ id ) ; }
Return a single record by it s id . Used to map the front - end variable back to an object from the repository .
226,003
public function createResultRecord ( $ record , $ admin ) { $ resultRecord = array ( 'label' => ( string ) $ record , 'value' => ( string ) $ record , 'url' => ( $ admin ? $ admin -> generateObjectUrl ( 'edit' , $ record ) : null ) , 'id' => ( $ admin ? $ admin -> id ( $ record ) : null ) ) ; return $ resultRecord ; }
Creates result record
226,004
public function addMenuItem ( MenuEvent $ e ) { $ array = $ e -> getMenuConfig ( ) ; $ this -> menu -> addChild ( $ this -> factory -> createItem ( $ array [ 'name' ] , $ array ) ) ; }
Add a child to the menu
226,005
public static function reorderTabs ( FormMapper $ formMapper , array $ tabOrder ) { $ tabsOriginal = $ formMapper -> getAdmin ( ) -> getFormTabs ( ) ; $ tabOrder = array_filter ( $ tabOrder , function ( $ key ) use ( $ tabsOriginal ) { return array_key_exists ( $ key , $ tabsOriginal ) ; } ) ; $ tabs = array_merge ( ar...
Allows to reorder Tabs
226,006
public function map ( FormMapper $ formMapper , $ helpPrefix = null ) { $ this -> formMapper = $ formMapper ; $ this -> helpPrefix = $ helpPrefix ; return $ this ; }
Start a mapping of fields on the given formMapper
226,007
public function add ( $ name , $ type = null , array $ options = array ( ) , array $ fieldDescriptionOptions = array ( ) ) { if ( null === $ this -> formMapper ) { throw new LogicException ( 'No FormMapper to add fields to, please make sure you start with AdminUtil->map' ) ; } $ this -> formMapper -> add ( $ name , $ t...
Add a field to the given formMapper
226,008
public function listItem ( $ type , $ dir = '.' , $ recursive = false , $ ignore = array ( ) ) { if ( $ type != 'dir' && $ type != 'file' ) { throw new \ InvalidArgumentException ( '$type must "file" or "dir"' ) ; } $ fileList = $ this -> nList ( $ dir ) ; $ fileInfo = array ( ) ; foreach ( $ fileList as $ file ) { $ f...
List of file or directory
226,009
public function wget ( $ httpFile , $ remote ) { if ( ! ini_get ( 'allow_url_fopen' ) ) { throw new \ RuntimeException ( 'allow_url_fopen must enabled' ) ; } if ( ! $ fileData = file_get_contents ( $ httpFile ) ) { throw new \ RuntimeException ( 'Can nat get file content' ) ; } $ parseFile = $ this -> parseLastDirector...
Upload file to ssh server from http address
226,010
public function fromMixed ( $ mixed , DOMElement $ domElement = null ) { $ domElement = is_null ( $ domElement ) ? $ this : $ domElement ; if ( is_array ( $ mixed ) ) { foreach ( $ mixed as $ index => $ mixedElement ) { if ( is_int ( $ index ) ) { if ( $ index == 0 ) { $ node = $ domElement ; } else { $ node = $ this -...
CONSTRUCTS ELEMENTS AND TEXTS FROM AN ARRAY OR STRING . THE ARRAY CAN CONTAIN AN ELEMENT S NAME IN THE INDEX PART AND AN ELEMENT S TEXT IN THE VALUE PART .
226,011
public static function build ( ServerInterface $ server ) { if ( $ server instanceof SftpServer ) { return new SftpDirectory ( $ server ) ; } elseif ( $ server instanceof FtpServer || $ server instanceof SslServer ) { return new FtpDirectory ( $ server ) ; } else { throw new \ InvalidArgumentException ( 'The argument i...
Build method for Directory classes
226,012
public static function build ( ServerInterface $ server ) { if ( $ server instanceof SftpServer ) { return new SftpFile ( $ server ) ; } elseif ( $ server instanceof FtpServer || $ server instanceof SslServer ) { return new FtpFile ( $ server ) ; } else { throw new \ InvalidArgumentException ( 'The argument is must ins...
Build method for File classes
226,013
public static function createFromJsonObject ( string $ value ) { $ json = \ json_decode ( $ value , true ) ; if ( ! \ is_array ( $ json ) ) { throw new \ InvalidArgumentException ( 'Invalid key or key set.' ) ; } return self :: createFromValues ( $ json ) ; }
Creates a key from a Json string .
226,014
public static function createFromValues ( array $ values ) { if ( \ array_key_exists ( 'keys' , $ values ) && \ is_array ( $ values [ 'keys' ] ) ) { return JWKSet :: createFromKeyData ( $ values ) ; } return JWK :: create ( $ values ) ; }
Creates a key or key set from the given input .
226,015
public static function createFromSecret ( string $ secret , array $ additional_values = [ ] ) : JWK { $ values = \ array_merge ( $ additional_values , [ 'kty' => 'oct' , 'k' => Base64Url :: encode ( $ secret ) , ] ) ; return JWK :: create ( $ values ) ; }
This method create a JWK object using a shared secret .
226,016
public static function createFromKeyFile ( string $ file , ? string $ password = null , array $ additional_values = [ ] ) : JWK { $ values = KeyConverter :: loadFromKeyFile ( $ file , $ password ) ; $ values = \ array_merge ( $ values , $ additional_values ) ; return JWK :: create ( $ values ) ; }
This method will try to load and convert a key file into a JWK object . If the key is encrypted the password must be set .
226,017
public static function createFromKey ( string $ key , ? string $ password = null , array $ additional_values = [ ] ) : JWK { $ values = KeyConverter :: loadFromKey ( $ key , $ password ) ; $ values = \ array_merge ( $ values , $ additional_values ) ; return JWK :: create ( $ values ) ; }
This method will try to load and convert a key into a JWK object . If the key is encrypted the password must be set .
226,018
public static function createFromX5C ( array $ x5c , array $ additional_values = [ ] ) : JWK { $ values = KeyConverter :: loadFromX5C ( $ x5c ) ; $ values = \ array_merge ( $ values , $ additional_values ) ; return JWK :: create ( $ values ) ; }
This method will try to load and convert a X . 509 certificate chain into a public key .
226,019
public static function formatByte ( $ byte ) { if ( $ byte == 0 ) { return '0 B' ; } $ s = array ( 'B' , 'Kb' , 'Mb' , 'Gb' , 'Tb' , 'Pb' ) ; $ e = floor ( log ( $ byte ) / log ( 1024 ) ) ; return sprintf ( '%.2f ' . $ s [ $ e ] , ( $ byte / pow ( 1024 , floor ( $ e ) ) ) ) ; }
Format file size to human readable
226,020
public function execute ( $ command , callable $ next ) { try { $ result = $ next ( $ command ) ; } catch ( \ Exception $ exception ) { $ this -> eventRecorder -> eraseEvents ( ) ; throw $ exception ; } $ recordedEvents = $ this -> eventRecorder -> releaseEvents ( ) ; foreach ( $ recordedEvents as $ event ) { $ this ->...
Dispatches all the recorded events in the EventBus and erases them
226,021
private function ignoreItem ( $ type , $ name , $ ignore ) { if ( $ type == 'file' && in_array ( pathinfo ( $ name , PATHINFO_EXTENSION ) , $ ignore ) ) { return true ; } elseif ( $ type == 'dir' && in_array ( $ name , $ ignore ) ) { return true ; } return false ; }
Ignore item to itemList
226,022
public function fetchUniqueIconsList ( ) { $ md5s = [ ] ; foreach ( $ this -> getIconsList ( ) as $ path => $ name ) { $ hash = md5_file ( $ path ) ; if ( in_array ( $ hash , $ md5s , true ) ) { continue ; } $ md5s [ $ path ] = $ hash ; $ list [ $ path ] = $ name ; } return $ list ; }
Fetches list of unique icons .
226,023
public function fetchIconsList ( ) { $ dir = Yii :: getAlias ( '@hiqdev/paymenticons/assets/png/xs' ) ; $ files = scandir ( $ dir ) ; $ list = [ ] ; foreach ( $ files as $ file ) { if ( $ file [ 0 ] === '.' ) { continue ; } $ name = pathinfo ( $ file ) [ 'filename' ] ; $ list [ "$dir/$file" ] = $ name ; } return $ list...
Scans directory to prepare list of icons .
226,024
public function genCss ( ) { $ sizes = [ 'xs' => 'height: 38px; width: 60px;' , 'sm' => 'height: 75px; width: 120px;' , 'md' => 'height: 240px; width: 150px;' , 'lg' => 'height: 480px; width: 300px;' , ] ; $ res = '.pi { display: inline-block;height: 38px;width: 60px; }' . PHP_EOL ; foreach ( array_keys ( $ sizes ) as ...
Generates CSS file .
226,025
public function wget ( $ httpFile , $ remote , $ mode = FTP_BINARY ) { if ( ! ini_get ( 'allow_url_fopen' ) ) { throw new \ RuntimeException ( 'allow_url_fopen must enabled' ) ; } if ( ! $ handle = fopen ( $ httpFile ) ) { throw new \ RuntimeException ( 'File can not opened' ) ; } if ( ! ftp_fput ( $ this -> session , ...
Upload file to ftp server from http address
226,026
protected function listItem ( $ type , $ dir = '/.' , $ recursive = false , $ ignore = array ( ) ) { if ( $ type == 'dir' ) { $ bool = true ; } elseif ( $ type == 'file' ) { $ bool = false ; } else { throw new \ InvalidArgumentException ( '$type must "file" or "dir"' ) ; } $ parseDir = $ this -> parseLastDirectory ( $ ...
List of file
226,027
public function get_baselayers ( DataContainer $ dc ) { $ id = 0 ; if ( $ dc -> activeRecord -> c4g_map_id != 0 ) { $ id = $ dc -> activeRecord -> c4g_map_id ; } else { $ id = $ this -> firstMapId ; } $ profile = $ this -> Database -> prepare ( "SELECT b.baselayers " . "FROM tl_c4g_maps a, tl_c4g_map_profiles b " . "WH...
Return all base layers for current Map Profile as array
226,028
public function get_maps ( DataContainer $ dc ) { $ maps = $ this -> Database -> prepare ( "SELECT * FROM tl_c4g_maps WHERE is_map=1 AND published=1" ) -> execute ( ) ; if ( $ maps -> numRows > 0 ) { while ( $ maps -> next ( ) ) { if ( ! isset ( $ this -> firstMapId ) ) { $ this -> firstMapId = $ maps -> id ; } $ retur...
Return all defined maps
226,029
public function getAllLocStyles ( DataContainer $ dc ) { $ locStyles = $ this -> Database -> prepare ( "SELECT id,name FROM tl_c4g_map_locstyles ORDER BY name" ) -> execute ( ) ; while ( $ locStyles -> next ( ) ) { $ return [ $ locStyles -> id ] = $ locStyles -> name ; } return $ return ; }
Return all Location Styles as array
226,030
public function getAllBaseLayers ( DataContainer $ dc ) { $ baseLayers = $ this -> Database -> prepare ( "SELECT id,name FROM tl_c4g_map_baselayers ORDER BY name" ) -> execute ( ) ; while ( $ baseLayers -> next ( ) ) { $ return [ $ baseLayers -> id ] = $ baseLayers -> name ; } return $ return ; }
Return all Base Layers as array
226,031
public function updateDCA ( DataContainer $ dc ) { if ( ! $ dc -> id ) { return ; } $ objProfile = $ this -> Database -> prepare ( "SELECT zoom_panel, geosearch_engine, be_optimize_checkboxes_limit FROM tl_c4g_map_profiles WHERE id=?" ) -> limit ( 1 ) -> execute ( $ dc -> id ) ; if ( $ objProfile -> numRows > 0 ) { if ...
Update the palette information that depend on other values
226,032
public function pickUrl ( DataContainer $ dc ) { return ' <a href="contao/page.php?do=' . Input :: get ( 'do' ) . '&amp;table=' . $ dc -> table . '&amp;field=' . $ dc -> field . '&amp;value=' . str_replace ( array ( '{{link_url::' , '}}' ) , '' , $ dc -> value ) . '" title="' . specialchars ( $ GLOBALS [ 'TL_LANG' ] [ ...
Return the page pick wizard for the editor_helpurl
226,033
public function editLocationStyle ( DataContainer $ dc ) { return ( $ dc -> value < 1 ) ? '' : ' <a href="contao/main.php?do=c4g_map_locstyles&amp;act=edit&amp;id=' . $ dc -> value . '&amp;popup=1&amp;nb=1&amp;rt=' . REQUEST_TOKEN . '" title="' . sprintf ( specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'tl_c4g_maps' ] [ 'edi...
Return the edit location style wizard
226,034
public function getAllThemes ( ) { $ return = [ ] ; $ themes = $ this -> Database -> prepare ( "SELECT id,name FROM tl_c4g_map_themes ORDER BY name" ) -> execute ( ) ; while ( $ themes -> next ( ) ) { $ return [ $ themes -> id ] = $ themes -> name ; } return $ return ; }
Return all themes as array
226,035
public function editModule ( DataContainer $ dc ) { return ( $ dc -> value < 1 ) ? '' : ' <a href="contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $ dc -> value . '&amp;popup=1&amp;nb=1&amp;rt=' . REQUEST_TOKEN . '" title="' . sprintf ( StringUtil :: specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'tl_co...
Return the edit module wizard
226,036
public function getModules ( ) { $ arrModules = [ ] ; $ objModules = $ this -> Database -> execute ( "SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id ORDER BY t.name, m.name" ) ; while ( $ objModules -> next ( ) ) { $ arrModules [ $ objModules -> theme ] [ $ objModules -> id ] =...
Get all modules and return them as array
226,037
public static function validateLon ( $ value ) { if ( strpos ( $ value , '{{' ) !== - 1 ) { return true ; } if ( self :: validateGeo ( $ value ) ) { return ( ( $ value >= - 180.0 ) && ( $ value <= 180.0 ) ) ; } return false ; }
Validate a longitude coordinate
226,038
public static function validateLat ( $ value ) { if ( strpos ( $ value , '{{' ) !== - 1 ) { return true ; } if ( self :: validateGeo ( $ value ) ) { return ( ( $ value >= - 90.0 ) && ( $ value <= 90.0 ) ) ; } return false ; }
Validate a latitude coordinate
226,039
public static function validateGeo ( $ value ) { if ( ! isset ( $ value ) ) { return false ; } $ value = floatval ( $ value ) ; if ( $ value == 0 ) { return false ; } return true ; }
Validate a Geo Coordinate
226,040
private function setChildHide ( $ childList , $ parentLayer ) { $ newChildList = [ ] ; if ( $ childList && $ parentLayer ) { foreach ( $ childList as $ index => $ child ) { if ( $ parentLayer -> data_hidelayer ) { $ child [ 'hide' ] = $ parentLayer -> data_hidelayer ; if ( $ child [ 'hasChilds' ] ) { $ child [ 'childs'...
Private function to set the hide property of childs correctly .
226,041
private function getChildsForLinkedLayer ( $ layerId , $ parentLayer ) { $ childLayers = C4gMapsModel :: findPublishedByPid ( $ layerId ) ; $ arrLayerData [ 'childs' ] = [ ] ; foreach ( $ childLayers as $ childLayer ) { if ( $ childLayer -> location_type !== "none" ) { $ childData = $ this -> parseLayer ( $ childLayer ...
Returns the linked structure .
226,042
public function createSinglesList ( RegisterElementSourcesEvent $ event ) { $ singles [ ] = [ 'heading' => Craft :: t ( 'app' , 'Singles' ) ] ; $ singleSections = Craft :: $ app -> sections -> getSectionsByType ( Section :: TYPE_SINGLE ) ; foreach ( $ singleSections as $ single ) { $ entry = null ; if ( Craft :: $ app ...
Create a new singles list and replace the old one with it
226,043
public function getMapTables ( ) { $ tables = [ ] ; if ( is_array ( $ GLOBALS [ 'con4gis' ] [ 'maps' ] [ 'sourcetable' ] ) ) { foreach ( $ GLOBALS [ 'con4gis' ] [ 'maps' ] [ 'sourcetable' ] as $ key => $ sourcetable ) { $ tables [ $ key ] = $ GLOBALS [ 'TL_LANG' ] [ 'c4g_maps' ] [ 'sourcetable' ] [ $ key ] [ 'name' ] ;...
Return available Map tables
226,044
public function on ( $ event , $ pattern , $ handler ) { $ bak = $ this -> f3 -> ROUTES ; $ this -> f3 -> ROUTES = array ( ) ; $ this -> f3 -> route ( $ pattern , $ handler ) ; $ this -> routes [ $ event ] = ( isset ( $ this -> routes [ $ event ] ) ) ? $ this -> f3 -> extend ( 'ROUTES' , $ this -> routes [ $ event ] ) ...
register route to a specific event
226,045
protected function getEditorConfigForProfile ( $ intId ) { $ arrEditorConfig = array ( ) ; $ objProfile = C4gMapProfilesModel :: findById ( $ intId ) ; if ( $ objProfile == null ) { HttpResultHelper :: NotFound ( ) ; } $ arrEditorConfig [ 'styles_point' ] = unserialize ( $ objProfile -> editor_styles_point ) ; $ arrEdi...
Returns the editor configuration from a given profile .
226,046
public static function findPublishedByPid ( $ intPid , array $ arrOptions = array ( ) ) { $ t = static :: $ strTable ; $ arrColumns = array ( "$t.pid=?" ) ; $ arrValues = array ( $ intPid ) ; if ( ! C4GUtils :: checkBackendUserLogin ( ) ) { $ time = time ( ) ; $ arrColumns [ ] = "$t.published=1" ; } if ( ! isset ( $ ar...
ToDo Funktioniert unter contao 4 offensichtlich nicht mehr so wie es soll .
226,047
public static function loadGeopickerResources ( $ additionalResources = array ( ) ) { $ profile = C4gMapProfilesModel :: findBy ( 'is_backend_geopicker_default' , 1 ) ; if ( ! $ profile ) { $ settings = C4gSettingsModel :: findAll ( ) ; $ profile = $ settings [ 0 ] -> defaultprofile ; if ( ! $ profile ) { $ profiles = ...
Loads the default geopicker profile and resources according to that profile
226,048
public function generateLabel ( ) { if ( ( $ this -> require_input ) && ( $ this -> value == '' ) ) { $ this -> required = true ; } return parent :: generateLabel ( ) ; }
Check custom setting require_input which implements custom mandatory handling possibility
226,049
public function getFolderData ( $ objLayer , $ key = false , $ folder = false , $ count = 0 ) { if ( ! $ folder ) { $ folder = $ this -> getFolder ( $ objLayer ) ; } if ( ! $ key ) { $ key = $ objLayer -> id ; } $ folderPath = realpath ( TL_ROOT . '/' . $ folder ) ; $ countFiles = 2050 ; if ( is_dir ( $ folderPath ) ) ...
Creates the layer data for a given layer of the location_type folder .
226,050
private function getFileContent ( $ objLayer , $ folder , $ fileInfo , $ key , $ count ) { switch ( $ fileInfo [ 'extension' ] ) { case 'gpx' : $ child = array ( "id" => strval ( $ key . $ count ) , "pid" => $ key , "name" => utf8_encode ( $ fileInfo [ 'filename' ] ) , "hide" => $ objLayer -> published , "display" => t...
Parses gpx contents of a given file for a given layer .
226,051
public static function render ( $ t , $ v = null ) { if ( Options :: get ( 'core.text.replace_empties' , true ) ) { $ replacer = function ( $ c ) use ( $ v ) { return Structure :: fetch ( trim ( $ c [ 1 ] ) , $ v ) ; } ; } else { $ replacer = function ( $ c ) use ( $ v ) { return Structure :: fetch ( trim ( $ c [ 1 ] )...
Fast string templating . Uses a Twig - like syntax .
226,052
public static function cut ( $ text , $ start_tag , $ end_tag = null ) { $ _s = strlen ( $ start_tag ) + strpos ( $ text , $ start_tag ) ; return $ end_tag ? substr ( $ text , $ _s , strpos ( $ text , $ end_tag , $ _s ) - $ _s ) : substr ( $ text , $ _s ) ; }
Cut a string from the end of a substring to the start of another
226,053
public static function fetch ( $ path , $ root ) { $ _ = ( array ) $ root ; if ( strpos ( $ path , '.' ) === false ) { return isset ( $ _ [ $ path ] ) ? $ _ [ $ path ] : null ; } else { list ( $ frag , $ rest ) = explode ( '.' , $ path , 2 ) ; if ( $ rest ) { return isset ( $ _ [ $ frag ] ) ? self :: fetch ( $ rest , $...
Dot - Notation Array Path Resolver
226,054
public function get ( $ key , $ default = null ) { if ( null !== ( $ ptr = & $ this -> find ( $ key , false ) ) ) { return $ ptr ; } else { if ( $ default !== null ) { return $ this -> set ( $ key , is_callable ( $ default ) ? call_user_func ( $ default ) : $ default ) ; } else { return null ; } } }
Get a value assigned to a key path from the map
226,055
public function set ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { return $ this -> merge ( $ key ) ; } else { $ ptr = & $ this -> find ( $ key , true ) ; return $ ptr = $ value ; } }
Set a value for a key path from map
226,056
public function delete ( $ key , $ compact = true ) { $ this -> set ( $ key , null ) ; if ( $ compact ) $ this -> compact ( ) ; }
Delete a value and the key path from map .
226,057
public function merge ( $ array , $ merge_back = false ) { $ this -> fields = $ merge_back ? array_replace_recursive ( ( array ) $ array , $ this -> fields ) : array_replace_recursive ( $ this -> fields , ( array ) $ array ) ; }
Merge an associative array to the map .
226,058
public function compact ( ) { $ array_filter_rec = function ( $ input , $ callback = null ) use ( & $ array_filter_rec ) { foreach ( $ input as & $ value ) { if ( is_array ( $ value ) ) { $ value = $ array_filter_rec ( $ value , $ callback ) ; } } return array_filter ( $ input , $ callback ) ; } ; $ this -> fields = $ ...
Compact map removing empty paths
226,059
public function & find ( $ path , $ create = false , callable $ operation = null ) { $ create ? $ value = & $ this -> fields : $ value = $ this -> fields ; foreach ( explode ( '.' , $ path ) as $ tok ) if ( $ create || isset ( $ value [ $ tok ] ) ) { $ value = & $ value [ $ tok ] ; } else { $ value = $ create ? $ value...
Navigate map and find the element from the path in dot notation .
226,060
static public function start ( $ name = null ) { if ( isset ( $ _SESSION ) ) return ; $ ln = static :: name ( $ name ) ; ini_set ( 'session.hash_function' , 'whirlpool' ) ; session_cache_limiter ( 'must-revalidate' ) ; if ( session_status ( ) == PHP_SESSION_NONE ) { @ session_start ( ) ; } static :: trigger ( "start" ,...
Start session handler
226,061
static public function get ( $ key , $ default = null ) { if ( ( $ active = static :: active ( ) ) && isset ( $ _SESSION [ $ key ] ) ) { return $ _SESSION [ $ key ] ; } else if ( $ active ) { return $ _SESSION [ $ key ] = ( is_callable ( $ default ) ? call_user_func ( $ default ) : $ default ) ; } else { return ( is_ca...
Get a session variable reference
226,062
public static function download ( $ data ) { if ( is_array ( $ data ) ) { if ( isset ( $ data [ 'filename' ] ) ) static :: $ force_dl = $ data [ 'filename' ] ; if ( isset ( $ data [ 'charset' ] ) ) static :: charset ( $ data [ 'charset' ] ) ; if ( isset ( $ data [ 'mime' ] ) ) static :: type ( $ data [ 'mime' ] ) ; if ...
Force download of Response body
226,063
public static function enableCORS ( $ origin = '*' ) { if ( $ origin = $ origin ? : ( isset ( $ _SERVER [ 'HTTP_ORIGIN' ] ) ? $ _SERVER [ 'HTTP_ORIGIN' ] : ( isset ( $ _SERVER [ 'HTTP_HOST' ] ) ? $ _SERVER [ 'HTTP_HOST' ] : '*' ) ) ) { static :: header ( 'Access-Control-Allow-Origin' , $ origin ) ; static :: header ( '...
Enable CORS HTTP headers .
226,064
public static function json ( $ payload ) { static :: type ( static :: TYPE_JSON ) ; static :: $ payload [ ] = json_encode ( $ payload , Options :: get ( 'core.response.json_flags' , JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING ) ) ; }
Append a JSON object to the buffer .
226,065
public static function load ( $ data ) { $ data = ( object ) $ data ; if ( isset ( $ data -> head ) ) static :: headers ( $ data -> head ) ; if ( isset ( $ data -> body ) ) static :: body ( $ data -> body ) ; }
Load response from a saved state
226,066
protected static function _compileCommand ( $ command , array $ params ) { $ s = $ w = [ ] ; foreach ( $ params as $ p ) { if ( $ p instanceof static ) { $ s [ ] = '$(' . $ p -> getShellCommand ( ) . ')' ; } else if ( is_array ( $ p ) ) foreach ( $ p as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ w [ ] = '--' ...
Compile a shell command
226,067
public static function pipe ( ) { $ cmd = [ ] ; foreach ( func_get_args ( ) as $ item ) { $ cmd [ ] = ( $ item instanceof static ) ? $ item -> getShellCommand ( ) : $ item ; } return new static ( implode ( ' | ' , $ cmd ) ) ; }
Concatenate multiple shell commands via piping
226,068
public static function from ( $ template , $ data = null ) { $ view = new self ( $ template ) ; return $ data ? $ view -> with ( $ data ) : $ view ; }
View factory method can optionally pass data to pre - init view
226,069
public function with ( $ data ) { if ( $ data ) { $ tmp = array_merge ( $ data , ( isset ( $ this -> options [ 'data' ] ) ? $ this -> options [ 'data' ] : [ ] ) ) ; $ this -> options [ 'data' ] = $ tmp ; } return $ this ; }
Assigns data to the view
226,070
protected function connect ( ) { if ( ! empty ( $ this -> conn ) ) { return ; } if ( ! extension_loaded ( 'ftp' ) ) { throw new ServerException ( "Unable to initialize ftp storage server, extension 'ftp' not found" ) ; } $ conn = ftp_connect ( $ this -> options [ 'host' ] , $ this -> options [ 'port' ] , $ this -> opti...
Ensure FTP connection .
226,071
public function withClient ( ClientInterface $ client ) : AmazonServer { $ server = clone $ this ; $ server -> client = $ client ; return $ this ; }
Version of driver with alternative client being set up .
226,072
protected function buildUri ( BucketInterface $ bucket , string $ name ) : UriInterface { return new Uri ( $ this -> options [ 'server' ] . '/' . $ bucket -> getOption ( 'bucket' ) . '/' . rawurlencode ( $ name ) ) ; }
Create instance of UriInterface based on provided bucket options and storage object name .
226,073
protected function buildRequest ( string $ method , BucketInterface $ bucket , string $ name , array $ headers = [ ] , array $ commands = [ ] ) : RequestInterface { $ headers += [ 'Date' => gmdate ( 'D, d M Y H:i:s T' ) , 'Content-MD5' => '' , 'Content-Type' => '' ] ; $ packedCommands = $ this -> packCommands ( $ comma...
Helper to create configured PSR7 request with set of amazon commands .
226,074
private function packCommands ( array $ commands ) : array { $ headers = [ ] ; foreach ( $ commands as $ command => $ value ) { $ headers [ 'X-Amz-' . $ command ] = $ value ; } return $ headers ; }
Generate request headers based on provided set of amazon commands .
226,075
private function run ( RequestInterface $ request , array $ skipCodes = [ ] ) : ? ResponseInterface { try { return $ this -> client -> send ( $ request ) ; } catch ( GuzzleException $ e ) { if ( in_array ( $ e -> getCode ( ) , $ skipCodes ) ) { return null ; } throw new ServerException ( $ e -> getMessage ( ) , $ e -> ...
Wrap guzzle errors into
226,076
private function signRequest ( RequestInterface $ request , array $ packedCommands = [ ] ) : RequestInterface { $ signature = [ $ request -> getMethod ( ) , $ request -> getHeaderLine ( 'Content-MD5' ) , $ request -> getHeaderLine ( 'Content-Type' ) , $ request -> getHeaderLine ( 'Date' ) ] ; $ normalizedCommands = [ ]...
Sign amazon request .
226,077
private function createHeaders ( BucketInterface $ bucket , string $ name , StreamInterface $ stream ) : array { if ( empty ( $ mimetype = mimetype_from_filename ( $ name ) ) ) { $ mimetype = self :: DEFAULT_MIMETYPE ; } ; $ headers = $ bucket -> getOption ( 'headers' , [ ] ) ; if ( ! empty ( $ maxAge = $ bucket -> get...
Generate object headers .
226,078
public static function make ( $ payload , $ method = 'md5' , $ raw_output = false ) { return $ method == 'murmur' ? static :: murmur ( serialize ( $ payload ) ) : hash ( $ method , serialize ( $ payload ) , $ raw_output ) ; }
Create ah hash for payload
226,079
protected function connect ( ) { if ( ! empty ( $ this -> conn ) ) { return ; } if ( ! extension_loaded ( 'ssh2' ) ) { throw new ServerException ( "Unable to initialize sftp storage server, extension 'ssh2' not found" ) ; } $ session = ssh2_connect ( $ this -> options [ 'host' ] , $ this -> options [ 'port' ] , $ this ...
Ensure that SSH connection is up and can be used for file operations .
226,080
protected function castRemoteFilename ( BucketInterface $ bucket , string $ name ) : string { return 'ssh2.sftp://' . $ this -> conn . $ this -> castPath ( $ bucket , $ name ) ; }
Get ssh2 specific uri which can be used in default php functions . Assigned to ssh2 . sftp stream wrapper .
226,081
public static function register ( ) { ini_set ( 'unserialize_callback_func' , 'spl_autoload_call' ) ; spl_autoload_register ( function ( $ class ) { $ cfile = strtr ( $ class , '_\\' , '//' ) . '.php' ; foreach ( static :: $ paths as $ path => $ v ) { $ file = rtrim ( $ path , '/' ) . '/' . $ cfile ; if ( is_file ( $ f...
Register core autoloader
226,082
public static function using ( $ driver ) { foreach ( ( array ) $ driver as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ drv = $ value ; $ conf = [ ] ; } else { $ drv = $ key ; $ conf = $ value ; } $ class = 'Cache\\' . ucfirst ( strtolower ( $ drv ) ) ; if ( class_exists ( $ class ) && $ class :: valid ( ) ) {...
Load cache drivers with a FCFS strategy
226,083
protected function internalMove ( BucketInterface $ bucket , string $ filename , string $ destination ) : bool { if ( ! $ this -> files -> exists ( $ filename ) ) { throw new ServerException ( "Unable to move '{$filename}', object does not exists" ) ; } $ mode = $ bucket -> getOption ( 'mode' , FilesInterface :: RUNTIM...
Move helper ensure target directory existence file permissions and etc .
226,084
public function getBucket ( string $ name ) : array { if ( ! $ this -> hasBucket ( $ name ) ) { throw new ConfigException ( "Undefined bucket `{$name}`" ) ; } $ bucket = $ this -> config [ 'buckets' ] [ $ name ] ; if ( ! array_key_exists ( 'options' , $ bucket ) ) { throw new ConfigException ( "Bucket `{$name}` must sp...
Get bucket options .
226,085
public function resolveBucket ( string $ address , string & $ name = null ) : string { $ bucket = null ; $ length = 0 ; foreach ( $ this -> prefixes as $ id => $ prefix ) { if ( strpos ( $ address , $ prefix ) === 0 && strlen ( $ prefix ) > $ length ) { $ bucket = $ id ; $ length = strlen ( $ prefix ) ; } } if ( empty ...
Locate bucket name using object address .
226,086
protected function castStream ( $ source ) : StreamInterface { if ( $ source instanceof UploadedFileInterface || $ source instanceof StreamableInterface ) { $ source = $ source -> getStream ( ) ; } if ( $ source instanceof StreamInterface ) { $ source -> rewind ( ) ; return $ source ; } if ( is_resource ( $ source ) ) ...
Cast stream associated with origin data .
226,087
protected function isFilename ( $ source ) : bool { if ( ! is_string ( $ source ) ) { return false ; } if ( ! preg_match ( '/[^A-Za-z0-9.#\\-$]/' , $ source ) ) { return false ; } $ source = strval ( str_replace ( "\0" , "" , $ source ) ) ; return file_exists ( $ source ) ; }
Check if given string is proper filename .
226,088
public static function on ( $ command , callable $ callback , $ description = '' ) { $ parts = preg_split ( '/\s+/' , $ command ) ; static :: $ commands [ array_shift ( $ parts ) ] = [ $ parts , $ callback , $ description ] ; }
Bind a callback to a command route
226,089
public static function help ( callable $ callback = null ) { $ callback ? is_callable ( $ callback ) && static :: $ help = $ callback : static :: $ help && call_user_func ( static :: $ help ) ; }
Bind a callback to the help route .
226,090
public static function error ( callable $ callback = null ) { $ callback ? is_callable ( $ callback ) && static :: $ error = $ callback : static :: $ error && call_user_func ( static :: $ error ) ; }
Bind a callback when an error occurs .
226,091
public static function input ( $ key = null , $ default = null ) { return $ key ? ( isset ( static :: $ options [ $ key ] ) ? static :: $ options [ $ key ] : ( is_callable ( $ default ) ? call_user_func ( $ default ) : $ default ) ) : static :: $ options ; }
Get a passed option
226,092
public static function commands ( ) { $ results = [ ] ; foreach ( static :: $ commands as $ name => $ cmd ) { $ results [ ] = [ 'name' => $ name , 'params' => preg_replace ( '/:(\w+)/' , '[$1]' , implode ( ' ' , $ cmd [ 0 ] ) ) , 'description' => $ cmd [ 2 ] , ] ; } return $ results ; }
Returns an explanation for the supported commands
226,093
public static function write ( $ message ) { if ( preg_match ( '~<[^>]+>~' , $ message ) ) { echo strtr ( preg_replace_callback ( '~^(.*)<([^>]+)>(.+)</\2>(.*)$~USm' , function ( $ m ) { static :: write ( $ m [ 1 ] ) ; $ color = strtoupper ( trim ( $ m [ 2 ] ) ) ; if ( isset ( static :: $ shell_colors [ $ color ] ) ) e...
Prints a message to the console with color formatting .
226,094
public function match ( $ URL , $ method = 'get' ) { $ method = strtolower ( $ method ) ; if ( empty ( $ this -> methods [ $ method ] ) && empty ( $ this -> methods [ '*' ] ) ) return false ; return ( bool ) ( $ this -> dynamic ? preg_match ( $ this -> matcher_pattern , '/' . trim ( $ URL , '/' ) ) : rtrim ( $ URL , '/...
Check if route match on a specified URL and HTTP Method .
226,095
public function run ( array $ args , $ method = 'get' ) { $ method = strtolower ( $ method ) ; $ append_echoed_text = Options :: get ( 'core.route.append_echoed_text' , true ) ; static :: trigger ( 'start' , $ this , $ args , $ method ) ; if ( $ this -> befores ) { foreach ( array_reverse ( $ this -> befores ) as $ mw ...
Run one of the mapped callbacks to a passed HTTP Method .
226,096
public function runIfMatch ( $ URL , $ method = 'get' ) { return $ this -> match ( $ URL , $ method ) ? $ this -> run ( $ this -> extractArgs ( $ URL ) , $ method ) : null ; }
Check if route match URL and HTTP Method and run if it is valid .
226,097
public function & via ( ... $ methods ) { $ this -> methods = [ ] ; foreach ( $ methods as $ method ) { $ this -> methods [ strtolower ( $ method ) ] = true ; } return $ this ; }
Defines the HTTP Methods to bind the route onto .
226,098
public function & rules ( array $ rules ) { foreach ( ( array ) $ rules as $ varname => $ rule ) { $ this -> rules [ $ varname ] = $ rule ; } $ this -> pattern = $ this -> compilePatternAsRegex ( $ this -> URLPattern , $ this -> rules ) ; $ this -> matcher_pattern = $ this -> compilePatternAsRegex ( $ this -> URLPatter...
Defines the regex rules for the named parameter in the current URL pattern
226,099
public static function & map ( $ URLPattern , $ callbacks = [ ] ) { $ route = new static ( $ URLPattern ) ; $ route -> callback = [ ] ; foreach ( $ callbacks as $ method => $ callback ) { $ method = strtolower ( $ method ) ; if ( Request :: method ( ) !== $ method ) continue ; $ route -> callback [ $ method ] = $ callb...
Map a HTTP Method = > callable array to a route .