idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
51,600
public function toUniversalTransverseMercator ( ) { $ coordinate = self :: getBaseCoordinate ( $ this ) ; $ convert = new Convert ( $ coordinate ) ; $ utm = $ convert -> toUniversalTransverseMercator ( ) ; return new StringLiteral ( $ utm ) ; }
Returns a Universal Transverse Mercator projection representation of the coordinate in meters
51,601
public function distanceFrom ( Coordinate $ coordinate , DistanceUnit $ unit = null , DistanceFormula $ formula = null ) { if ( null === $ unit ) { $ unit = DistanceUnit :: METER ( ) ; } if ( null === $ formula ) { $ formula = DistanceFormula :: FLAT ( ) ; } $ baseThis = self :: getBaseCoordinate ( $ this ) ; $ baseCoo...
Calculates the distance between two Coordinate objects
51,602
protected static function getBaseCoordinate ( self $ coordinate ) { $ latitude = $ coordinate -> getLatitude ( ) -> toNative ( ) ; $ longitude = $ coordinate -> getLongitude ( ) -> toNative ( ) ; $ ellipsoid = BaseEllipsoid :: createFromName ( $ coordinate -> getEllipsoid ( ) -> toNative ( ) ) ; $ coordinate = new Base...
Returns the underlying Coordinate object
51,603
public function getEventActions ( $ eventName ) { $ events = isset ( $ this -> events [ $ eventName ] ) ? $ this -> events [ $ eventName ] : [ ] ; return is_array ( $ events ) ? $ events : [ $ events ] ; }
Returns a list of methods associated with a event
51,604
public function handle ( $ eventName , $ data = null ) { $ results = [ ] ; if ( $ actions = $ this -> getEventActions ( $ eventName ) ) { $ actions = is_array ( $ actions ) ? $ actions : [ $ actions ] ; $ data = is_array ( $ data ) ? $ data : [ $ data ] ; foreach ( $ actions as $ action ) { if ( $ result = $ this -> ca...
Handles the event
51,605
protected function call ( $ eventName , $ method , $ data = null ) { if ( method_exists ( $ this , $ method ) ) { $ result = call_user_func_array ( [ $ this , $ method ] , $ data ) ; return $ result ; } return null ; }
Calls a event method
51,606
private function hasColumnDifference ( ) { return ! empty ( $ this -> createdColumns ) || ! empty ( $ this -> alteredColumns ) || ! empty ( $ this -> droppedColumns ) ; }
Checks if the table diff has column difference .
51,607
public function handleError ( $ errno , $ errstr , $ errfile , $ errline ) { if ( error_reporting ( ) === 0 ) { return false ; } $ exception = new ErrorException ( $ errstr , $ errno , $ errno , $ errfile , $ errline ) ; $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; array_shift ( $ trace ) ; foreach ( $ t...
An error handler function that throws exceptions .
51,608
public function register ( $ theDebug = false , $ theErrorTypes = null ) { if ( $ theErrorTypes === null ) { $ theErrorTypes = E_ALL | E_STRICT ; } $ this -> myDebug = $ theDebug ; ini_set ( 'display_errors' , false ) ; set_exception_handler ( [ $ this , 'handleException' ] ) ; set_error_handler ( [ $ this , 'handleErr...
Registers this error handler .
51,609
protected function validateString ( string $ string ) { if ( strlen ( $ string ) > self :: MAX_LENGTH || ! filter_var ( $ string , FILTER_VALIDATE_IP ) ) { throw InvalidArgumentException :: format ( 'Cannot construct class %s: argument must be a valid ip address, \'%s\' given' , get_class ( $ this ) , $ string ) ; } }
Validates the string is in the required format .
51,610
protected function parseArguments ( string $ string ) : ArgumentList { $ argParser = $ this -> argumentParserFactory -> create ( $ string ) ; return $ argParser -> tokenise ( ) ; }
Handlebars will give arguments in a string . This will transform them into a legitimate argument array .
51,611
protected function registerValidationRules ( $ validator ) { $ validator -> resolver ( function ( $ translator , $ data , $ rules , $ messages ) { return new BaseValidator ( $ translator , $ data , $ rules , $ messages ) ; } ) ; $ validator -> replacer ( 'elfinder_max' , function ( $ message , $ attribute , $ rule , $ ...
Registers validation rules
51,612
public function cmdGetPriceRule ( ) { $ result = $ this -> getListPriceRule ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePriceRule ( $ result ) ; $ this -> output ( ) ; }
Callback for pricerule - get command
51,613
public function cmdUpdatePriceRule ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ thi...
Callback for pricerule - update command
51,614
protected function addPriceRule ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> price_rule -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new price rule
51,615
protected function submitAddPriceRule ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'price_rule' ) ; $ this -> addPriceRule ( ) ; }
Add a new price rule at once
51,616
protected function wizardAddPriceRule ( ) { $ this -> validatePrompt ( 'name' , $ this -> text ( 'Name' ) , 'price_rule' ) ; $ this -> validatePrompt ( 'trigger_id' , $ this -> text ( 'Trigger ID' ) , 'price_rule' ) ; $ types = array ( ) ; foreach ( $ this -> price_rule -> getTypes ( ) as $ id => $ type ) { $ types [ $...
Add a new price rule step by step
51,617
protected function setStatusPriceRule ( $ status ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && ! $ all ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ result = $ options = null ; if ( isset ( $ id ) ) { if ( empty ( $ id ) || ! is_numeric...
Sets status for one or several price rules
51,618
public static function turnDateIntervalToSeconds ( DateInterval $ dateInterval ) { return $ dateInterval -> y * 365 * 24 * 3600 + $ dateInterval -> m * 30 * 24 * 3600 + $ dateInterval -> d * 24 * 3600 + $ dateInterval -> h * 3600 + $ dateInterval -> i * 60 + $ dateInterval -> s ; }
1 Year is defined as 365 days and 1 Month is defined as 30 days
51,619
public function renderItem ( $ model , $ key , $ index ) { if ( $ this -> itemView === null ) { $ content = $ key ; } elseif ( is_string ( $ this -> itemView ) ) { $ content = $ this -> getView ( ) -> render ( $ this -> itemView , array_merge ( [ 'model' => $ model , 'key' => $ key , 'index' => $ index , 'widget' => $ ...
Renders a single data model .
51,620
public static function getClassProperties ( $ class ) { if ( is_string ( $ class ) ) { if ( isset ( self :: $ classPropertyes [ $ class ] ) ) { return self :: $ classPropertyes [ $ class ] ; } $ class = new \ ReflectionClass ( $ class ) ; } if ( ! $ class instanceof \ ReflectionClass ) { throw new \ InvalidArgumentExce...
Get array of class properties including parents private properties .
51,621
public function getUrl ( array $ data = [ ] ) { $ translation_guess = preg_replace ( [ '/\[([^\[]+)\]/is' , '/{(\w*?)}/is' , '/{(\w*?):(:?.*?)}/is' ] , '{$1}' , $ this -> _path ) ; $ keys = [ ] ; preg_match_all ( '/{(\w*?)}/is' , $ translation_guess , $ keys ) ; foreach ( $ keys [ 1 ] as $ key ) { $ translation_guess =...
Get route URL with parameters passed on .
51,622
protected function registerToHandler ( $ name , $ value , $ crypt = false ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { $ value = base64_encode ( serialize ( $ value ) ) ; } if ( true === $ crypt ) { $ value = $ this -> getCrypt ( ) -> encode ( $ crypt ) ; } $ this -> getHandler ( ) -> write ( $ name , $ v...
register a new session to handler
51,623
public function has ( $ name ) { $ value = $ this -> get ( $ name ) ; return isset ( $ value ) ? $ value : false ; }
check the value is exists
51,624
public function renderOptions ( array $ options , array $ selectedOptions = array ( ) ) { $ template = '<li %s><a href="#">%s</a></li>' ; $ optionStrings = array ( ) ; $ escapeHtml = $ this -> getEscapeHtmlHelper ( ) ; foreach ( $ options as $ key => $ optionSpec ) { $ value = '' ; $ label = '' ; $ selected = false ; $...
Render an array of options
51,625
public function renderOptgroup ( array $ optgroup , array $ selectedOptions = array ( ) ) { $ template = '<optgroup%s>%s</optgroup>' ; $ options = array ( ) ; if ( isset ( $ optgroup [ 'options' ] ) && is_array ( $ optgroup [ 'options' ] ) ) { $ options = $ optgroup [ 'options' ] ; unset ( $ optgroup [ 'options' ] ) ; ...
Render an optgroup
51,626
protected function validateMultiValue ( $ value , array $ attributes ) { if ( null === $ value ) { return array ( ) ; } if ( ! is_array ( $ value ) ) { return ( array ) $ value ; } if ( ! isset ( $ attributes [ 'multiple' ] ) || ! $ attributes [ 'multiple' ] ) { throw new Exception \ DomainException ( sprintf ( '%s doe...
Ensure that the value is set appropriately
51,627
protected function renderHidden ( \ Zend \ Form \ Element \ Select $ element , array $ attributes ) { $ attributes [ 'type' ] = 'select' ; $ attributes [ 'name' ] .= '[id]' ; if ( method_exists ( $ element , 'getId' ) ) { $ attributes [ 'value' ] = $ element -> getId ( ) ; } elseif ( array_key_exists ( 'value' , $ attr...
Render the hidden input with the captcha identifier
51,628
public function toString ( $ to = self :: TO_FRAGMENT , $ schemaRelative = false ) { if ( $ to == static :: TO_SCHEME ) { return $ this -> scheme ; } if ( $ schemaRelative || empty ( $ this -> scheme ) ) { $ uri = empty ( $ this -> host ) ? '' : '//' ; } else { $ uri = empty ( $ this -> host ) ? '' : ( $ this -> scheme...
Renders an encoded URI .
51,629
public static function encode ( $ string , $ encodeSlashes = false ) { if ( $ encodeSlashes ) { return rawurlencode ( $ string ) ; } return implode ( '/' , array_map ( 'rawurlencode' , explode ( '/' , ( string ) $ string ) ) ) ; }
URL - encode the given string .
51,630
private function setUserInfo ( $ user , $ pass ) { $ this -> userInfo = $ user . ( ! empty ( $ pass ) ? ':' . $ pass : '' ) ; return $ this ; }
Set user info
51,631
final public function setMinLevel ( $ minLevel ) { if ( isset ( $ this -> levels [ $ minLevel ] ) ) { $ this -> minLevel = $ this -> levels [ $ minLevel ] ; } return $ this ; }
If set then only messages with level equal or greater then minLevel will be logged .
51,632
function addString ( $ string_to_add ) { settype ( $ string_to_add , "string" ) ; if ( strlen ( $ string_to_add ) > 0 ) { $ this -> _Buffer [ ] = new StringBufferItem ( $ string_to_add ) ; } }
Adds another string to the buffer .
51,633
function addStringBuffer ( $ stringbuffer_to_add ) { if ( ! isset ( $ stringbuffer_to_add ) ) { return ; } for ( $ i = 0 ; $ i < sizeof ( $ stringbuffer_to_add -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ ] = $ stringbuffer_to_add -> _Buffer [ $ i ] ; } }
Adds content of another StringBuffer to the buffer .
51,634
function getLength ( ) { $ out = 0 ; for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ out = $ out + $ this -> _Buffer [ $ i ] -> getLength ( ) ; } return $ out ; }
Returns length of buffer content .
51,635
function printOut ( ) { for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ $ i ] -> flush ( ) ; } }
Echoes content of buffer .
51,636
function replace ( $ search , $ replace ) { settype ( $ search , "string" ) ; if ( is_object ( $ replace ) ) { $ replace = $ replace -> toString ( ) ; } for ( $ i = 0 ; $ i < sizeof ( $ this -> _Buffer ) ; $ i ++ ) { $ this -> _Buffer [ $ i ] -> replace ( $ search , $ replace ) ; } }
Replaces string in buffer with replacement string .
51,637
function replace ( $ search , $ replace ) { $ this -> _String = str_replace ( $ search , $ replace , $ this -> _String ) ; }
Replace part of string in buffer
51,638
function toString ( ) { if ( isset ( $ this -> _String ) ) { return parent :: toString ( ) ; } return Files :: GetFileContent ( $ this -> _Filename ) ; }
Outputs content of buffer as string .
51,639
function replace ( $ search , $ replace ) { $ this -> _String = $ this -> toString ( ) ; return parent :: replace ( $ search , $ replace ) ; }
Replaces part of a string with another string .
51,640
protected function toCollection ( $ data , $ collectionClass ) { if ( $ data instanceof $ collectionClass ) { return $ data ; } $ data = $ data ? : array ( ) ; if ( ! is_array ( $ data ) && ! $ data instanceof Collection ) { throw new \ InvalidArgumentException ( 'Can transform only Collections or arrays.' ) ; } return...
helper method to use for cast arrays to collections of entities .
51,641
public static function setAlias ( $ alias , $ realPath ) { if ( is_string ( $ alias ) && is_string ( $ realPath ) ) { self :: $ aliases [ strtolower ( $ alias ) ] = $ realPath ; } }
Setting or installing new alias
51,642
public static function getClassPath ( $ className , $ extension = '.php' ) { $ prefix = $ className = self :: camelCaseToLowerNamespace ( str_replace ( '_' , '\\' , $ className ) ) ; while ( false !== $ position = strrpos ( $ prefix , '\\' ) ) { $ prefix = substr ( $ prefix , 0 , $ position ) ; $ alias = self :: getAli...
Get class path
51,643
private static function camelCaseToLowerNamespace ( $ path ) { $ classNameArr = array_map ( function ( $ val ) { return lcfirst ( $ val ) ; } , explode ( '\\' , $ path ) ) ; $ classNameArr [ ] = ucfirst ( array_pop ( $ classNameArr ) ) ; return implode ( '\\' , $ classNameArr ) ; }
Convert first symbols of namespace to lowercase
51,644
public function getTableMetadata ( string $ tableName ) : TableMetadata { if ( ! array_key_exists ( $ tableName , $ this -> tableMetadataList ) ) { throw new \ RuntimeException ( 'Database "' . $ this -> databaseName . '" doesn\'t contain table "' . $ tableName . '"' ) ; } return $ this -> tableMetadataList [ $ tableNa...
Get the metadata for a single table .
51,645
public function error ( $ code = 404 , $ msg = "Resource not found" ) { $ request = HttpFactory :: i ( ) -> request ( ) ; if ( $ request -> ajax ( ) || $ request -> wantsJson ( ) ) return new JsonResponse ( [ 'error' => $ msg ] ) ; else return new Response ( Redirect :: back ( ) -> withInput ( $ request -> input ( ) ) ...
Produces a new error response based on if this is an api request or not .
51,646
protected function get ( $ path , $ body = [ ] , array $ headers = [ ] ) { $ client = $ this -> getClient ( ) ; $ request = AbstractHttpClient :: createRequest ( 'GET' , $ path , $ body , $ headers ) ; return $ this -> transformer -> transform ( $ client -> send ( $ request ) ) ; }
Execute a http get query
51,647
public function createColumn ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createColumnBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Column type guessing is not yet supported.' ) ; }
Creates a column builder .
51,648
public function createFilter ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createFilterBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Filter type guessing is not yet supported.' ) ; }
Creates a filter builder .
51,649
public function createAction ( $ name , $ type = null , array $ options = [ ] ) { $ this -> preventIfLocked ( ) ; if ( null !== $ type ) { return $ this -> getFactory ( ) -> createActionBuilder ( $ name , $ type , $ options ) ; } throw new \ InvalidArgumentException ( 'Action type guessing is not yet supported.' ) ; }
Creates a action builder .
51,650
private function resolveColumn ( $ name ) { $ info = $ this -> unresolvedColumns [ $ name ] ; $ child = $ this -> createColumn ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> columns [ $ name ] = $ child ; unset ( $ this -> unresolvedColumns [ $ name ] ) ; return $ child ; }
Converts an unresolved column into a column builder instance .
51,651
private function resolveFilter ( $ name ) { $ info = $ this -> unresolvedFilters [ $ name ] ; $ child = $ this -> createFilter ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> filters [ $ name ] = $ child ; unset ( $ this -> unresolvedFilters [ $ name ] ) ; return $ child ; }
Converts an unresolved filter into a filter builder instance .
51,652
private function resolveAction ( $ name ) { $ info = $ this -> unresolvedActions [ $ name ] ; $ child = $ this -> createAction ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; $ this -> actions [ $ name ] = $ child ; unset ( $ this -> unresolvedActions [ $ name ] ) ; return $ child ; }
Converts an unresolved action into a action builder instance .
51,653
private function resolveElements ( ) { foreach ( $ this -> unresolvedColumns as $ name => $ info ) { $ this -> columns [ $ name ] = $ this -> createColumn ( $ name , $ info [ 'type' ] , $ info [ 'options' ] ) ; } $ this -> unresolvedColumns = [ ] ; foreach ( $ this -> unresolvedFilters as $ name => $ info ) { $ this ->...
Converts all unresolved elements into builder instances .
51,654
protected function isSyntacticallyValid ( ) : bool { if ( preg_match ( '!^([a-z][a-z0-9\+]*)://([^@]+@)?([^/?#]*)(/([^#?]*))?(.*)$!' , $ this -> parsedUri -> asString ( ) ) == 0 ) { return false ; } if ( $ this -> parsedUri -> hasUser ( ) ) { if ( preg_match ( '~([@:/])~' , $ this -> parsedUri -> user ( ) ) != 0 ) { re...
Checks whether URI is a syntactically correct URI .
51,655
public function asStringWithNonDefaultPort ( ) : string { if ( $ this -> parsedUri -> hasPort ( ) && ! $ this -> hasDefaultPort ( ) ) { return $ this -> asString ( ) ; } return $ this -> asStringWithoutPort ( ) ; }
Returns uri as string containing the port if it is not the default port .
51,656
public function password ( string $ defaultPassword = null ) { if ( ! $ this -> parsedUri -> hasUser ( ) ) { return null ; } if ( $ this -> parsedUri -> hasPassword ( ) ) { return $ this -> parsedUri -> password ( ) ; } return $ defaultPassword ; }
returns the password
51,657
public function addParams ( array $ params ) : self { foreach ( $ params as $ name => $ value ) { $ this -> addParam ( $ name , $ value ) ; } return $ this ; }
adds given map of params
51,658
public function addParam ( string $ name , $ value ) : self { $ this -> parsedUri -> queryString ( ) -> addParam ( $ name , $ value ) ; return $ this ; }
add a parameter to the uri
51,659
public function removeParam ( string $ name ) : self { $ this -> parsedUri -> queryString ( ) -> removeParam ( $ name ) ; return $ this ; }
remove a param from uri
51,660
public function prepare ( $ val , $ col = null , $ type = null ) { if ( is_array ( $ val ) ) { $ holder = [ ] ; foreach ( $ val as $ key => $ v ) { $ holder [ $ key ] = $ this -> prepare ( $ v , $ col , $ type ) ; } return $ holder ; } if ( $ val instanceof \ Closure ) return $ val ; $ holder = ( static :: $ useColumnI...
replaces value with place holder for prepared statement . the value is kept in prepared_value array .
51,661
public function setName ( $ name ) { if ( ! is_string ( $ name ) || ( strlen ( $ name ) <= 0 ) ) { $ explodedNamespace = explode ( '\\' , get_class ( $ this ) ) ; $ class = $ explodedNamespace [ count ( $ explodedNamespace ) - 1 ] ; $ asset = strtolower ( preg_replace ( '/(.)([A-Z])/' , '\\1 \\2' , $ class ) ) ; throw ...
Sets the asset name .
51,662
protected function generateIdentifier ( $ prefix , $ maxLength ) { $ hash = null ; $ dictionary = 'abcdefghijklmnopqrstuvwxyz0123456789' ; for ( $ i = 0 ; $ i < ( $ maxLength - strlen ( $ prefix ) ) ; $ i ++ ) { $ hash .= $ dictionary [ mt_rand ( 0 , strlen ( $ dictionary ) - 1 ) ] ; } return $ prefix . $ hash ; }
Generates a prefixed identifier .
51,663
public function isAllowed ( $ action , $ role = null ) { if ( $ this -> _acl_entity === null ) { return $ this -> getACL ( ) -> getDefaultPolicy ( ) ; } if ( $ role === null ) { $ role = $ this -> getACL ( ) -> getCurrentRole ( ) ; } return $ this -> _acl_entity -> isAllowed ( $ role , $ action , array ( get_class ( $ ...
Check if an action is allowed on this object . If the ACL subsystem is not loaded true will be returned .
51,664
public static function getACLClass ( ) { $ cl = static :: class ; $ parts = explode ( "\\" , $ cl ) ; if ( count ( $ parts ) === 1 ) return $ parts [ 0 ] ; $ first = reset ( $ parts ) ; $ last = end ( $ parts ) ; return $ first . "_" . $ last ; }
Generate a ACL Class name for the called DAO class . It will be composed of the first part of the namespace and the classname by default but subclasses may override this to alter this behaviour . It should return a unique name
51,665
public function generateID ( ) { $ id = $ this -> getID ( ) ; $ fmt_string = "%08s" ; if ( is_array ( $ id ) ) $ id = implode ( "-" , $ id ) ; if ( empty ( $ id ) ) throw new Exception ( "Cannot generate an ID for an empty object" ) ; $ id = substr ( sha1 ( $ id ) , 0 , 10 ) ; $ acl_class = $ this -> getACLClass ( ) ; ...
Generate a ID based on the provided Model object
51,666
function cacheApplication ( ) { $ this -> log ( "Downloading application..." ) ; $ app = Config :: instance ( ) -> application -> apiClient ( ) -> get ( "application" , array ( "definition" => "true" ) ) ; $ this -> cache ( Application :: cacheKey ( ) , json_encode ( $ app ) ) ; $ this -> log ( "Application has been ca...
Caches application data
51,667
function cacheLanguages ( ) { $ this -> log ( "Downloading languages..." ) ; $ count = 0 ; $ languages = Config :: instance ( ) -> application -> apiClient ( ) -> get ( "application/languages" , array ( "definition" => "true" ) ) ; foreach ( $ languages as $ lang ) { $ this -> cache ( Language :: cacheKey ( $ lang [ "l...
Caches application languages with full definition
51,668
public function only ( array $ array ) { $ data = [ ] ; foreach ( $ array as $ field ) { if ( $ this -> has ( $ field ) ) { $ data [ $ field ] = $ this -> data [ $ field ] ; } } return $ data ; }
Grab selected fields .
51,669
public function file ( $ name , $ disk = null ) { return File :: make ( $ this -> files [ $ name ] , $ disk ) ; }
Get request file
51,670
public function getLabel ( ) { if ( $ this -> label ) { return $ this -> translate ( $ this -> label ) ; } $ labels = array ( ) ; if ( $ this -> form -> model && is_string ( $ this -> form -> model ) ) { $ class = $ this -> form -> model ; $ labels = $ class :: getLabels ( ) ; } elseif ( $ this -> form -> model && is_o...
Get label for current field . It will first try to get label attribute if that s not specified it will check for a model and read the label from there if it s still not found then it will generate one using the name .
51,671
public function display ( Form $ form ) { if ( ! $ this -> visible ) { return "" ; } $ this -> form = $ form ; if ( ! isset ( $ this -> rowHtmlOptions [ 'class' ] ) ) { $ this -> rowHtmlOptions [ 'class' ] = $ this -> rowClass ; } else { $ this -> rowHtmlOptions [ 'class' ] .= ' ' . $ this -> rowClass ; } if ( ! is_nul...
Get html content for current field .
51,672
public function getHTMLError ( ) { $ error = $ this -> getError ( ) ; if ( ! is_null ( $ error ) ) { if ( is_string ( $ error ) ) { $ errorContent = Html :: get ( ) -> tag ( 'span' , $ error ) ; } elseif ( is_array ( $ error ) ) { $ errors = array ( ) ; foreach ( $ error as $ message ) { $ errors [ ] = Html :: get ( ) ...
Get HTML code for errors .
51,673
public function getError ( ) { if ( $ this -> error ) { return $ this -> translate ( $ this -> error ) ; } if ( $ this -> form -> model && is_object ( $ this -> form -> model ) && $ this -> form -> model -> hasErrors ( $ this -> name ) ) { $ errors = $ this -> form -> model -> getErrors ( $ this -> name ) ; foreach ( $...
Return a simple text message or a list of messages with errors for current field
51,674
public function query ( $ sql , $ binders = array ( ) , $ suggestedClass = null , $ debug = false ) { $ minBinderLocation = 0 ; if ( ! is_array ( $ binders ) ) $ binders = array ( $ binders ) ; if ( ! empty ( $ binders ) ) { foreach ( $ binders as & $ bound ) { $ bound = $ this -> provider -> escapeItem ( $ bound ) ; $...
Run an SQL query
51,675
public function __getSerialisablePropertyValue ( $ propertyName ) { $ map = $ this -> __getSerialisablePropertyMap ( ) ; if ( array_key_exists ( $ propertyName , $ map ) ) { return $ map [ $ propertyName ] ; } elseif ( array_key_exists ( substr ( strtoupper ( $ propertyName ) , 0 , 1 ) . substr ( $ propertyName , 1 ) ,...
Get a serialisable property value by name if it exists . Throw an exception if it doesn t exist .
51,676
public function __getSerialisablePropertyMap ( ) { $ propertyAccessors = $ this -> __findSerialisablePropertyAccessors ( ) ; $ propertyMap = array ( ) ; foreach ( $ propertyAccessors as $ accessorSet ) { if ( isset ( $ accessorSet [ "get" ] ) ) { $ accessor = $ accessorSet [ "get" ] ; if ( $ accessor instanceof \ Refle...
Get an associative array of all of the serialisable properties defined on this class .
51,677
public function __setSerialisablePropertyMap ( $ propertyMap , $ ignoreNoneWritableProperties = false ) { $ propertyAccessors = $ this -> __findSerialisablePropertyAccessors ( ) ; $ noneWritables = array ( ) ; foreach ( $ propertyMap as $ inputPropertyName => $ propertyValue ) { $ propertyName = strtolower ( $ inputPro...
Set an associative array of serialisable properties
51,678
public function __findSerialisablePropertyAccessors ( ) { $ className = get_class ( $ this ) ; if ( ! isset ( self :: $ __accessorMaps [ $ className ] ) ) { $ reflectionClass = new \ ReflectionClass ( $ className ) ; $ accessors = array ( ) ; $ methods = $ reflectionClass -> getMethods ( ) ; foreach ( $ methods as $ me...
Find all serialisable property objects return a map of accessor objects keyed in by GET and SET .
51,679
public function forever ( $ name = '' , $ value = '' , $ path = '/' , $ domain = null , $ secure = false , $ httpOnly = false ) { $ this -> set ( $ name , $ value , 2628000 , $ path , $ domain , $ secure , $ httpOnly ) ; return $ this ; }
this cookie life very long time
51,680
public function format ( $ entities ) { $ data = array ( 'models' => array ( ) , 'images' => array ( ) , 'links' => array ( ) ) ; if ( ! is_array ( $ entities ) ) { $ entities = array ( $ entities -> getId ( ) => $ entities ) ; } foreach ( $ entities as $ entity ) { if ( $ entity instanceof \ Application \ Togu \ Appli...
Prepares the data to be serialized
51,681
public function register ( ) { $ this -> prepare_hook = $ this -> prepare_hook ? : Hook :: subscribe ( 'Wedeto.HTTP.Forms.Form.prepare' , [ $ this , 'hookPrepareForm' ] ) ; $ this -> validate_hook = $ this -> validate_hook ? : Hook :: subscribe ( 'Wedeto.HTTP.Forms.Form.isValid' , [ $ this , 'hookIsValid' ] ) ; }
Subscribe to two hooks prepare and isValid
51,682
public function unregister ( ) { if ( $ this -> prepare_hook ) { Hook :: unsubscribe ( 'Wedeto.HTTP.Forms.Form.prepare' , $ this -> prepare_hook ) ; $ this -> prepare_hook = null ; } if ( $ this -> validate_hook ) { Hook :: unsubscribe ( 'Wedeto.HTTP.Forms.Form.isValid' , $ this -> validate_hook ) ; $ this -> validate_...
Unsubscribe from the two hooks
51,683
public function hookPrepareForm ( Dictionary $ params ) { $ session = $ params [ 'session' ] ; $ form = $ params [ 'form' ] ; if ( $ session !== null ) { $ nonce_name = Nonce :: getParameterName ( ) ; if ( ! isset ( $ form [ $ nonce_name ] ) ) { $ context = [ ] ; $ nonce = Nonce :: getNonce ( $ form -> getName ( ) , $ ...
The hook called when the form is being prepared . Is used to add the nonce field to the form .
51,684
public function hookIsValid ( Dictionary $ params ) { $ form = $ params [ 'form' ] ; $ request = $ params [ 'request' ] ; $ arguments = $ params [ 'arguments' ] ; $ result = Nonce :: validateNonce ( $ form -> getName ( ) , $ request -> session , $ arguments ) ; $ nonce_name = Nonce :: getParameterName ( ) ; if ( $ resu...
The hook called when the form is validated . Is used to validate that the received nonce is valid .
51,685
public static function createNewInstanceWithoutConstructor ( $ className , array $ arguments = [ ] ) { $ reflectedClass = new ReflectionClass ( $ className ) ; $ newInstance = $ reflectedClass -> newInstanceWithoutConstructor ( ) ; $ reflectedConstructor = $ reflectedClass -> getConstructor ( ) ; if ( null !== $ reflec...
Creates a new instance of the class with the specified class name without invoking its constructor .
51,686
public static function invokeMethod ( $ object , $ methodName , array $ arguments = [ ] ) { $ reflectedObject = new ReflectionObject ( $ object ) ; $ reflectedMethod = $ reflectedObject -> getMethod ( $ methodName ) ; $ reflectedMethod -> setAccessible ( true ) ; $ reflectedMethod -> invokeArgs ( $ object , $ arguments...
Invokes the specified method on the specified object .
51,687
public function add ( string $ name , callable $ callback ) : \ IvoPetkov \ BearFrameworkAddons \ ServerRequests { $ this -> callbacks [ $ name ] = $ callback ; return $ this ; }
Register a named callback
51,688
public function execute ( string $ name , array $ data , \ BearFramework \ App \ Response $ response ) : string { if ( isset ( $ this -> callbacks [ $ name ] ) ) { return ( string ) call_user_func ( $ this -> callbacks [ $ name ] , $ data , $ response ) ; } return '' ; }
Executes the callback for the name specified
51,689
public function process ( array $ input ) { try { $ success = $ this -> v -> validate ( $ input ) ; } catch ( ValidationException $ e ) { $ this -> setErrorsAndThrowException ( ) ; } if ( ! $ success ) { $ this -> setErrorsAndThrowException ( ) ; } Event :: fire ( "form.processing" , array ( $ input ) ) ; return $ this...
Processa l input e chiama create o opdate a seconda
51,690
public function renderContent ( ) { if ( is_object ( $ this -> content ) && ! method_exists ( $ this -> content , '__toString' ) ) { throw new \ LogicException ( 'Cannot render content: it is an object without __toString method!' ) ; } if ( is_array ( $ this -> content ) ) { throw new \ LogicException ( 'Cannot render ...
Render content .
51,691
protected function attributes ( $ attributes = [ ] ) { $ ar = [ ] ; foreach ( $ attributes as $ key => $ value ) { $ element = $ this -> attribute ( $ key , $ value ) ; if ( ! is_null ( $ element ) ) { $ ar [ ] = $ element ; } } return count ( $ ar ) > 0 ? ' ' . implode ( ' ' , $ ar ) : '' ; }
Cycles through given attributes and sets them for the element .
51,692
protected function attribute ( $ key , $ value ) { if ( is_numeric ( $ key ) ) { $ key = $ value ; } if ( ! is_null ( $ value ) ) { return $ key . '="' . $ value . '"' ; } }
Creates the attribute string .
51,693
public function obfuscate ( $ value ) { $ safe = '' ; foreach ( str_split ( $ value ) as $ letter ) { if ( ord ( $ letter ) > 128 ) { return $ letter ; } switch ( rand ( 1 , 3 ) ) { case 1 : $ safe .= '&#' . ord ( $ letter ) . ';' ; break ; case 2 : $ safe .= '&#x' . dechex ( ord ( $ letter ) ) . ';' ; break ; case 3 :...
Obfuscates a string .
51,694
public function postMediaAction ( $ provider , Request $ request ) { $ pool = $ this -> get ( "sonata.media.pool" ) ; $ manager = $ this -> get ( "sonata.media.manager.media" ) ; $ formFactory = $ this -> get ( 'form.factory' ) ; try { $ mediaProvider = $ pool -> getProvider ( $ provider ) ; } catch ( \ RuntimeExceptio...
Create a new media
51,695
public function addOut ( $ str , $ wrapTag = 0 , $ attributes = array ( ) ) { if ( is_string ( $ str ) ) { if ( is_string ( $ wrapTag ) ) { $ str = Html :: element ( $ wrapTag , $ attributes , $ str ) ; } $ this -> mainOutput [ 'body' ] .= $ str ; return true ; } else { return false ; } }
Add a string to the output memory
51,696
public function clientKick ( $ clid , $ reasonid = Teamspeak :: KICK_CHANNEL , $ reasonmsg = null ) { $ this -> clientListReset ( ) ; $ this -> execute ( "clientkick" , array ( "clid" => $ clid , "reasonid" => $ reasonid , "reasonmsg" => $ reasonmsg ) ) ; }
Kicks one or more clients from their currently joined channel or from the server .
51,697
public function channelGroupGetByName ( $ name , $ type = Teamspeak :: GROUP_DBTYPE_REGULAR ) { foreach ( $ this -> channelGroupList ( ) as $ group ) { if ( $ group [ "name" ] == $ name && $ group [ "type" ] == $ type ) { return $ group ; } } throw new Ts3Exception ( "invalid groupID" , 0xA00 ) ; }
Returns the Channelgroup object matching the given name .
51,698
public function snapshotCreate ( $ mode = Teamspeak :: SNAPSHOT_STRING ) { $ snapshot = $ this -> request ( "serversnapshotcreate" ) -> toString ( false ) ; switch ( $ mode ) { case Teamspeak :: SNAPSHOT_BASE64 : return $ snapshot -> toBase64 ( ) ; break ; case Teamspeak :: SNAPSHOT_HEXDEC : return $ snapshot -> toHex ...
Creates and returns snapshot data for the selected virtual server .
51,699
public function checkData ( array $ data ) { $ keys = array ( 'to' , 'fullname' , 'title' , 'activationLink' , 'siteurl' , 'cdnurl' , 'siteName' ) ; foreach ( $ keys as $ key ) { if ( ! array_key_exists ( $ key , $ data ) ) { throw new \ Exception ( 'Key not in data' ) ; } } return $ this ; }
Checks if data contains neede keye