idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
19,200
public function validate ( $ entity , $ entityName = null ) { $ entityName = $ entityName ? : 'root' ; $ this -> validateType ( $ entity , $ this -> schema , $ entityName ) ; return $ this ; }
Validate schema object
19,201
public function checkFormat ( $ entity , $ schema , $ entityName ) { if ( ! isset ( $ schema -> format ) ) { return $ this ; } $ valid = true ; switch ( $ schema -> format ) { case 'date-time' : if ( ! preg_match ( '#^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$#' , $ entity ) ) { $ valid = false ; } break ; case 'date' : if ...
Check format restriction
19,202
protected function validateProperties ( $ entity , $ schema , $ entityName ) { $ properties = get_object_vars ( $ entity ) ; if ( ! isset ( $ schema -> properties ) ) { return $ this ; } foreach ( $ schema -> properties as $ propertyName => $ property ) { if ( array_key_exists ( $ propertyName , $ properties ) ) { $ pa...
Validate object properties
19,203
protected function validateType ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> type ) ) { $ types = $ schema -> type ; } else { $ types = 'any' ; } if ( ! is_array ( $ types ) ) { $ types = array ( $ types ) ; } $ valid = false ; foreach ( $ types as $ type ) { switch ( $ type ) { case 'object' : if ...
Validate entity type
19,204
protected function checkTypeObject ( $ entity , $ schema , $ entityName ) { $ this -> validateProperties ( $ entity , $ schema , $ entityName ) ; return $ this ; }
Check object type
19,205
protected function checkTypeNumber ( $ entity , $ schema , $ entityName ) { $ this -> checkMinimum ( $ entity , $ schema , $ entityName ) ; $ this -> checkMaximum ( $ entity , $ schema , $ entityName ) ; $ this -> checkExclusiveMinimum ( $ entity , $ schema , $ entityName ) ; $ this -> checkExclusiveMaximum ( $ entity ...
Check number type
19,206
protected function checkTypeString ( $ entity , $ schema , $ entityName ) { $ this -> checkPattern ( $ entity , $ schema , $ entityName ) ; $ this -> checkMinLength ( $ entity , $ schema , $ entityName ) ; $ this -> checkMaxLength ( $ entity , $ schema , $ entityName ) ; $ this -> checkFormat ( $ entity , $ schema , $ ...
Check string type
19,207
protected function checkTypeArray ( $ entity , $ schema , $ entityName ) { $ this -> checkMinItems ( $ entity , $ schema , $ entityName ) ; $ this -> checkMaxItems ( $ entity , $ schema , $ entityName ) ; $ this -> checkUniqueItems ( $ entity , $ schema , $ entityName ) ; $ this -> checkEnum ( $ entity , $ schema , $ e...
Check array type
19,208
protected function checkTypeAny ( $ entity , $ schema , $ entityName ) { $ this -> checkDisallow ( $ entity , $ schema , $ entityName ) ; return $ this ; }
Check any type
19,209
protected function checkMinimum ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> minimum ) ) { if ( $ entity < $ schema -> minimum ) { throw new ValidationException ( sprintf ( 'Invalid value for [%s], minimum is [%s]' , $ entityName , $ schema -> minimum ) ) ; } } return $ this ; }
Check minimum value
19,210
protected function checkMaximum ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> maximum ) ) { if ( $ entity > $ schema -> maximum ) { throw new ValidationException ( sprintf ( 'Invalid value for [%s], maximum is [%s]' , $ entityName , $ schema -> maximum ) ) ; } } return $ this ; }
Check maximum value
19,211
protected function checkExclusiveMinimum ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> minimum ) && isset ( $ schema -> exclusiveMinimum ) && $ schema -> exclusiveMinimum ) { if ( $ entity == $ schema -> minimum ) { throw new ValidationException ( sprintf ( 'Invalid value for [%s], must be greater t...
Check exlusive minimum requirement
19,212
protected function checkExclusiveMaximum ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> maximum ) && isset ( $ schema -> exclusiveMaximum ) && $ schema -> exclusiveMaximum ) { if ( $ entity == $ schema -> maximum ) { throw new ValidationException ( sprintf ( 'Invalid value for [%s], must be less than...
Check exclusive maximum requirement
19,213
protected function checkPattern ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> pattern ) && $ schema -> pattern ) { if ( ! preg_match ( $ schema -> pattern , $ entity ) ) { throw new ValidationException ( sprintf ( 'String does not match pattern for [%s]' , $ entityName ) ) ; } } return $ this ; }
Check value against regex pattern
19,214
protected function checkMinLength ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> minLength ) && $ schema -> minLength ) { if ( strlen ( $ entity ) < $ schema -> minLength ) { throw new ValidationException ( sprintf ( 'String too short for [%s], minimum length is [%s]' , $ entityName , $ schema -> min...
Check string minimum length
19,215
protected function checkMaxLength ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> maxLength ) && $ schema -> maxLength ) { if ( strlen ( $ entity ) > $ schema -> maxLength ) { throw new ValidationException ( sprintf ( 'String too long for [%s], maximum length is [%s]' , $ entityName , $ schema -> maxL...
Check string maximum length
19,216
protected function checkMinItems ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> minItems ) && $ schema -> minItems ) { if ( count ( $ entity ) < $ schema -> minItems ) { throw new ValidationException ( sprintf ( 'Not enough array items for [%s], minimum is [%s]' , $ entityName , $ schema -> minItems ...
Check array minimum items
19,217
protected function checkMaxItems ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> maxItems ) && $ schema -> maxItems ) { if ( count ( $ entity ) > $ schema -> maxItems ) { throw new ValidationException ( sprintf ( 'Too many array items for [%s], maximum is [%s]' , $ entityName , $ schema -> maxItems ) ...
Check array maximum items
19,218
protected function checkUniqueItems ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> uniqueItems ) && $ schema -> uniqueItems ) { if ( count ( array_unique ( $ entity ) ) != count ( $ entity ) ) { throw new ValidationException ( sprintf ( 'All items in array [%s] must be unique' , $ entityName ) ) ; } ...
Check array unique items
19,219
protected function checkEnum ( $ entity , $ schema , $ entityName ) { $ valid = true ; if ( isset ( $ schema -> enum ) && $ schema -> enum ) { if ( ! is_array ( $ schema -> enum ) ) { throw new SchemaException ( sprintf ( 'Enum property must be an array for [%s]' , $ entityName ) ) ; } if ( is_array ( $ entity ) ) { fo...
Check enum restriction
19,220
protected function checkItems ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> items ) && $ schema -> items ) { if ( is_array ( $ schema -> items ) ) { foreach ( $ entity as $ index => $ node ) { $ nodeEntityName = $ entityName . '[' . $ index . ']' ; foreach ( $ schema -> items as $ item ) { $ nodeVal...
Check items restriction
19,221
protected function checkDisallow ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> disallow ) && $ schema -> disallow ) { $ thisSchema = clone $ schema ; $ thisSchema -> type = $ schema -> disallow ; unset ( $ thisSchema -> disallow ) ; try { $ valid = false ; $ this -> validateType ( $ entity , $ thisS...
Check disallowed entity type
19,222
protected function checkDivisibleBy ( $ entity , $ schema , $ entityName ) { if ( isset ( $ schema -> divisibleBy ) && $ schema -> divisibleBy ) { if ( ! is_numeric ( $ schema -> divisibleBy ) ) { throw new SchemaException ( sprintf ( 'Invalid divisibleBy value for [%s], must be numeric' , $ entityName ) ) ; } if ( $ e...
Check divisibleby restriction
19,223
public function addMeta ( $ key , $ data = null ) { if ( is_array ( $ key ) ) { $ this -> meta += $ key ; } else { $ this -> meta [ $ key ] = $ data ; } return $ this ; }
add additional meta data to transformed data .
19,224
public function excludes ( $ excludes ) { if ( is_string ( $ excludes ) ) { $ excludes = explode ( ',' , $ excludes ) ; } if ( $ this -> autoload and $ this -> request -> get ( $ this -> exclude_key ) ) { $ excludes = array_merge ( $ excludes , explode ( ',' , $ this -> request -> get ( $ this -> exclude_key ) ) ) ; } ...
excludes sub level from data transformer .
19,225
public function includes ( $ includes ) { if ( is_string ( $ includes ) ) { $ includes = explode ( ',' , $ includes ) ; } if ( $ this -> autoload and $ this -> request -> get ( $ this -> input_key ) ) { $ includes = array_merge ( $ includes , explode ( ',' , $ this -> request -> get ( $ this -> input_key ) ) ) ; } $ th...
includes sub level data transformer .
19,226
private function scope ( ResourceInterface $ resource ) { return new ScopeDataAdapter ( $ this -> manager -> parseFieldsets ( $ this -> fieldsets ) -> createData ( $ resource ) ) ; }
return result scope .
19,227
public function addStr ( $ str ) { $ str = str_replace ( $ this -> tab , '' , $ str ) ; $ this -> outputStringArray [ ] = str_repeat ( $ this -> tab , $ this -> tabLevel ) . $ str ; }
Adds string to output string array with tab prefix
19,228
protected function getCasting ( $ type ) { if ( $ type instanceof \ Doctrine \ DBAL \ Types \ DecimalType or $ type instanceof \ Doctrine \ DBAL \ Types \ FloatType ) { return 'double' ; } else { if ( $ type instanceof \ Doctrine \ DBAL \ Types \ IntegerType or $ type instanceof \ Doctrine \ DBAL \ Types \ BigIntType o...
get value cast type .
19,229
public function transform ( $ data , $ transformer = null , $ resourceKey = null , PaginatorInterface $ adapter = null ) { if ( ! $ transformer ) { $ transformer = $ this -> getTransformer ( ) ; } $ fractal = $ this -> getService ( ) ; if ( $ this -> isCollection ( $ data ) ) { return $ fractal -> collection ( $ data ,...
transform data .
19,230
protected function getTransformer ( ) { if ( property_exists ( $ this , $ transformer = $ this -> getTransformerProperty ( ) ) ) { return app ( $ this -> { $ transformer } ) ; } return false ; }
get transformer defined in class scope .
19,231
protected function isCollection ( $ data ) { if ( is_array ( $ data ) || $ data instanceof \ Illuminate \ Support \ Collection || $ data instanceof Paginator ) { return true ; } $ length = count ( $ this -> getCollectionClass ( ) ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ class = \ Illuminate \ Support \ Arr :: ...
determine if an object should be recognize as collection .
19,232
public static function initialize ( ) { if ( static :: $ isConfigurationLoaded === true ) { return ; } foreach ( static :: $ handlers as $ handler ) { EventManager :: getInstance ( ) -> addEventHandler ( $ handler [ 0 ] , $ handler [ 1 ] , $ handler [ 2 ] , $ handler [ 3 ] ) ; } static :: $ isConfigurationLoaded = true...
Initialize . Register handlers of the Bitrix events .
19,233
public function resolveBindings ( array $ vars ) { if ( count ( $ vars ) > 1 && ! empty ( $ this -> compositeBindings ) ) { if ( $ r = $ this -> resolveCompositeBinding ( $ vars ) ) { return $ r ; } } if ( ! empty ( $ this -> implicitBindings ) || ! empty ( $ this -> bindings ) ) { foreach ( $ vars as $ var => $ value ...
Resolve bindings for route parameters
19,234
protected function resolveCompositeBinding ( $ vars ) { $ keys = array_keys ( $ vars ) ; foreach ( $ this -> compositeBindings as $ binding ) { if ( $ keys === $ binding [ 0 ] ) { $ binder = $ binding [ 1 ] ; $ errorHandler = $ binding [ 2 ] ; $ callable = $ this -> getBindingCallable ( $ binder , null ) ; $ r = $ this...
Check for and resolve the composite bindings if a match found
19,235
protected function resolveBinding ( $ key , $ value ) { if ( isset ( $ this -> bindings [ $ key ] ) ) { list ( $ binder , $ errorHandler ) = $ this -> bindings [ $ key ] ; $ callable = $ this -> getBindingCallable ( $ binder , $ value ) ; return $ this -> callBindingCallable ( $ callable , $ value , $ errorHandler ) ; ...
Resolve binding for the given wildcard
19,236
protected function getBindingCallable ( $ binder , $ value ) { if ( is_callable ( $ binder ) ) { return $ binder ; } elseif ( is_string ( $ binder ) ) { if ( strpos ( $ binder , '@' ) === false ) { $ class = $ binder ; $ method = null ; } else { list ( $ class , $ method ) = explode ( '@' , $ binder ) ; } if ( ! class_...
Get the callable for the binding
19,237
protected function getDefaultBindingResolver ( $ instance , $ value ) { $ instance = $ instance -> where ( $ instance -> getRouteKeyName ( ) , $ value ) ; return function ( ) use ( $ instance ) { return $ instance -> firstOrFail ( ) ; } ; }
Get the default binding resolver callable
19,238
public function implicitBind ( $ namespace , $ prefix = '' , $ suffix = '' , $ method = null , callable $ errorHandler = null ) { $ this -> implicitBindings [ ] = compact ( 'namespace' , 'prefix' , 'suffix' , 'method' , 'errorHandler' ) ; }
Implicit bind all models in the given namespace
19,239
public function dispatch ( $ httpMethod , $ uri ) { if ( $ this -> routesResolver ) { list ( $ this -> staticRouteMap , $ this -> variableRouteData ) = call_user_func ( $ this -> routesResolver ) ; } return parent :: dispatch ( $ httpMethod , $ uri ) ; }
Dispatch the request after getting the routes data if not set at the instantiation .
19,240
protected function dispatchVariableRoute ( $ routeData , $ uri ) { $ routeInfo = parent :: dispatchVariableRoute ( $ routeData , $ uri ) ; if ( $ this -> bindingResolver && isset ( $ routeInfo [ 2 ] ) ) { $ routeInfo [ 2 ] = $ this -> bindingResolver -> resolveBindings ( $ routeInfo [ 2 ] ) ; } return $ routeInfo ; }
Dispatch the route and it s variables then resolve the route bindings .
19,241
public static function runCacheCollector ( $ iblockType = null , $ iblockCode = null ) { if ( ! $ iblockType || ! $ iblockCode ) { $ iblock = IblockTable :: query ( ) -> setFilter ( [ '!CODE' => false ] ) -> setLimit ( 1 ) -> setSelect ( [ 'IBLOCK_TYPE_ID' , 'CODE' ] ) -> exec ( ) -> fetch ( ) ; $ iblockType = $ iblock...
Preliminary collection of cache .
19,242
private function normalizeStylesheetsProperty ( ) { if ( empty ( $ this -> pluginOptions [ 'stylesheets' ] ) ) $ this -> pluginOptions [ 'stylesheets' ] = array ( ) ; else if ( is_array ( $ this -> pluginOptions [ 'stylesheets' ] ) ) $ this -> pluginOptions [ 'stylesheets' ] = array_filter ( $ this -> pluginOptions [ '...
Normalizes stylesheet property
19,243
public function getBuyablePrice ( $ options = null ) { if ( property_exists ( $ this , 'price' ) ) return $ this -> price ; if ( property_exists ( $ this , 'cost' ) ) return $ this -> cost ; if ( property_exists ( $ this , 'value' ) ) return $ this -> value ; return null ; }
Get the price of the Buyable item .
19,244
public function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; $ cs -> registerCssFile ( $ assetsUrl . '/css/bootstrap-formhelpers.css' ) ; $ cs -> registerScriptFile ( $ assetsU...
Registers client script
19,245
protected function connect ( $ username , $ password , $ connectionString = null , $ characterSet = null , $ sessionMode = null ) { set_error_handler ( static :: getErrorHandler ( ) ) ; $ connection = oci_new_connect ( $ username , $ password , $ connectionString , $ characterSet , $ sessionMode ) ; restore_error_handl...
Connect to the Oracle server using a unique connection
19,246
public function renderField ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; TbArray :: defaultValue ( 'id' , $ id , $ this -> htmlOptions ) ; TbArray :: defaultValue ( 'name' , $ name , $ this -> htmlOptions ) ; $ this -> pluginOptions [ 'id' ] = $ this -> htmlOptions [ 'id' ] . '_switch' ; echo CHtml :: o...
Renders the typeahead field
19,247
public function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; $ min = $ this -> debugMode ? '.min' : '' ; $ cs -> registerCssFile ( $ assetsUrl . '/css/bootstrap-switch.css' ) ;...
Registers required client script for bootstrap typeahead . It is not used through bootstrap - > registerPlugin in order to attach events if any
19,248
public function getColumnByName ( $ name ) { foreach ( $ this -> columns as $ column ) { if ( strcmp ( $ column -> name , $ name ) === 0 ) { return $ column ; } } return null ; }
Helper function to get a column by its name
19,249
protected function parseColumnValue ( $ column , $ row ) { ob_start ( ) ; $ column -> renderDataCell ( $ row ) ; $ value = ob_get_clean ( ) ; if ( $ column instanceof CDataColumn && array_key_exists ( $ column -> name , $ this -> extendedSummary [ 'columns' ] ) ) { $ config = $ this -> extendedSummary [ 'columns' ] [ $...
Parses the value of a column by an operation
19,250
public function renderTag ( ) { echo CHtml :: tag ( $ this -> tagName , $ this -> htmlOptions , '<noscript>' . $ this -> noScriptText . '</noscript>' , true ) ; }
Renders the tag where the button is going to be rendered
19,251
private function setLocale ( $ locale ) { $ path = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'php' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR . $ locale . '.php' ; if ( ! file_exists ( $ path ) ) { $ this -> locale = 'en' ; $ path = __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY...
Includes file with locale - specific data array . When locale isnt exists used default en locale
19,252
public function formatTimeago ( $ value ) { if ( $ value instanceof DateTime ) { $ value = date_timestamp_get ( $ value ) ; } else if ( ! is_numeric ( $ value ) && is_string ( $ value ) ) { $ value = strtotime ( $ value ) ; } return $ this -> inWords ( ( time ( ) - $ value ) ) ; }
Formats value in timeago formatted string
19,253
public function inWords ( $ seconds ) { $ prefix = $ this -> data [ 'prefixAgo' ] ; $ suffix = $ this -> data [ 'suffixAgo' ] ; if ( $ this -> allowFuture && $ seconds < 0 ) { $ prefix = $ this -> data [ 'prefixFromNow' ] ; $ suffix = $ this -> data [ 'suffixFromNow' ] ; } $ seconds = abs ( $ seconds ) ; $ minutes = $ ...
Converts time delta to timeago formatted string
19,254
public function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; $ cs -> registerScriptFile ( $ assetsUrl . '/js/ace.js' , CClientScript :: POS_END ) ; $ id = TbArray :: getValue (...
Registers required client script for bootstrap ace editor .
19,255
public function registerClientScript ( ) { $ this -> registerGalleryScriptFiles ( ) ; $ items = CJavaScript :: encode ( $ this -> items ) ; $ options = CJavaScript :: encode ( $ this -> pluginOptions ) ; $ js = ";blueimp.Gallery({$items}, {$options});" ; Yii :: app ( ) -> clientScript -> registerScript ( __CLASS__ . '#...
Registers the script
19,256
private function setDaysOfWeekNames ( ) { if ( empty ( $ this -> pluginOptions [ 'locale' ] [ 'daysOfWeek' ] ) ) { $ this -> pluginOptions [ 'locale' ] [ 'daysOfWeek' ] = Yii :: app ( ) -> locale -> getWeekDayNames ( 'narrow' , true ) ; } }
Sets days of week names if no locale settings were made to the plugin options .
19,257
protected function renderItem ( $ options , $ templateData ) { $ apply = ! empty ( $ options [ 'name' ] ) && ( ! isset ( $ options [ 'editable' ] ) || $ options [ 'editable' ] !== false ) ; if ( $ apply ) { if ( ! isset ( $ options [ 'editable' ] ) ) $ options [ 'editable' ] = array ( ) ; $ options [ 'editable' ] = CMa...
Renders an item
19,258
protected function loadModel ( $ id ) { if ( empty ( $ this -> additionalCriteriaOnLoadModel ) ) { $ model = CActiveRecord :: model ( $ this -> modelName ) -> findByPk ( $ id ) ; } else { $ finder = CActiveRecord :: model ( $ this -> modelName ) ; $ c = new CDbCriteria ( $ this -> additionalCriteriaOnLoadModel ) ; $ c ...
Loads the requested data model .
19,259
public function getTax ( ) { $ rate = $ this -> taxRate / 100 ; $ value = $ this -> price -> multiply ( $ rate ) ; return $ value ; }
Returns the tax for one single item .
19,260
public function setTaxRate ( $ taxRate ) { if ( empty ( $ taxRate ) || ! is_numeric ( $ taxRate ) ) { throw new \ InvalidArgumentException ( 'Please supply a valid tax rate.' ) ; } $ this -> taxRate = $ taxRate ; return $ this ; }
Set the tax rate .
19,261
public function getYiiWheels ( ) { if ( self :: $ _wheels === null ) { self :: $ _wheels = Yii :: app ( ) -> getComponent ( 'yiiwheels' ) ; } return self :: $ _wheels ; }
Returns the main component
19,262
public function renderField ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; if ( $ this -> hasModel ( ) ) { echo CHtml :: activeHiddenField ( $ this -> model , $ this -> attribute , $ this -> htmlOptions ) ; } else { echo CHtml :: hiddenField ( $ name , $ this -> value , $ this -> htmlOptions ) ; } echo '<...
Renders field and tag
19,263
public function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ id = TbArray :: getValue ( 'id' , $ this -> htmlOptions , $ this -> getId ( ) ) ; $ jsFile = ! empty ( $ this -> scales ) ? 'jQAllRangeSliders-withRuler-min.js'...
Registers required files and initialization script
19,264
protected function buildOptions ( ) { $ options = array ( 'arrows' => $ this -> arrows , 'delayOut' => $ this -> delayOut , 'durationIn' => $ this -> durationIn , 'durationOut' => $ this -> durationOut , 'valueLabels' => $ this -> valueLabels , 'formatter' => $ this -> formatter , 'step' => $ this -> step , 'wheelMode'...
Builds the options
19,265
protected function checkOptionAttribute ( $ attribute , $ availableOptions , $ name ) { if ( ! in_array ( $ attribute , $ availableOptions ) ) { throw new CException ( Yii :: t ( 'zii' , 'Unsupported "{attribute}" setting.' , array ( '{attribute}' => $ name ) ) ) ; } }
Checks whether the option set is supported by the plugin
19,266
public function renderField ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; TbArray :: defaultValue ( 'id' , $ id , $ this -> htmlOptions ) ; TbArray :: defaultValue ( 'name' , $ name , $ this -> htmlOptions ) ; if ( $ this -> hasModel ( ) ) { echo $ this -> asDropDownList ? TbHtml :: activeDropDownList ( ...
Renders the select2 field
19,267
protected function connect ( $ username , $ password , $ connectionString = null , $ characterSet = null , $ sessionMode = null ) { set_error_handler ( $ this -> getErrorHandler ( ) ) ; $ connection = oci_pconnect ( $ username , $ password , $ connectionString , $ characterSet , $ sessionMode ) ; restore_error_handler ...
Connect to an Oracle database using a persistent connection
19,268
public function renderField ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; TbArray :: defaultValue ( 'id' , $ id , $ this -> htmlOptions ) ; TbArray :: defaultValue ( 'name' , $ name , $ this -> htmlOptions ) ; $ this -> htmlOptions [ 'multiple' ] = 'multiple' ; if ( $ this -> hasModel ( ) ) { echo CHtml ...
Renders the multiselect field
19,269
public function formatMoney ( Money $ value ) { $ currencies = new ISOCurrencies ( ) ; $ moneyFormatter = new DecimalMoneyFormatter ( $ currencies ) ; return $ moneyFormatter -> format ( $ value ) ; }
Format a money string
19,270
public function renderTemplate ( ) { $ options = array ( 'id' => $ this -> htmlOptions [ 'id' ] . '-gallery' , 'class' => 'blueimp-gallery' ) ; if ( $ this -> displayControls ) { TbHtml :: addCssClass ( 'blueimp-gallery-controls' , $ options ) ; } echo CHtml :: openTag ( 'div' , $ options ) ; echo '<div class="slides">...
Renders gallery template
19,271
public function registerGalleryScriptFiles ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; $ cs -> registerScriptFile ( $ assetsUrl . '/js/blueimp-gallery.min.js' , CClientScript :: POS_END ) ; $ cs -...
Registers gallery script files
19,272
public function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; $ cs -> registerScriptFile ( $ assetsUrl . '/js/jquery.mask.js' ) ; $ selector = '#' . TbArray :: getValue ( 'id' ,...
Registers required client script for jquery mask plugin . It doesn t use bootstrap - > registerPlugin .
19,273
private function getButtonLabel ( $ value ) { return $ value === null ? $ this -> emptyButtonLabel : ( $ value ? $ this -> checkedButtonLabel : $ this -> uncheckedButtonLabel ) ; }
Returns the button label
19,274
public function getAssetsUrl ( ) { if ( isset ( $ this -> _assetsUrl ) ) { return $ this -> _assetsUrl ; } else { $ forceCopyAssets = $ this -> getApi ( ) -> forceCopyAssets ; $ path = Yii :: getPathOfAlias ( 'yiiwheels' ) ; $ assetsUrl = Yii :: app ( ) -> assetManager -> publish ( $ path . DIRECTORY_SEPARATOR . 'asset...
Returns the assets URL . Assets folder has few orphan and very useful utility libraries .
19,275
public function registerAssetJs ( $ jsFile , $ position = CClientScript :: POS_END ) { Yii :: app ( ) -> getClientScript ( ) -> registerScriptFile ( $ this -> getAssetsUrl ( ) . "/js/{$jsFile}" , $ position ) ; return $ this ; }
Register a specific js file in the asset s js folder
19,276
public function registerAssetCss ( $ cssFile , $ media = '' ) { Yii :: app ( ) -> getClientScript ( ) -> registerCssFile ( $ this -> getAssetsUrl ( ) . "/css/{$cssFile}" , $ media ) ; return $ this ; }
Registers a specific css in the asset s css folder
19,277
public function renderField ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; echo CHtml :: openTag ( $ this -> tagName , array ( 'id' => 'wrapper-' . $ id ) ) ; if ( $ this -> hasModel ( ) ) { echo CHtml :: activeCheckBox ( $ this -> model , $ this -> attribute , $ this -> htmlOptions ) ; } else { echo CHtm...
Renders the input field
19,278
protected function registerClientScript ( ) { $ path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ assetsUrl = $ this -> getAssetsUrl ( $ path ) ; $ cs = Yii :: app ( ) -> clientScript ; $ cs -> registerCoreScript ( 'jquery' ) ; $ cs -> registerCssFile ( $ assetsUrl . '/css/bootstrap-toggle-buttons.css' )...
Registers client scripts
19,279
public function load ( $ identifier , $ name = null ) { $ name = $ name ? : self :: DEFAULT_NAME ; $ classname = config ( 'shoppingcart.models.shoppingcart' ) ; $ shoppingcart = $ classname :: firstOrNew ( $ this -> defaultValues ( $ identifier , $ name ) ) ; return $ shoppingcart ; }
Load a cart from the database . If no cart exists an empty cart is returned
19,280
public function removeItem ( $ row ) { $ content = $ this -> getContent ( ) ; if ( $ content -> has ( $ row ) ) { $ content -> pull ( $ row ) ; $ this -> content = serialize ( $ content ) ; $ this -> save ( ) ; } return $ this ; }
Remove a specified row from the shoppingcart
19,281
protected function renderHeaderCellContent ( ) { if ( $ this -> grid -> enableSorting && $ this -> sortable && $ this -> name !== null ) { $ sort = $ this -> grid -> dataProvider -> getSort ( ) ; $ label = isset ( $ this -> header ) ? $ this -> header : $ sort -> resolveLabel ( $ this -> name ) ; if ( $ sort -> resolve...
Require this overwrite to show bootstrap sort icons
19,282
private function buildInputFilterFromForm ( InputFilterInterface $ inputFilter ) : void { foreach ( $ this -> getNodeList ( ) as $ name => $ node ) { if ( $ inputFilter -> has ( $ name ) ) { continue ; } $ type = $ node -> getAttribute ( 'type' ) ; if ( $ node -> tagName === 'textarea' ) { $ type = 'textarea' ; } elsei...
Build the InputFilter validators and filters from form fields
19,283
private function getNodeList ( ) : Generator { $ xpath = new DOMXPath ( $ this -> document ) ; $ nodeList = $ xpath -> query ( '//input | //textarea | //select | //div[@data-input-name]' ) ; foreach ( $ nodeList as $ node ) { $ name = $ node -> getAttribute ( 'name' ) ; if ( ! $ name ) { $ name = $ node -> getAttribute...
Get form elements and create an id if needed
19,284
private function getSubmitStateNodeList ( ) : Generator { $ xpath = new DOMXPath ( $ this -> document ) ; $ nodeList = $ xpath -> query ( '//input[@type="submit"] | //button[@type="submit"]' ) ; foreach ( $ nodeList as $ node ) { $ name = $ node -> getAttribute ( 'name' ) ; if ( ! $ name ) { continue ; } yield $ name ;...
Get names of available named submit elements
19,285
private function setData ( array $ data , ? bool $ force = null ) : void { $ force = $ force ?? false ; foreach ( $ this -> getNodeList ( ) as $ name => $ node ) { if ( ! array_key_exists ( $ name , $ data ) ) { continue ; } $ value = $ data [ $ name ] ; $ reuseSubmittedValue = filter_var ( $ node -> getAttribute ( 'da...
Set values and element checked and selected states
19,286
private function setMessages ( array $ data ) : void { foreach ( $ data as $ name => $ errors ) { $ xpath = new DOMXPath ( $ this -> document ) ; $ nodeList = $ xpath -> query ( sprintf ( '//*[@name="%1$s"] | //*[@data-input-name="%1$s"]' , $ name ) ) ; if ( $ nodeList -> length === 0 ) { continue ; } $ node = $ nodeLi...
Set validation messages bootstrap style
19,287
public function phpTypecastComposite ( $ value ) { if ( is_string ( $ value ) ) { $ value = $ this -> getCompositeParser ( ) -> parse ( $ value ) ; } if ( is_array ( $ value ) ) { $ result = [ ] ; $ fields = array_keys ( $ this -> columns ) ; foreach ( $ value as $ i => $ item ) { $ field = is_int ( $ i ) ? $ fields [ ...
Converts the composite type to PHP
19,288
public function createCompositeObject ( $ values ) { switch ( $ this -> phpType ) { case 'array' : return $ values ; case 'object' : return ( object ) $ values ; } return \ Yii :: createObject ( $ this -> phpType , [ $ values ] ) ; }
Creates an object for the composite type .
19,289
protected function getCode ( ) { $ queryData = [ 'response_type' => 'code' , 'client_id' => $ this -> clientId , 'redirect_uri' => $ this -> redirectUri ] ; header ( 'Location: ' . self :: AUTHORIZE_URI . '?' . http_build_query ( $ queryData ) ) ; throw new ExitException ( ) ; }
Authorize - First step
19,290
protected function getToken ( ) { $ response = $ this -> post ( self :: TOKEN_URI , [ 'body' => [ 'grant_type' => 'authorization_code' , 'code' => $ this -> getCodeQueryField ( ) , 'client_id' => $ this -> clientId , 'client_secret' => $ this -> clientSecret ] ] ) ; if ( $ response -> getStatusCode ( ) == 200 ) { $ thi...
Authorize - Second step
19,291
protected function parseDataAttribute ( string $ dataAttribute ) : Generator { $ matches = [ ] ; preg_match_all ( '/([a-zA-Z]+)([^|]*)/' , $ dataAttribute , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) { $ name = $ match [ 1 ] ; $ options = [ ] ; if ( isset ( $ match [ 2 ] ) ) { $ allOptions = explod...
Parse data attribute value for validators filters and options
19,292
public function parse ( $ value ) { if ( $ value === null ) { return null ; } if ( $ value == '()' ) { return [ null ] ; } return $ this -> parseComposite ( $ value ) ; }
Converts PostgreSQL composite type representation to PHP array
19,293
private function parseComposite ( $ value , & $ i = 0 ) { $ result = [ ] ; $ length = strlen ( $ value ) ; for ( ++ $ i ; $ i < $ length ; ++ $ i ) { switch ( $ value [ $ i ] ) { case ')' : break 2 ; case ',' : if ( empty ( $ result ) ) { $ result [ ] = null ; } if ( in_array ( $ value [ $ i + 1 ] , [ ',' , ')' ] , tru...
Parses PostgreSQL composite type encoded in string
19,294
private function parseString ( $ value , & $ i ) { $ isQuoted = $ value [ $ i ] === '"' ; $ endChars = $ isQuoted ? [ '"' ] : [ ',' , ')' ] ; $ result = '' ; $ length = strlen ( $ value ) ; for ( $ i += $ isQuoted ? 1 : 0 ; $ i < $ length ; ++ $ i ) { if ( in_array ( $ value [ $ i ] , [ '\\' , '"' ] , true ) && in_arra...
Parses PostgreSQL encoded string
19,295
public static function addCallback ( $ hook , $ order , $ function ) { $ callback = array ( $ order , $ function ) ; if ( ! isset ( Hook :: $ hooks [ $ hook ] ) ) { Hook :: $ hooks [ $ hook ] = array ( ) ; } Hook :: $ hooks [ $ hook ] [ ] = $ callback ; uasort ( Hook :: $ hooks [ $ hook ] , '\\SciActive\\Hook::sortCall...
Add a callback .
19,296
public static function delCallbackByID ( $ hook , $ id ) { if ( ! isset ( Hook :: $ hooks [ $ hook ] [ $ id ] ) ) { return 2 ; } unset ( Hook :: $ hooks [ $ hook ] [ $ id ] ) ; return 1 ; }
Delete a callback by its ID .
19,297
public static function runCallbacks ( $ name , & $ arguments = array ( ) , $ type = 'all' , & $ object = null , & $ function = null , & $ data = array ( ) ) { if ( isset ( Hook :: $ hooks [ 'all' ] ) ) { foreach ( Hook :: $ hooks [ 'all' ] as $ curCallback ) { if ( ( $ type == 'all' && $ curCallback [ 0 ] != 0 ) || ( $...
Run the callbacks for a given hook .
19,298
public function detach ( $ event , $ callback ) { if ( $ this -> hasEvent ( $ event ) ) { $ this -> removeEventCallable ( $ event , $ callback ) ; } elseif ( '' === $ event ) { $ this -> events = [ ] ; } return true ; }
if call is NULL clear this event . if event is clear all events
19,299
protected function newEvent ( $ eventName , $ target = null , array $ parameters = [ ] ) { if ( is_object ( $ eventName ) ) { return $ eventName ; } else { return new Event ( $ eventName , $ target , $ parameters ) ; } }
Create a new event