idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
6,000
public static function group ( $ buttons , $ htmlOptions = array ( ) ) { ArrayHelper :: addValue ( 'class' , 'button-group' , $ htmlOptions ) ; ob_start ( ) ; echo \ CHtml :: openTag ( 'ul' , $ htmlOptions ) ; foreach ( $ buttons as $ button ) { echo $ button ; } echo \ CHtml :: closeTag ( 'ul' ) ; return ob_get_clean ( ) ; }
Generates a group of link buttons
6,001
public static function bar ( $ groups , $ htmlOptions = array ( ) ) { ArrayHelper :: addValue ( 'class' , 'button-bar' , $ htmlOptions ) ; ob_start ( ) ; echo \ CHtml :: openTag ( 'div' , $ htmlOptions ) ; foreach ( $ groups as $ group ) { echo $ group ; } echo \ CHtml :: closeTag ( 'div' ) ; return ob_get_clean ( ) ; }
Generates a button bar by wrapping multiple button groups into a button - bar
6,002
protected function loadConfigDefaults ( $ userSettings ) { $ parser = $ this [ 'config-parser' ] ; $ defaults = $ parser -> parseFile ( __DIR__ . '/slender.yml' ) ; $ userSettings = array_merge_recursive ( $ defaults , $ userSettings ) ; $ this [ 'settings' ] -> setArray ( $ userSettings ) ; }
Load up config defaults
6,003
protected function loadApplicationConfigFiles ( $ userSettings ) { $ parser = $ this [ 'config-parser' ] ; $ loader = $ this [ 'config-finder' ] ; $ userSettings = array ( ) ; foreach ( $ loader -> findFiles ( ) as $ path ) { if ( is_readable ( $ path ) ) { $ parsedFile = $ parser -> parseFile ( $ path ) ; if ( $ parsedFile !== false ) { $ this -> addConfig ( $ parsedFile ) ; } } else { echo "Invalid path $path\n" ; } } }
Load any application config files
6,004
public function registerService ( $ service , $ class ) { $ this [ $ service ] = function ( $ app ) use ( $ class ) { $ inst = new $ class ; if ( $ inst instanceof FactoryInterface ) { return $ inst -> create ( $ app ) ; } else { return $ inst ; } } ; }
Register a Service to the DI container . Services are singletons and the same instance is returned every time the identifier is requested
6,005
public function registerFactory ( $ factory , $ class ) { $ this [ $ factory ] = $ this -> factory ( function ( $ app ) use ( $ class ) { $ obj = new $ class ; if ( $ obj instanceof FactoryInterface ) { return $ obj -> create ( $ app ) ; } else { return $ obj ; } } ) ; }
Register a Factory to the DI container . Factories return a new instance of a class each time they are called
6,006
protected function registerCoreServices ( ) { $ this [ 'util' ] = function ( $ app ) { return new \ Slender \ Core \ Util \ Util ( ) ; } ; $ this -> registerService ( 'dependency-injector' , 'Slender\Core\DependencyInjector\Factory' ) ; $ this -> registerService ( 'autoloader' , 'Slender\Core\Autoloader\AutoloaderFactory' ) ; $ this -> registerService ( 'autoloader.psr4' , 'Slender\Core\Autoloader\PSR4Factory' ) ; $ this [ 'config-parser' ] = function ( ) { return new ConfigParser \ Stack ( array ( 'yml' => new ConfigParser \ YAML , 'php' => new ConfigParser \ PHP , 'json' => new ConfigParser \ JSON , ) ) ; } ; $ this [ 'config-finder' ] = function ( $ app ) { $ configLoader = new \ Slender \ Core \ ConfigFinder \ ConfigFinder ( $ this [ 'settings' ] [ 'config' ] [ 'autoload' ] , $ this [ 'settings' ] [ 'config' ] [ 'files' ] ) ; return $ configLoader ; } ; $ this [ 'module-resolver' ] = function ( $ app ) { $ stack = new ResolverStack ( new NamespaceResolver ) ; $ stack -> setConfigParser ( $ app [ 'config-parser' ] ) ; foreach ( $ this [ 'settings' ] [ 'modulePaths' ] as $ path ) { if ( is_readable ( $ path ) ) { $ stack -> prependResolver ( new DirectoryResolver ( $ path ) ) ; } } return $ stack ; } ; $ this -> registerService ( 'module-loader' , 'Slender\Core\ModuleLoader\Factory' ) ; }
Registers core services to the IoC Container
6,007
public function sendMessage ( Message $ message ) { $ this -> currentId ++ ; $ messageData = $ message -> convertToRconData ( $ this -> currentId ) ; $ this -> client -> write ( $ messageData ) ; return $ this -> getResponseMessage ( ) ; }
Send a RCON message .
6,008
protected function getResponseMessage ( ) { $ lengthEncoded = $ this -> client -> read ( 4 ) ; if ( strlen ( $ lengthEncoded ) < 4 ) { return new Message ( '' , Message :: TYPE_RESPONSE_VALUE ) ; } $ lengthInBytes = unpack ( 'V1size' , $ lengthEncoded ) [ 'size' ] ; if ( $ lengthInBytes <= 0 ) { return new Message ( '' , Message :: TYPE_RESPONSE_VALUE ) ; } $ responseData = $ this -> client -> read ( $ lengthInBytes ) ; if ( null === $ responseData ) { return new Message ( '' , Message :: TYPE_RESPONSE_VALUE ) ; } $ responseMessage = new Message ( ) ; $ responseMessage -> initializeFromRconData ( $ responseData ) ; if ( $ lengthInBytes >= 4000 ) { $ this -> handleFragmentedResponse ( $ responseMessage ) ; } return $ responseMessage ; }
Get the response value of the server .
6,009
protected function authenticate ( $ password ) { $ message = new Message ( $ password , Message :: TYPE_AUTH ) ; $ response = $ this -> sendMessage ( $ message ) ; if ( $ response -> getType ( ) === Message :: TYPE_AUTH_FAILURE ) { throw new AuthenticationFailedException ( 'Could not authenticate to the server.' ) ; } }
Authenticate with the server .
6,010
protected function getDateExceptionMessage ( $ details ) { $ errors = "Date/time problem: Details: " ; if ( is_array ( $ details [ 'errors' ] ) && $ details [ 'error_count' ] > 0 ) { foreach ( $ details [ 'errors' ] as $ error ) { $ errors .= $ error . " " ; } } elseif ( is_array ( $ details [ 'warnings' ] ) ) { foreach ( $ details [ 'warnings' ] as $ warning ) { $ errors .= $ warning . " " ; } } return $ errors ; }
Build an exception message from a detailed error array .
6,011
public function convertToDisplayDateAndTime ( $ createFormat , $ timeString , $ separator = ' ' ) { return $ this -> convertToDisplayDate ( $ createFormat , $ timeString ) . $ separator . $ this -> convertToDisplayTime ( $ createFormat , $ timeString ) ; }
Public method for getting a date prepended to a time .
6,012
public function convertToDisplayTimeAndDate ( $ createFormat , $ timeString , $ separator = ' ' ) { return $ this -> convertToDisplayTime ( $ createFormat , $ timeString ) . $ separator . $ this -> convertToDisplayDate ( $ createFormat , $ timeString ) ; }
Public method for getting a time prepended to a date .
6,013
public static function open ( $ action = '' , array $ attributes = null ) : string { $ attributes [ 'action' ] = $ action ; if ( ! isset ( $ attributes [ 'method' ] ) ) { $ attributes [ 'method' ] = 'post' ; } return '<form' . Html :: attributes ( $ attributes ) . '>' ; }
Create an opening HTML form tag .
6,014
public static function input ( string $ name , string $ value = '' , array $ attributes = null ) : string { $ attributes [ 'name' ] = $ name ; $ attributes [ 'id' ] = ( isset ( $ attributes [ 'id' ] ) ) ? $ attributes [ 'id' ] : $ name ; $ attributes [ 'value' ] = $ value ; if ( ! isset ( $ attributes [ 'type' ] ) ) { $ attributes [ 'type' ] = 'text' ; } return '<input' . Html :: attributes ( $ attributes ) . '>' ; }
Create a form input . Text is default input type .
6,015
public static function hidden ( string $ name , string $ value = '' , array $ attributes = null ) : string { $ attributes [ 'type' ] = 'hidden' ; return Form :: input ( $ name , $ value , $ attributes ) ; }
Create a hidden form input .
6,016
public static function password ( string $ name , string $ value = '' , array $ attributes = null ) : string { $ attributes [ 'type' ] = 'password' ; return Form :: input ( $ name , $ value , $ attributes ) ; }
Creates a password form input .
6,017
public static function file ( string $ name , array $ attributes = null ) : string { $ attributes [ 'type' ] = 'file' ; return Form :: input ( $ name , '' , $ attributes ) ; }
Creates a file upload form input .
6,018
public static function checkbox ( $ name , $ value = '' , $ checked = false , array $ attributes = null ) { $ attributes [ 'type' ] = 'checkbox' ; if ( $ checked === true ) { $ attributes [ 'checked' ] = 'checked' ; } return Form :: input ( $ name , $ value , $ attributes ) ; }
Creates a checkbox form input .
6,019
public static function radio ( $ name , $ value = '' , $ checked = null , array $ attributes = null ) { $ attributes [ 'type' ] = 'radio' ; if ( $ checked === true ) { $ attributes [ 'checked' ] = 'checked' ; } return Form :: input ( $ name , $ value , $ attributes ) ; }
Creates a radio form input .
6,020
public static function textarea ( $ name , $ body = '' , array $ attributes = null ) { $ attributes [ 'name' ] = $ name ; $ attributes [ 'id' ] = ( isset ( $ attributes [ 'id' ] ) ) ? $ attributes [ 'id' ] : $ name ; return '<textarea' . Html :: attributes ( $ attributes ) . '>' . $ body . '</textarea>' ; }
Creates a textarea form input .
6,021
public static function select ( $ name , array $ options = null , $ selected = null , array $ attributes = null ) { $ attributes [ 'name' ] = $ name ; $ attributes [ 'id' ] = ( isset ( $ attributes [ 'id' ] ) ) ? $ attributes [ 'id' ] : $ name ; $ options_output = '' ; foreach ( $ options as $ value => $ name ) { if ( $ selected == $ value ) $ current = ' selected ' ; else $ current = '' ; $ options_output .= '<option value="' . $ value . '" ' . $ current . '>' . $ name . '</option>' ; } return '<select' . Html :: attributes ( $ attributes ) . '>' . $ options_output . '</select>' ; }
Creates a select form input .
6,022
public static function submit ( $ name , $ value , array $ attributes = null ) { $ attributes [ 'type' ] = 'submit' ; return Form :: input ( $ name , $ value , $ attributes ) ; }
Creates a submit form input .
6,023
public static function button ( $ name , $ body , array $ attributes = null ) { $ attributes [ 'name' ] = $ name ; return '<button' . Html :: attributes ( $ attributes ) . '>' . $ body . '</button>' ; }
Creates a button form input .
6,024
public static function label ( $ input , $ text , array $ attributes = null ) { $ attributes [ 'for' ] = $ input ; return '<label' . Html :: attributes ( $ attributes ) . '>' . $ text . '</label>' ; }
Creates a form label .
6,025
public function run ( $ cmd , array $ args ) { if ( ! isset ( $ this -> commands [ $ cmd ] ) ) { $ this -> error ( sprintf ( 'command %s not exists' , $ cmd ) ) ; } $ response = new Response ( ) ; $ driverId = isset ( $ args [ 'target' ] ) ? $ this -> getDriverId ( $ args [ 'target' ] ) : '' ; $ driverId = ! $ driverId && isset ( $ args [ 'targets' ] ) ? $ this -> getDriverId ( current ( $ args [ 'targets' ] ) ) : $ driverId ; $ interface = $ this -> getInterfaceByCmd ( $ cmd ) ; $ data = null ; foreach ( $ this -> driverList as $ name => $ driver ) { if ( ! $ driverId || $ driverId == $ name ) { if ( $ driver instanceof $ interface ) { if ( $ driver -> mount ( ) ) { $ data = $ this -> runCmd ( $ driver , $ cmd , $ args , $ response ) ; } $ driver -> unmount ( ) ; } else { $ this -> error ( sprintf ( 'command "%s" not supported, please use interface "%s"' , $ cmd , $ interface ) ) ; } $ this -> addDisabledCommand ( $ driver ) ; $ response -> setOptions ( $ driver -> getOptions ( ) ) ; } $ response -> addFile ( $ driver -> getRootFileInfo ( ) ) ; } if ( ! empty ( $ args [ 'init' ] ) ) { $ response -> setApi ( DriverInterface :: VERSION ) ; } return $ data ? : $ response ; }
run command .
6,026
public function addDriver ( DriverInterface $ driver ) { $ driver -> setConnector ( $ this ) ; $ this -> driverList [ $ driver -> getDriverId ( ) ] = $ driver ; return $ this ; }
add Driver .
6,027
public function setDrivers ( array $ drivers ) { $ this -> driverList = array ( ) ; foreach ( $ drivers as $ driver ) { $ this -> addDriver ( $ driver ) ; } return $ this ; }
set All Drivers .
6,028
public function error ( $ message ) { if ( $ this -> logger ) { $ this -> logger -> error ( $ message ) ; } if ( ! $ this -> debug ) { throw new \ RuntimeException ( $ message ) ; } }
error Handling .
6,029
public function getDriverId ( $ targetHash ) { if ( is_array ( $ targetHash ) ) { $ targetHash = current ( $ targetHash ) ; } return substr ( $ targetHash , 0 , strpos ( $ targetHash , '_' ) ) ; }
get Driver Id from hash target .
6,030
private function runCmd ( DriverInterface $ driver , $ cmd , array $ args , Response $ response ) { $ data = null ; try { if ( $ driver -> isAllowedCommand ( $ cmd ) ) { $ data = call_user_func_array ( array ( $ driver , $ cmd ) , $ this -> getArgs ( $ args , $ cmd , $ response , $ driver -> getDriverId ( ) ) ) ; } else { $ this -> error ( sprintf ( 'command "%s" not allowed' , $ cmd ) ) ; } } catch ( Exception $ e ) { $ this -> error ( $ e -> getMessage ( ) ) ; } return $ data instanceof HttpResponse ? $ data : $ response ; }
run cmd .
6,031
private function addDisabledCommand ( AbstractDriver $ driver ) { foreach ( $ this -> commands as $ name => $ command ) { $ interface = $ this -> getInterfaceByCmd ( $ name ) ; if ( ! $ driver instanceof $ interface ) { $ driver -> addDisabledCmd ( $ name ) ; } } return $ this ; }
add Disabled Command .
6,032
private function getArgs ( array $ args , $ cmd , $ response , $ driverId ) { $ response = array ( $ response ) ; $ allowedArgs = $ this -> commands [ $ cmd ] ; unset ( $ allowedArgs [ 'interface' ] ) ; foreach ( $ allowedArgs as $ key => $ value ) { if ( isset ( $ args [ $ key ] ) ) { $ response [ $ key ] = $ args [ $ key ] ; if ( isset ( $ this -> filenameInRequest [ $ key ] ) ) { $ response [ $ key ] = self :: getNameByTarget ( $ args [ $ key ] , $ driverId ) ; } elseif ( $ key == 'targets' ) { $ response [ $ key ] = array_map ( function ( $ val ) use ( $ driverId ) { return self :: getNameByTarget ( $ val , $ driverId ) ; } , $ args [ $ key ] ) ; } } elseif ( isset ( $ this -> defaultValues [ $ key ] ) ) { $ response [ $ key ] = $ this -> defaultValues [ $ key ] ; } elseif ( $ value ) { $ this -> error ( sprintf ( 'parameter "%s" in cmd "%s" required' , $ key , $ cmd ) ) ; } } return $ response ; }
get Allowed Arguments .
6,033
function checkPassword ( Userinfo $ userinfo ) { return $ this -> comparePassword ( $ userinfo -> password , $ this -> generateEncryptedPassword ( $ userinfo ) ) ; }
used by framework to ensure a password test
6,034
public function writeOctet ( $ n ) { if ( $ n < 0 || $ n > 255 ) { throw new \ InvalidArgumentException ( 'Octet out of range 0..255' ) ; } $ this -> flushBits ( ) ; $ this -> out .= chr ( $ n ) ; return $ this ; }
Write an integer as an unsigned 8 - bit value .
6,035
public function writeShort ( $ n ) { if ( $ n < 0 || $ n > 65535 ) { throw new \ InvalidArgumentException ( 'Octet out of range 0..65535' ) ; } $ this -> flushBits ( ) ; $ this -> out .= pack ( 'n' , $ n ) ; return $ this ; }
Write an integer as an unsigned 16 - bit value .
6,036
public function writeLong ( $ n ) { $ this -> flushBits ( ) ; $ this -> out .= implode ( '' , Writer :: chrByteSplit ( $ n , 4 ) ) ; return $ this ; }
Write an integer as an unsigned 32 - bit value .
6,037
public function writeLongLong ( $ n ) { $ this -> flushBits ( ) ; $ this -> out .= implode ( '' , Writer :: chrByteSplit ( $ n , 8 ) ) ; return $ this ; }
Write an integer as an unsigned 64 - bit value .
6,038
public function writeShortStr ( $ s ) { $ this -> flushBits ( ) ; if ( strlen ( $ s ) > 255 ) { throw new \ InvalidArgumentException ( 'String too long' ) ; } $ this -> writeOctet ( strlen ( $ s ) ) ; $ this -> out .= $ s ; return $ this ; }
Write a string up to 255 bytes long after encoding . Assume UTF - 8 encoding .
6,039
protected function setupViewer ( ) { $ this -> app -> bindShared ( 'viewer' , function ( $ app ) { $ view = $ app [ 'view' ] ; $ credentials = $ app [ 'credentials' ] ; $ navigation = $ app [ 'navigation' ] ; $ pageprovider = $ app [ 'pageprovider' ] ; $ name = $ app [ 'config' ] [ 'platform.name' ] ; $ inverse = $ app [ 'config' ] [ 'theme.inverse' ] ; return new Classes \ Viewer ( $ view , $ credentials , $ navigation , $ pageprovider , $ name , $ inverse ) ; } ) ; }
Setup the viewer class .
6,040
protected function registerCommentProvider ( ) { $ this -> app -> bindShared ( 'commentprovider' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'graham-campbell/cms-core::comment' ] ; $ comment = new $ model ( ) ; return new Providers \ CommentProvider ( $ comment ) ; } ) ; }
Register the comment provider class .
6,041
protected function registerEventProvider ( ) { $ this -> app -> bindShared ( 'eventprovider' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'graham-campbell/cms-core::event' ] ; $ event = new $ model ( ) ; return new Providers \ EventProvider ( $ event ) ; } ) ; }
Register the event provider class .
6,042
protected function registerPageProvider ( ) { $ this -> app -> bindShared ( 'pageprovider' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'graham-campbell/cms-core::page' ] ; $ page = new $ model ( ) ; return new Providers \ PageProvider ( $ page ) ; } ) ; }
Register the page provider class .
6,043
protected function registerPostProvider ( ) { $ this -> app -> bindShared ( 'postprovider' , function ( $ app ) { $ model = $ app [ 'config' ] [ 'graham-campbell/cms-core::post' ] ; $ post = new $ model ( ) ; return new Providers \ PostProvider ( $ post ) ; } ) ; }
Register the post provider class .
6,044
public function add ( $ sTitle , $ bPrepend = false ) { if ( $ bPrepend ) { $ this -> aTitles = array_reverse ( $ this -> aTitles , true ) ; $ this -> aTitles [ $ sTitle ] = $ sTitle ; $ this -> aTitles = array_reverse ( $ this -> aTitles , true ) ; } else { $ this -> aTitles [ $ sTitle ] = $ sTitle ; } }
Add a title tag to the titles tag stack .
6,045
public function has ( $ sTitle = null ) { if ( null === $ sTitle ) { return ! empty ( $ this -> aTitles ) ; } return isset ( $ this -> aTitles [ $ sTitle ] ) ; }
Indicate if a given title tag exists or if there are items in the titles tag stack .
6,046
protected function getSource ( $ packagePath ) { $ sources = [ "{$packagePath}/resources/database/migrations" , "{$packagePath}/resources/migrations" , "{$packagePath}/migrations" , ] ; foreach ( $ sources as $ source ) { if ( $ this -> files -> isDirectory ( $ source ) ) { $ paths = [ ] ; $ files = $ this -> getSourceFiles ( $ source ) ; foreach ( $ files as $ file ) { if ( ! class_exists ( $ this -> getClassFromFile ( $ file ) ) ) { $ paths [ $ file ] = $ this -> getDestinationPath ( 'migrations' , [ date ( 'Y_m_d_His' , time ( ) ) , $ this -> getFileName ( $ file ) , ] ) ; } } return $ paths ; } } throw new InvalidArgumentException ( 'Migrations not found.' ) ; }
Get the source assets directory to publish .
6,047
public function assetsAdd ( $ file ) { $ resource = '/assets.json' ; $ parameters = array ( 'file' => '@' . $ file , ) ; $ data = $ this -> auth -> request ( 'POST' , $ resource , $ parameters ) ; return $ data ; }
Add an asset
6,048
public function assetsGet ( $ id ) { $ resource = '/assets/' . $ id . '.json' ; $ data = $ this -> auth -> request ( 'GET' , $ resource ) ; return $ data ; }
Get an asset by id
6,049
public function assetsDelete ( $ id ) { $ resource = '/assets/' . $ id . '.json' ; $ data = $ this -> auth -> request ( 'DELETE' , $ resource ) ; return $ data ; }
Delete asset by id
6,050
public function assetsTagsAddById ( $ id , $ tag ) { $ resource = '/assets/' . $ id . '/tags/' . $ tag . '.json' ; $ parameters = array ( 'query' => array ( 'method' => 'link' ) , ) ; $ data = $ this -> auth -> request ( 'GET' , $ resource , $ parameters ) ; return $ data ; }
Add a tag to an asset by tag id
6,051
public function tagsList ( $ limit = 25 , $ offset = 0 ) { $ resource = '/tags.json' ; $ data = $ this -> auth -> request ( 'GET' , $ resource , array ( 'query' => array ( 'limit' => ( int ) $ limit , 'offset' => ( int ) $ offset ) ) ) ; return $ data ; }
Get a list of existing tags
6,052
public function ticketsGet ( $ id ) { $ resource = '/tickets/' . $ id . '.json' ; $ data = $ this -> auth -> request ( 'GET' , $ resource ) ; return $ data ; }
Get a ticket by id
6,053
public function tagAssetsList ( $ tagId , $ limit = 25 , $ offset = 0 ) { return $ this -> auth -> request ( 'GET' , '/tags/' . $ tagId . '/assets.json' , array ( 'query' => array ( 'limit' => ( int ) $ limit , 'offset' => ( int ) $ offset ) ) ) ; }
Get a list of assets coupled to a certain tag
6,054
public function channelsList ( $ limit = 25 , $ offset = 0 ) { return $ this -> auth -> request ( 'GET' , '/channels.json' , array ( 'query' => array ( 'limit' => ( int ) $ limit , 'offset' => ( int ) $ offset ) ) ) ; }
Get a list of existing channels
6,055
public function beforeDelete ( ) { $ this -> invites ( ) -> sync ( array ( ) ) ; $ this -> deletePages ( ) ; $ this -> deletePosts ( ) ; $ this -> deleteEvents ( ) ; $ this -> deleteComments ( ) ; }
Before deleting an existing model .
6,056
public static function success ( $ content , $ htmlOptions = array ( ) , $ close = '&times' ) { ArrayHelper :: addValue ( 'class' , Enum :: COLOR_SUCCESS , $ htmlOptions ) ; return static :: alert ( $ content , $ htmlOptions , $ close ) ; }
Generates a success alert
6,057
public static function important ( $ content , $ htmlOptions = array ( ) , $ close = '&times' ) { ArrayHelper :: addValue ( 'class' , Enum :: COLOR_ALERT , $ htmlOptions ) ; return static :: alert ( $ content , $ htmlOptions , $ close ) ; }
Generates an red coloured alert box
6,058
public static function secondary ( $ content , $ htmlOptions = array ( ) , $ close = '&times' ) { ArrayHelper :: addValue ( 'class' , Enum :: COLOR_SECONDARY , $ htmlOptions ) ; return static :: alert ( $ content , $ htmlOptions , $ close ) ; }
Generates a secondary alert box
6,059
public static function alert ( $ content , $ htmlOptions = array ( ) , $ close = '&times' ) { ArrayHelper :: addValue ( 'class' , 'alert-box' , $ htmlOptions ) ; ob_start ( ) ; echo '<div data-alert ' . \ CHtml :: renderAttributes ( $ htmlOptions ) . '>' ; echo $ content ; if ( $ close !== false ) echo static :: closeLink ( $ close ) ; echo '</div>' ; return ob_get_clean ( ) ; }
Returns an alert box
6,060
private function detachContentTypeGroupsByIdentifiers ( ContentType $ contentType , array $ contentTypeGroupsIdentifiers ) { $ contentTypeGroups = $ this -> loadContentTypeGroupsByIdentifiers ( $ contentTypeGroupsIdentifiers ) ; foreach ( $ contentTypeGroups as $ contentTypeGroup ) { $ this -> contentTypeService -> unassignContentTypeGroup ( $ contentType , $ contentTypeGroup ) ; } }
Load contenttype groups and unassign them from a contenttype .
6,061
protected function compile ( $ name ) { if ( ! isset ( $ this -> raw [ $ name ] ) ) { return ; } $ count = preg_match_all ( self :: ROUTE_PARAM_PATTERN , $ this -> raw [ $ name ] , $ matches , PREG_OFFSET_CAPTURE ) ; if ( $ count === 0 ) { $ this -> compiled [ $ name ] = $ this -> raw [ $ name ] ; } else if ( $ count > 0 ) { $ routePath = $ this -> raw [ $ name ] ; $ params = [ ] ; $ chunks = [ ] ; $ pos = 0 ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ chunks [ ] = substr ( $ routePath , $ pos , $ matches [ 1 ] [ $ i ] [ 1 ] - $ pos ) ; $ size = array_push ( $ chunks , '' ) ; $ params [ $ matches [ 2 ] [ $ i ] [ 0 ] ] = $ size - 1 ; $ pos = $ matches [ 1 ] [ $ i ] [ 1 ] + strlen ( $ matches [ 1 ] [ $ i ] [ 0 ] ) ; } $ chunks [ ] = substr ( $ routePath , $ pos ) ; $ this -> compiled [ $ name ] = [ 'params' => $ params , 'chunks' => $ chunks , ] ; } }
Compile raw route to a format for generation .
6,062
protected function getCompiledRoute ( $ name ) { if ( ! isset ( $ this -> compiled [ $ name ] ) ) { $ this -> compile ( $ name ) ; } return isset ( $ this -> compiled [ $ name ] ) ? $ this -> compiled [ $ name ] : null ; }
Get a compiled route .
6,063
protected function generatePath ( $ name , $ params = [ ] ) { $ result = '' ; $ compiledRoute = $ this -> getCompiledRoute ( $ name ) ; if ( is_string ( $ compiledRoute ) ) { $ result = $ compiledRoute ; } else if ( is_array ( $ compiledRoute ) ) { $ chunks = $ compiledRoute [ 'chunks' ] ; foreach ( $ params as $ paramName => $ value ) { if ( isset ( $ compiledRoute [ 'params' ] [ $ paramName ] ) ) { $ index = $ compiledRoute [ 'params' ] [ $ paramName ] ; $ chunks [ $ index ] = $ value ; } } $ result = implode ( $ chunks ) ; } return $ result ; }
Generate path from compiled route .
6,064
public static function select ( $ name , $ options , $ selected = NULL , Array $ attributes = NULL ) { $ name = self :: getName ( $ name ) ; if ( is_string ( $ options ) ) { } else { $ options = self :: selectOptions ( $ options , $ selected ) ; } $ select = static :: tag ( 'select' , $ options , $ attributes ) -> setAttribute ( 'name' , $ name ) -> setGlueContent ( "%s \n" ) ; return $ select ; }
Erstellt ein Select Element
6,065
public function create ( $ abstract , array $ options = [ ] ) { $ concrete = $ this -> getConcrete ( $ abstract ) ; if ( class_exists ( $ concrete ) ) { return new $ concrete ( $ options ) ; } throw new InvalidArgumentException ( "The gateway of [$abstract] not supported." ) ; }
Create an instance of the specified market driver .
6,066
public function fetchMessages ( $ clear = true ) { $ messages = $ this -> messages ; if ( $ clear ) { $ this -> clear ( ) ; } return $ messages ; }
Fetch the captured messages .
6,067
public function update ( $ count ) { update_post_meta ( $ this -> post_id , '_inc2734_count_cache_' . $ this -> service_name , [ 'count' => $ count , 'expiration' => time ( ) + ( int ) apply_filters ( 'inc2734_wp_share_buttons_count_cache_seconds' , 60 * 5 ) , ] ) ; }
Update count cache
6,068
public function only ( array $ keys ) : array { $ return = [ ] ; foreach ( $ keys as $ key ) { $ value = $ this -> get ( $ key ) ; if ( ! is_null ( $ value ) ) { $ return [ $ key ] = $ value ; } } return $ return ; }
Return specific items .
6,069
public function setAlign ( $ pValue = null ) { if ( strtolower ( $ pValue ) == 'justify' ) { $ pValue = 'both' ; } $ this -> _align = $ pValue ; return $ this ; }
Set Paragraph Alignment
6,070
public function addGrantType ( GrantTypeInterface $ grantType , $ identifier = null ) { if ( is_null ( $ identifier ) ) { $ identifier = $ grantType -> getIdentifier ( ) ; } $ grantType -> setAuthorizationServer ( $ this ) ; $ this -> grantTypes [ $ identifier ] = $ grantType ; if ( ! is_null ( $ grantType -> getResponseType ( ) ) ) { $ this -> responseTypes [ ] = $ grantType -> getResponseType ( ) ; } return $ this ; }
Enable support for a grant
6,071
public function issueAccessToken ( ) { $ grantType = $ this -> getRequest ( ) -> request -> get ( 'grant_type' ) ; if ( is_null ( $ grantType ) ) { throw new Exception \ InvalidRequestException ( 'grant_type' ) ; } if ( ! in_array ( $ grantType , array_keys ( $ this -> grantTypes ) ) ) { throw new Exception \ UnsupportedGrantTypeException ( $ grantType ) ; } return $ this -> getGrantType ( $ grantType ) -> completeFlow ( ) ; }
Issue an access token
6,072
public function getGrantType ( $ grantType ) { if ( isset ( $ this -> grantTypes [ $ grantType ] ) ) { return $ this -> grantTypes [ $ grantType ] ; } throw new Exception \ InvalidGrantException ( $ grantType ) ; }
Return a grant type class
6,073
public function renderButtons ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; $ buttons = array ( ) ; $ checked = $ this -> hasModel ( ) ? ( ! $ this -> model -> { $ this -> attribute } ) : true ; $ buttons [ ] = \ CHtml :: radioButton ( $ name , $ checked , array ( 'id' => $ id . '_on' , 'value' => 1 ) ) ; $ buttons [ ] = \ CHtml :: label ( $ this -> offLabel , $ id . '_on' ) ; $ checked = $ checked ? false : true ; $ buttons [ ] = \ CHtml :: radioButton ( $ name , $ checked , array ( 'id' => $ id . '_off' , 'value' => 1 ) ) ; $ buttons [ ] = \ CHtml :: label ( $ this -> onLabel , $ id . '_off' ) ; $ buttons [ ] = '<span></span>' ; return \ CHtml :: tag ( 'div' , $ this -> htmlOptions , implode ( "\n" , $ buttons ) ) ; }
Returns the formatted button
6,074
public function join ( Builder $ objBuilder , $ blnExpandSelection = false , iCondition $ objJoinCondition = null , Clause \ Select $ objSelect = null ) { $ objParentNode = $ this -> objParentNode ; $ objParentNode -> join ( $ objBuilder , $ blnExpandSelection , null , $ objSelect ) ; if ( $ objJoinCondition && ! $ objJoinCondition -> equalTables ( $ this -> fullAlias ( ) ) ) { throw new Caller ( "The join condition on the \"" . $ this -> strTableName . "\" table must only contain conditions for that table." ) ; } try { $ strParentAlias = $ objParentNode -> fullAlias ( ) ; $ strAlias = $ this -> fullAlias ( ) ; $ objBuilder -> addJoinItem ( $ this -> strTableName , $ strAlias , $ strParentAlias , $ objParentNode -> _PrimaryKey , $ this -> strPrimaryKey , $ objJoinCondition ) ; if ( $ blnExpandSelection ) { $ this -> putSelectFields ( $ objBuilder , $ strAlias , $ objSelect ) ; } } catch ( Caller $ objExc ) { $ objExc -> incrementOffset ( ) ; throw $ objExc ; } }
Join the node to the query . Join condition here gets applied to parent item .
6,075
public static function loadListeners ( ) { $ manager = self :: instance ( ) ; $ plugins = Plugin :: loaded ( ) ; foreach ( $ plugins as $ plugin ) { $ events = Plugin :: getData ( $ plugin , 'events' ) -> getArrayCopy ( ) ; foreach ( $ events as $ name => $ config ) { if ( is_numeric ( $ name ) ) { $ name = $ config ; $ config = [ ] ; } $ class = App :: className ( $ name , 'Event' ) ; $ config = ( array ) $ config ; if ( $ class !== false ) { $ listener = new $ class ( $ config ) ; $ manager -> on ( $ listener , $ config ) ; } } } }
Load Event Handlers during bootstrap .
6,076
public function getDatabase ( $ key ) { if ( array_key_exists ( $ key , $ this -> database ) ) { return $ this -> database [ $ key ] ; } return false ; }
Get the database details or false on failure
6,077
public function setDatabase ( $ name , $ user , $ pass , $ host = 'localhost' , $ port = 3306 ) { $ this -> database [ 'name' ] = $ name ; $ this -> database [ 'user' ] = $ user ; $ this -> database [ 'pass' ] = $ pass ; $ this -> database [ 'host' ] = $ host ; $ this -> database [ 'port' ] = $ port ; return $ this ; }
Set the database details
6,078
public function setDatabaseUrl ( $ url ) { $ parts = parse_url ( $ url ) ; $ this -> database [ 'name' ] = trim ( $ parts [ 'path' ] , '/' ) ; $ this -> database [ 'user' ] = $ parts [ 'user' ] ; $ this -> database [ 'pass' ] = $ parts [ 'pass' ] ; $ this -> database [ 'host' ] = $ parts [ 'host' ] ; $ this -> database [ 'port' ] = $ parts [ 'port' ] ; return $ this ; }
Set the database details via URL
6,079
public function setDatabaseJdbc ( $ url , $ dir , $ class ) { $ this -> database [ 'url' ] = $ url ; $ this -> database [ 'dir' ] = $ dir ; $ this -> database [ 'class' ] = $ class ; return $ this ; }
Set the database JDBC details
6,080
public function filterBy ( $ mapper , $ condition ) { $ this -> operationChain -> append ( new FilterByPredicate ( $ mapper , $ condition ) ) ; return $ this ; }
Filters the input stream by passing each element first through the mapper and the to the condition
6,081
public function any ( $ condition ) { $ this -> filter ( $ condition ) ; $ tmp = new \ stdClass ( ) ; return $ this -> getFirst ( $ tmp ) !== $ tmp ; }
Returns true if at least one element matches the condition
6,082
public function all ( $ condition ) { return ! $ this -> any ( function ( $ elem , $ idx ) use ( $ condition ) { return ! $ condition ( $ elem , $ idx ) ; } ) ; }
Returns true if all elements match the condition
6,083
public static function compareDatetime ( $ a , $ b ) { $ timea = strtotime ( $ a ) ; $ timeb = strtotime ( $ b ) ; if ( $ timea === false || $ timeb === false ) { return false ; } if ( $ timea > $ timeb ) { return 1 ; } elseif ( $ timea < $ timeb ) { return - 1 ; } return 0 ; }
compare two datetime
6,084
public function setForm ( $ form ) { foreach ( $ this -> namedLinkCompositeField -> compositeDatabaseFields ( ) as $ field => $ spec ) { $ fieldHandle = 'field' . $ field ; $ this -> { $ fieldHandle } -> setForm ( $ form ) ; } parent :: setForm ( $ form ) ; return $ this ; }
Set the container form .
6,085
public function errors ( ) { if ( isset ( $ this -> data ) && isset ( $ this -> data [ "error_description" ] ) ) { return $ this -> data [ "error_description" ] ; } return null ; }
When the request was not successful this will return all the errors .
6,086
private function rememberFilesFactory ( $ files , $ prefix = '' ) { $ result = [ ] ; foreach ( $ files as $ key => $ file ) { $ cacheKey = $ prefix . ( empty ( $ prefix ) ? '' : '.' ) . $ key ; if ( is_string ( $ file ) ) { if ( ! $ this -> cache -> has ( '_remembered_files.' . $ cacheKey ) ) { continue ; } $ cached = $ this -> cache -> get ( '_remembered_files.' . $ cacheKey ) ; if ( $ cached instanceof RememberedFile ) { $ result [ $ key ] = $ cached ; } unset ( $ cached ) ; continue ; } if ( is_array ( $ file ) ) { $ result [ $ key ] = $ this -> rememberFilesFactory ( $ file , $ cacheKey ) ; } else { $ storagePathName = $ this -> storagePath . DIRECTORY_SEPARATOR . $ file -> getFilename ( ) ; copy ( $ file -> getPathname ( ) , $ storagePathName ) ; $ rememberedFile = new RememberedFile ( $ storagePathName , $ file ) ; $ this -> cache -> put ( '_remembered_files.' . $ cacheKey , $ rememberedFile , $ this -> cacheTimeout ) ; $ result [ $ key ] = $ rememberedFile ; } } return $ result ; }
Recursive factory method to create RememberedFile from UploadedFile .
6,087
protected function getItem ( $ foreignKey ) { $ name = empty ( $ foreignKey [ 'name' ] ) ? $ this -> createIndexName ( $ foreignKey [ 'field' ] ) : $ foreignKey [ 'name' ] ; return sprintf ( "\$table->dropForeign('%s');" , $ name ) ; }
Return string for dropping a foreign key
6,088
public function getNames ( ) { $ enums = [ ] ; foreach ( static :: toArray ( ) as $ name => $ value ) { if ( $ this -> has ( $ value ) ) { $ enums [ ] = $ name ; } } return $ enums ; }
Get an array of all the enum names this flag instance represents .
6,089
protected function getValuesFromFlagOrEnum ( $ flag ) { $ values = [ ] ; if ( $ flag instanceof static ) { foreach ( $ flag -> getNames ( ) as $ enum ) { $ values [ ] = static :: getNameValue ( $ enum ) ; } } elseif ( static :: isValidName ( ( string ) $ flag ) ) { $ values [ ] = static :: getNameValue ( ( string ) $ flag ) ; } elseif ( is_numeric ( $ flag ) ) { $ values [ ] = $ flag ; } return $ values ; }
Given an enum name enum value or flag enum instance get the array of values it represents .
6,090
public function getVersion ( ) { $ composer = $ this -> loadJsonFileFromRoot ( "composer.json" ) ; if ( ! isset ( $ composer -> version ) ) { throw new \ Exception ( "composer.json does not contain a version" ) ; } return $ composer -> version ; }
Returns the project s version
6,091
public function getWebDriverProxyConfig ( ) { $ this -> requireOpenConnection ( ) ; $ address = new HttpAddress ( $ this -> getUrl ( ) ) ; return array ( 'proxyType' => 'manual' , 'httpProxy' => $ address -> hostname . ':' . $ this -> getPort ( ) , 'sslProxy' => $ address -> hostname . ':' . $ this -> getPort ( ) ) ; }
Returns the config information that needs to be given to webdriver to make it use browsermob - proxy
6,092
public function setHeaders ( $ headers ) { $ this -> requireOpenConnection ( ) ; $ response = $ this -> curl ( 'POST' , '/proxy/' . $ this -> port . '/headers' , ( object ) $ headers ) ; }
inject a set of headers into all subsequent requests
6,093
public function removeHeader ( $ name ) { $ this -> requireOpenConnection ( ) ; $ this -> requireFeature ( 'headerGetDelete' ) ; $ response = $ this -> curl ( 'DELETE' , '/proxy/' . $ this -> port . '/header/' . urlencode ( $ name ) ) ; }
remove a header from the list of headers that browsermob - proxy injects for us
6,094
public function removeAllHeaders ( ) { $ this -> requireOpenConnection ( ) ; $ this -> requireFeature ( 'headerGetDelete' ) ; $ response = $ this -> curl ( 'DELETE' , '/proxy/' . $ this -> port . '/headers' ) ; }
remove all of the headers that browsermob - proxy injects for us
6,095
public function setHttpBasicAuth ( $ domain , $ username , $ password ) { $ this -> requireOpenConnection ( ) ; $ this -> requireFeature ( 'authBasic' ) ; $ response = $ this -> curl ( 'PUT' , '/proxy/' . $ this -> port . '/auth/basic/' . urlencode ( $ domain ) , array ( 'username' => $ username , 'password' => $ password ) ) ; }
enable HTTP BASIC auth
6,096
public function close ( ) { $ this -> requireOpenConnection ( ) ; $ response = $ this -> curl ( 'DELETE' , '/proxy/' . $ this -> port ) ; $ this -> closed = true ; }
delete the proxy because we re done
6,097
public function title ( $ string , $ backgorund = 'blue' , $ forgeground = 'white' ) { $ string = $ this -> paintString ( " {$string} " , $ forgeground , $ backgorund ) ; echo $ string . "\n\r" ; }
Write title output .
6,098
protected function create ( $ name ) { $ c = $ this -> avaibleModules [ $ name ] [ 'class' ] ; $ module = new $ c ( $ this -> project , $ this -> inTests ) ; $ module -> setName ( $ name ) ; $ this -> modules [ $ name ] = $ module ; PSC :: getEventManager ( ) -> dispatchEvent ( 'Psc.ModuleCreated' , NULL , $ module ) ; return $ module ; }
Erstellt ein neues Modul
6,099
private function toArray ( DOMElement $ node ) { $ value = null ; switch ( $ node -> nodeName ) { case 'array' : $ value = array ( ) ; if ( $ node -> hasChildNodes ( ) ) { for ( $ i = 0 ; $ i < $ node -> childNodes -> length ; $ i ++ ) { $ child = $ node -> childNodes -> item ( $ i ) ; if ( $ child -> hasAttribute ( 'key' ) ) { $ value [ $ child -> getAttribute ( 'key' ) ] = $ this -> toArray ( $ child ) ; } else { $ value [ ] = $ this -> toArray ( $ child ) ; } } } break ; case 'bool' : $ value = ( bool ) $ node -> textContent ; break ; case 'float' : $ value = ( float ) $ node -> textContent ; break ; case 'int' : $ value = ( int ) $ node -> textContent ; break ; case 'str' : $ value = $ node -> textContent ; break ; } return $ value ; }
Converts a DOM elements to native PHP values .