idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
4,400
public function add ( $ url , $ parentID = 0 , $ extract = \ false , $ callbackUrl = '' ) { $ data = [ 'url' => $ url , 'save_parent_id' => $ parentID , 'extract' => ( $ extract ? 'True' : 'False' ) , 'callback_url' => $ callbackUrl ] ; return $ this -> post ( 'transfers/add' , $ data , \ false ) ; }
Adds a new transfer to the queue .
4,401
public function cancel ( $ transferIDs ) { if ( is_array ( $ transferIDs ) ) { $ transferIDs = implode ( ',' , $ transferIDs ) ; } $ data = [ 'transfer_ids' => $ transferIDs ] ; return $ this -> post ( 'transfers/cancel' , $ data , \ true ) ; }
Cancels given transfers .
4,402
protected function normalizeAccessToken ( $ access_token ) { if ( ! isset ( $ access_token [ 'expires_in' ] ) && isset ( $ access_token [ 'expires' ] ) ) { $ access_token [ 'expires_in' ] = $ access_token [ 'expires' ] ; unset ( $ access_token [ 'expires' ] ) ; } return parent :: normalizeAccessToken ( $ access_token ) ; }
Facebook does it differently ... again!
4,403
public function get ( $ path , $ default = null ) { $ path = explode ( $ this -> separator , $ path ) ; $ item = & $ this -> item ; foreach ( $ path as $ key ) { if ( ! is_array ( $ item ) ) { return $ default ; } if ( ! array_key_exists ( $ key , $ item ) ) { return $ default ; } $ item = & $ item [ $ key ] ; } return $ item ; }
Get the value stored under the specified path
4,404
public function remove ( $ path ) { $ path = explode ( $ this -> separator , $ path ) ; $ last = array_pop ( $ path ) ; $ item = & $ this -> item ; foreach ( $ path as $ key ) { if ( array_key_exists ( $ key , $ item ) && is_array ( $ item [ $ key ] ) ) { $ item = & $ item [ $ key ] ; continue ; } return false ; } if ( array_key_exists ( $ last , $ item ) ) { unset ( $ item [ $ last ] ) ; return true ; } return false ; }
Remove a path
4,405
public function unserialize ( $ data ) { $ data = unserialize ( $ data ) ; $ this -> item = $ data [ 'item' ] ; $ this -> separator = $ data [ 'separator' ] ; $ this -> constraint = $ data [ 'constraint' ] ; }
Method inherited from Serializable
4,406
public function isArray ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; if ( $ value === $ this || ! is_array ( $ value ) ) { return false ; } return array_keys ( $ value ) === range ( 0 , count ( $ value ) - 1 ) ; }
Check if the value stored under the specified path is a JSON array
4,407
public function isString ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_string ( $ value ) ; }
Check if the value stored under the specified path is a string
4,408
public function isNumber ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_numeric ( $ value ) ; }
Check if the value stored under the specified path is a number
4,409
public function isNull ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_null ( $ value ) ; }
Check if the value stored under the specified path is a null value
4,410
public function isBoolean ( $ path ) { $ value = $ this -> get ( $ path , $ this ) ; return $ value === $ this ? false : is_bool ( $ value ) ; }
Check if the value stored under the specified path is a boolean value
4,411
private function initRequest ( ) : App { try { $ request = ServerRequestFactory :: fromGlobals ( ) ; $ this -> containers ( ) -> set ( 'request' , $ request ) ; } catch ( \ InvalidArgumentException $ e ) { new Exception ( $ e ) ; } return $ this ; }
Initiate PSR - 7 request object
4,412
private function initResponse ( ) : App { try { $ response = new Response ( ) ; $ this -> containers ( ) -> set ( 'response' , $ response ) ; } catch ( \ InvalidArgumentException $ e ) { new Exception ( $ e ) ; } return $ this ; }
Initiate PSR - 7 response object
4,413
private function initRouter ( ) : App { $ request = $ this -> container ( 'request' ) ; $ response = $ this -> container ( 'response' ) ; $ router = new Router ( $ request , $ response ) ; $ router -> error ( Error :: class ) ; $ this -> containers ( ) -> set ( 'router' , $ router ) ; return $ this ; }
Put route into the container of classes
4,414
public function map ( array $ methods , string $ pattern , $ callable ) : MethodsInterface { $ this -> container ( 'router' ) -> map ( $ methods , $ pattern , $ callable ) ; return $ this ; }
Few methods provided
4,415
private function detectAction ( string $ className , array $ variables = [ ] ) : string { $ action = $ this -> extractActionFromClass ( $ className ) ?? ( $ variables [ 'action' ] [ 0 ] ?? self :: DEFAULT_ACTION ) ; return 'action_' . $ action ; }
Detect action by string name variable or use default
4,416
private function methodCheck ( $ class , string $ action ) : bool { try { if ( ! \ method_exists ( $ class , $ action ) ) { $ className = \ get_class ( $ class ) ; throw new Exception ( "Method \"$action\" is not found in \"$className\"" ) ; } } catch ( Exception $ e ) { return false ; } return true ; }
Check if method exist in required class
4,417
private function exec ( RouteInterface $ route , RequestInterface $ request , ResponseInterface $ response , bool $ error = false ) { $ variables = $ route -> getVariables ( ) ; $ callback = $ route -> getCallback ( ) ; if ( \ is_string ( $ callback ) ) { $ className = $ this -> extractClass ( $ callback ) ; $ class = new $ className ( ) ; $ action = $ this -> detectAction ( $ callback , $ variables ) ; if ( true !== $ error && false === $ this -> methodCheck ( $ class , $ action ) ) { $ router = $ this -> container ( 'router' ) ; $ routeError = $ router -> getError ( ) ; return $ this -> exec ( $ routeError , $ request , $ response , true ) ; } $ class -> $ action ( $ request , $ response , $ variables ) ; } else { $ callback ( $ request , $ response , $ variables ) ; } return $ response -> getBody ( ) ; }
Here we need to solve how to display the page and if method is not available need to show error
4,418
public function run ( ) : StreamInterface { $ router = $ this -> container ( 'router' ) ; $ request = $ this -> container ( 'request' ) ; $ response = $ this -> container ( 'response' ) ; $ route = $ router -> getRoute ( ) ; return $ this -> exec ( $ route , $ request , $ response ) ; }
Simple runner should parse query and make work on user s class
4,419
public function resolve ( Request $ request , Response $ response ) { $ uriPath = $ this -> calledUri -> path ( $ this -> route -> configuredPath ( ) ) ; $ target = $ this -> route -> target ( ) ; if ( is_callable ( $ target ) ) { return $ target ( $ request , $ response , $ uriPath ) ; } if ( $ target instanceof Target ) { return $ target -> resolve ( $ request , $ response , $ uriPath ) ; } $ targetInstance = $ this -> injector -> getInstance ( $ target ) ; if ( ! ( $ targetInstance instanceof Target ) ) { return $ response -> internalServerError ( 'Configured target class ' . $ target . ' for route ' . $ uriPath . ' is not an instance of ' . Target :: class ) ; } return $ targetInstance -> resolve ( $ request , $ response , $ uriPath ) ; }
triggers actual logic on this resource
4,420
public function container ( Column \ Container $ column , array $ row ) { $ html = '' ; foreach ( $ column -> getColumns ( ) as $ c ) { $ html .= $ c -> render ( $ row ) . PHP_EOL ; } return $ this -> post ( $ html , $ column , $ row ) ; }
Render a container
4,421
public function boolean ( Column \ Boolean $ column , array $ row ) { $ html = '' ; if ( $ column -> getValue ( $ row ) ) { $ html .= '<i class="fa fa-check"></i>' ; } return $ this -> post ( $ html , $ column , $ row ) ; }
render boolean icon
4,422
public function remote_boolean ( Column \ RemoteBoolean $ column , array $ row ) { $ table = $ column -> getTable ( ) ; $ attributes = [ 'class' => 'ff-remote-boolean make-switch' , 'type' => 'checkbox' , 'data-size' => 'small' , 'value' => true , 'data-id' => $ row [ $ column -> getTable ( ) -> getIdField ( ) ] , 'data-column' => $ column -> getName ( ) , ] ; if ( isset ( $ row [ $ column -> getName ( ) ] ) && ! empty ( $ row [ $ column -> getName ( ) ] ) ) { $ attributes [ 'checked' ] = 'checked' ; } $ html = html ( 'input' , $ attributes ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
render boolean switch
4,423
public function icon ( Column \ Icon $ column , array $ row ) { $ html = '' ; $ html .= '<i class="fa ' . $ column -> getValue ( $ row ) . '"></i>' ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render Icon column
4,424
public function custom ( Column \ Custom $ column , array $ row ) { $ html = call_user_func ( $ column -> getCustom ( ) , $ row ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render custom callable column
4,425
public function text ( Column \ Text $ column , array $ row ) { $ attributes = $ column -> getAttributes ( ) ; if ( $ column -> hasTooltip ( ) ) { $ attributes += [ 'data-placement' => $ column -> getTooltipPosition ( ) , 'data-original-title' => $ column -> getValue ( $ row ) , 'data-toggle' => 'tooltip' ] ; $ html = html ( 'div' , $ attributes , str_limit ( $ column -> getValue ( $ row ) , 70 ) ) ; } else { $ html = html ( 'span' , $ attributes , $ column -> getValue ( $ row ) ) ; } return $ this -> post ( $ html , $ column , $ row ) ; }
Render text column
4,426
public function remote_text ( Column \ RemoteText $ column , array $ row ) { $ html = $ this -> text ( $ column , $ row ) ; $ html .= html ( 'input' , [ 'type' => 'text' , 'data-id' => $ row [ $ column -> getTable ( ) -> getIdField ( ) ] , 'data-column' => $ column -> getName ( ) ] ) ; $ html = html ( 'div' , [ 'class' => 'ff-remote-text' ] , $ html ) ; return $ html ; }
Render a text remote
4,427
public function remote_select ( Column \ RemoteSelect $ column , array $ row ) { $ options = html ( 'option' , [ ] , '--' ) ; $ elementValue = $ row [ $ column -> getIndex ( ) ] ; foreach ( $ column -> getOptions ( ) as $ value => $ key ) { $ attr = [ 'value' => $ value ] ; if ( $ value == $ elementValue ) { $ attr [ 'selected' ] = 'selected' ; } $ options .= html ( 'option' , $ attr , $ key ) ; } $ html = html ( 'select' , [ 'class' => 'ff-remote-select' , 'data-id' => $ row [ $ column -> getTable ( ) -> getIdField ( ) ] , 'data-column' => $ column -> getName ( ) ] , $ options ) ; return $ html ; }
Render remote Select
4,428
public function link ( Column \ Link $ column , array $ row ) { if ( $ column -> isRemote ( ) ) { $ column -> addAttribute ( 'data-target' , '#' . $ column -> getRemoteId ( ) ) -> addAttribute ( 'data-toggle' , 'modal' ) ; } elseif ( $ column -> isCallback ( ) ) { $ column -> addClass ( 'callback-remote' ) ; } $ html = html ( 'a' , [ 'href' => $ column -> getBindedLink ( $ row ) ] , $ column -> getValue ( $ row ) ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render link column
4,429
public function button ( Column \ Button $ column , array $ row ) { if ( $ column -> hasOption ( ) ) { $ column -> addClass ( constant ( Style :: class . '::' . $ column -> getOption ( ) ) ) ; } if ( $ column -> hasSize ( ) ) { $ column -> addClass ( constant ( Style :: class . '::' . $ column -> getSize ( ) ) ) ; } $ column -> addClass ( Style :: BUTTON_CLASS ) ; $ column -> addAttribute ( 'href' , $ column -> getBindedLink ( $ row ) ) ; $ label = '' ; if ( $ column -> hasIcon ( ) ) { $ label .= html ( 'i' , [ 'class' => $ column -> getIcon ( ) ] ) ; $ label .= PHP_EOL ; } $ name = $ column -> getBindedLabel ( $ row ) ; if ( $ column -> isIconOnly ( ) ) { $ column -> addClass ( 'ff-tooltip-left' ) ; } else { $ label .= $ name ; } if ( $ column -> isRemote ( ) ) { $ column -> addAttribute ( 'data-target' , '#' . $ column -> getRemoteId ( ) ) -> addClass ( 'modal-remote' ) ; } elseif ( $ column -> isCallback ( ) ) { $ column -> addClass ( 'callback-remote' ) ; } $ column -> addAttribute ( 'title' , $ name ) ; $ html = html ( 'a' , $ column -> getAttributes ( ) , $ label ) ; $ column -> clearClasses ( ) -> center ( ) ; return $ html ; }
Render a button
4,430
public function code ( Column \ Code $ column , array $ row ) { $ html = html ( 'code' , [ ] , $ column -> getValue ( $ row ) ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Rendor a code element
4,431
public function pre ( Column \ Pre $ column , array $ row ) { $ html = html ( 'pre' , [ ] , $ column -> getValue ( $ row ) ) ; return $ this -> post ( $ html , $ column , $ row ) ; }
Render a pre element
4,432
public function strainerSelect ( Column \ Strainer \ Select $ strainer ) { $ element = $ strainer -> getElement ( ) ; $ element -> addStyle ( 'width' , '100%' ) ; $ element -> addClass ( Style :: FORM_ELEMENT_CONTROL ) ; $ options = '' ; if ( $ element -> hasPlaceholder ( ) ) { $ options .= html ( 'option' , [ 'value' => null ] , $ element -> getPlaceholder ( ) ) ; } foreach ( $ element -> getOptions ( ) as $ value => $ label ) { $ attr = [ 'value' => $ value ] ; if ( $ element -> hasValue ( ) && in_array ( $ value , $ element -> getValue ( ) ) ) { $ attr [ 'selected' ] = 'selected' ; } $ options .= html ( 'option' , $ attr , $ label ) ; } return html ( 'select' , $ element -> getAttributes ( ) , $ options ) ; }
Render strainer for a select element
4,433
public function getOrderName ( Order $ order ) : string { if ( preg_match_all ( '/{{(.*)}}/U' , $ scheme = $ this -> getNameScheme ( ) , $ matches ) ) { foreach ( $ matches [ 1 ] as $ index => $ foundSnippet ) { $ foundSnippetName = trim ( $ foundSnippet ) ; $ usedSnippet = $ order -> hasField ( $ foundSnippetName ) ? $ order -> get ( $ foundSnippetName ) : date ( $ foundSnippetName ) ; $ scheme = str_replace ( $ matches [ 0 ] [ $ index ] , $ usedSnippet , $ scheme ) ; } } return $ scheme ; }
Returns the name for the order .
4,434
protected function getMIMEType ( $ file ) { $ mime = 'application/octet-stream' ; if ( function_exists ( 'finfo_open' ) && $ info = @ finfo_open ( FILEINFO_MIME ) ) { if ( ( $ mime = @ finfo_file ( $ info , $ file ) ) !== \ false ) { $ mime = explode ( ';' , $ mime ) ; $ mime = trim ( $ mime [ 0 ] ) ; } } return $ mime ; }
Attempts to get the MIME type of a given file . Required for native file uploads .
4,435
protected function getResponse ( $ response , $ returnBool , $ arrayKey = '' ) { $ response = $ this -> jsonDecode ( $ response ) ; if ( $ response === \ null ) { return \ false ; } if ( $ returnBool ) { return $ this -> getStatus ( $ response ) ; } if ( $ arrayKey ) { if ( isset ( $ response [ $ arrayKey ] ) ) { return $ response [ $ arrayKey ] ; } return \ false ; } return $ response ; }
Decodes the response and returns the appropriate value
4,436
protected function nativeJsonDecode ( $ string ) { $ result = @ json_decode ( $ string , \ true ) ; if ( ! $ result || JSON_ERROR_NONE !== json_last_error ( ) ) { $ result = \ null ; } return $ result ; }
Decodes a JSON encoded string natively .
4,437
protected function intFloatCompare ( NI $ a , NI $ b ) { return $ this -> rationalCompare ( RationalTypeFactory :: fromFloat ( $ a -> asFloatType ( ) ) , RationalTypeFactory :: fromFloat ( $ b -> asFloatType ( ) ) ) ; }
Compare int and float types
4,438
protected function rationalCompare ( RationalType $ a , RationalType $ b ) { $ res = $ this -> calculator -> rationalSub ( $ a , $ b ) ; if ( $ res -> numerator ( ) -> get ( ) == 0 ) { return 0 ; } if ( $ res -> numerator ( ) -> get ( ) < 0 ) { return - 1 ; } return 1 ; }
Compare two rationals
4,439
protected function complexCompare ( ComplexType $ a , ComplexType $ b ) { if ( $ a -> isReal ( ) && $ b -> isReal ( ) ) { return $ this -> rationalCompare ( $ a -> r ( ) , $ b -> r ( ) ) ; } $ am = $ a -> modulus ( ) -> asFloatType ( ) -> get ( ) ; $ bm = $ b -> modulus ( ) -> asFloatType ( ) -> get ( ) ; if ( $ am == $ bm ) { return 0 ; } if ( $ am < $ bm ) { return - 1 ; } return 1 ; }
Compare complex numbers . If both operands are real then compare the real parts else compare the modulii of the two numbers
4,440
public function applyConclusiveMatch ( $ userAgent ) { if ( WURFL_Configuration_ConfigHolder :: getWURFLConfig ( ) -> isHighPerformance ( ) ) { $ tolerance = WURFL_Handlers_Utils :: firstCloseParen ( $ userAgent ) ; return $ this -> getDeviceIDFromRIS ( $ userAgent , $ tolerance ) ; } else { return $ this -> getDeviceIDFromLD ( $ userAgent , 5 ) ; } }
If UA starts with Mozilla apply LD with tolerance 5 .
4,441
public function listCollections ( array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> getAll ( ) ; $ this -> checkResponse ( $ rs ) ; $ colls = array_get ( $ rs , 'DocumentCollections' ) ; $ list = [ ] ; if ( ! empty ( $ colls ) ) { foreach ( $ colls as $ coll ) { $ list [ ] = array_get ( $ coll , 'id' ) ; } } return $ list ; }
List all collections in a Database .
4,442
public function getCollection ( $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> get ( $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Retrieves a collection information .
4,443
public function replaceCollection ( array $ data , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ coll = new Collection ( $ this -> client , $ this -> database ) ; $ coll -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ coll -> replace ( $ data , $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Replaces a collection .
4,444
public function listDocuments ( $ collection , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> getAll ( ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
List all documents in a collection .
4,445
public function getDocument ( $ collection , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> get ( $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Retrieves a document .
4,446
public function createDocument ( $ collection , array $ data , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> create ( $ data ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Creates a document .
4,447
public function replaceDocument ( $ collection , array $ data , $ id , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> replace ( $ data , $ id ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Replaces a document .
4,448
public function queryDocument ( $ collection , $ sql , array $ params = [ ] , array $ options = [ ] ) { $ this -> setOptions ( $ options ) ; $ doc = new Document ( $ this -> client , $ this -> database , $ collection ) ; $ doc -> setHeaders ( $ this -> getHeaders ( ) ) ; $ rs = $ doc -> query ( $ sql , $ params ) ; $ this -> checkResponse ( $ rs ) ; unset ( $ rs [ '_curl_info' ] ) ; return $ rs ; }
Queries a collection for documents .
4,449
protected function checkResponse ( array $ response ) { $ responseCode = intval ( array_get ( $ response , '_curl_info.http_code' ) ) ; $ message = array_get ( $ response , 'message' ) ; if ( $ responseCode >= 400 ) { $ context = [ 'response_headers' => array_get ( $ response , '_curl_info.response_headers' ) ] ; throw new RestException ( $ responseCode , $ message , null , null , $ context ) ; } }
Checks response status code for exceptions .
4,450
public function createQuery ( $ context = 'list' ) { $ query = parent :: createQuery ( $ context ) ; $ query -> leftJoin ( $ query -> getRootAlias ( ) . '.article' , 'article' ) -> addSelect ( 'article' ) -> leftJoin ( $ query -> getRootAlias ( ) . '.parent' , 'parent' ) -> addSelect ( 'parent' ) -> leftJoin ( $ query -> getRootAlias ( ) . '.children' , 'children' ) -> addSelect ( 'children' ) -> orderBy ( $ query -> getRootAlias ( ) . '.root, ' . $ query -> getRootAlias ( ) . '.lft' , 'ASC' ) ; return $ query ; }
Need to override createQuery method because of list order & joins
4,451
private static function mb_fill_string ( string $ pattern , $ length , $ encoding = 'UTF-8' ) : string { $ pattern_length = mb_strlen ( $ pattern , $ encoding ) ; $ str = '' ; $ i = 0 ; while ( $ i < $ length ) { if ( $ length - $ i >= $ pattern_length ) { $ str .= $ pattern ; $ i += $ pattern_length ; } else { $ str .= mb_substr ( $ pattern , 0 , $ length - $ i , $ encoding ) ; break ; } } return $ str ; }
Returns a string of given length filled with some pattern substring
4,452
public function resolve ( Request $ request , Response $ response , UriPath $ uriPath ) { $ routeName = $ uriPath -> remaining ( 'index.html' ) ; if ( ! file_exists ( $ this -> routePath . $ routeName ) ) { return $ response -> notFound ( ) ; } return $ this -> modifyContent ( $ request , $ response , file_get_contents ( $ this -> routePath . $ routeName ) , $ routeName ) ; }
processes the request
4,453
public function __isset ( $ property ) { if ( $ propertyReflector = $ this -> liberatorPropertyReflector ( $ property ) ) { return null !== $ propertyReflector -> getValue ( $ this -> popsValue ( ) ) ; } return parent :: __isset ( $ property ) ; }
Returns true if the property exists on the wrapped object .
4,454
protected function initService ( string $ type , string $ alias , array $ options ) { $ id = $ this -> resolverFactory -> resolve ( $ type , $ alias ) ; $ service = $ this -> get ( $ id ) ; $ service -> setOptions ( $ options ) ; return $ service ; }
Initializes a service by its type
4,455
public function getBid ( $ itemId ) { $ item = Item :: findOrFail ( $ itemId ) ; if ( ! $ item -> auction ) { return redirect ( $ item -> url ) -> withErrors ( [ 'This item is not an auction, so cannot be bid on.' , ] ) ; } $ bids = $ item -> getBidHistory ( ) ; $ highest_bid = $ bids -> first ( ) ? : new Bid ( ) ; if ( $ bids -> isEmpty ( ) ) { $ minimum_bid = $ item -> startPrice ; } elseif ( $ highest_bid -> bidder == Auth :: user ( ) ) { $ minimum_bid = BidIncrement :: getMinimumNextBid ( $ highest_bid -> amount ) ; } else { $ minimum_bid = BidIncrement :: getMinimumNextBid ( $ item -> biddingPrice ) ; } return view ( 'mustard::item.bid' , [ 'item' => $ item , 'bids' => $ bids , 'highest_bid' => $ highest_bid , 'minimum_bid' => $ minimum_bid , ] ) ; }
Return the item bid view .
4,456
public function generate ( $ lenght = 4 , $ separator = ' ' ) { $ length = count ( $ this -> lists ) ; $ words = [ ] ; $ randomArray = static :: getRandomArray ( $ lenght ) ; foreach ( $ randomArray as $ index => $ random ) { $ list = $ this -> lists [ $ index % $ length ] ; $ words [ ] = $ list -> get ( $ random ) ; } return implode ( $ separator , $ words ) ; }
Generate password from word lists .
4,457
public static function generateRu ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ Ru ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates Russian phrase password .
4,458
public static function generateEn ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ En ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates English phrase password .
4,459
public static function generateDe ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ De ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates German phrase password .
4,460
public static function generateRuTranslit ( $ lenght = 4 , $ separator = ' ' ) { $ list = new WordList \ RuTranslit ( ) ; return ( new static ( $ list ) ) -> generate ( $ lenght , $ separator ) ; }
Static function generates transliterated Russian phrase password
4,461
protected static function getRandomArray ( $ length ) { $ bytes = random_bytes ( $ length * 2 ) ; $ result = [ ] ; foreach ( unpack ( 'S*' , $ bytes ) as $ long ) { $ result [ ] = $ long / 0xFFFF ; } return $ result ; }
Get array of random numbers between 0 . 0 - 1 . 0 .
4,462
public static function extIs ( $ value ) { if ( static :: is ( $ value ) ) { return true ; } if ( is_string ( $ value ) ) { $ value = strtolower ( $ value ) ; return ( static :: isTrueStrExt ( $ value ) || static :: isFalseStrExt ( $ value ) ) ; } return false ; }
Tests if the given value is a bool or not .
4,463
public static function compare ( $ bool1 , $ bool2 ) { if ( ! static :: is ( $ bool1 ) || ! static :: is ( $ bool2 ) ) { throw new \ InvalidArgumentException ( "The \$bool1 and \$bool2 parameters must be of type bool." ) ; } return ( ( int ) $ bool1 - ( int ) $ bool2 ) ; }
Compares two bool values .
4,464
public function add ( $ property ) { if ( ! $ property instanceof PropertyInterface ) { throw new \ InvalidArgumentException ( 'This Property must be a instance of \ClassGeneration\PropertyInterface' ) ; } if ( $ property -> getName ( ) === null ) { $ property -> setName ( 'property' . ( $ this -> count ( ) + 1 ) ) ; } parent :: set ( $ property -> getName ( ) , $ property ) ; return true ; }
Adds a new Property on the collection .
4,465
public function toString ( ) { $ string = '' ; $ properties = $ this -> getIterator ( ) ; foreach ( $ properties as $ property ) { $ string .= $ property -> toString ( ) ; } return $ string ; }
Parse the Property Collection to string .
4,466
public function getByName ( $ propertyName ) { $ foundList = new self ( ) ; $ list = $ this -> getIterator ( ) ; foreach ( $ list as $ property ) { if ( ( is_array ( $ propertyName ) && in_array ( $ property -> getName ( ) , $ propertyName ) ) || ( $ property -> getName ( ) === $ propertyName ) ) { $ foundList -> add ( $ property ) ; } } return $ foundList ; }
Find the properties by name .
4,467
protected function fillForm ( Element \ NodeElement $ form ) { $ inputs = $ form -> findAll ( 'css' , 'input[type="text"]' ) ; foreach ( $ inputs as $ i ) { if ( $ i -> isVisible ( ) ) { if ( $ i -> hasAttribute ( 'name' ) ) { $ name = $ i -> getAttribute ( 'name' ) ; $ value = $ this -> getFakerValue ( $ name ) ; } else { $ value = $ this -> faker ( ) -> text ( ) ; } $ i -> setValue ( $ value ) ; } } $ passwords = $ form -> findAll ( 'css' , 'input[type="password"]' ) ; $ password = $ this -> faker ( ) -> password ; foreach ( $ passwords as $ p ) { if ( $ p -> isVisible ( ) ) { $ p -> setValue ( $ password ) ; } } $ selects = $ form -> findAll ( 'css' , 'select' ) ; foreach ( $ selects as $ s ) { if ( $ s -> isVisible ( ) ) { $ s -> selectOption ( $ s -> find ( 'css' , 'option' ) -> getAttribute ( 'name' ) ) ; } } $ checkboxes = $ form -> findAll ( 'css' , 'checkbox' ) ; foreach ( $ checkboxes as $ c ) { if ( $ c -> isVisible ( ) ) { $ c -> check ( ) ; } } $ radios = $ form -> findAll ( 'css' , 'input[type="radio"]' ) ; $ radio_names = array ( ) ; foreach ( $ radios as $ r ) { if ( $ r -> isVisible ( ) ) { if ( $ r -> hasAttribute ( 'name' ) ) { $ name = $ r -> getAttribute ( 'name' ) ; if ( ! isset ( $ radio_names [ $ name ] ) ) { $ radio_names [ $ name ] = true ; $ r -> click ( ) ; } } } } }
Fuzz fill all form fields with random data
4,468
public function getBasicFunctionRenames ( $ maxVersion = '' ) { $ data = array ( '1.7' => array ( 'elgg_validate_action_url' => 'elgg_add_action_tokens_to_url' , 'menu_item' => 'make_register_object' , 'extend_view' => 'elgg_extend_view' , 'get_views' => 'elgg_get_views' , ) , '1.8' => array ( 'register_elgg_event_handler' => 'elgg_register_event_handler' , 'unregister_elgg_event_handler' => 'elgg_unregister_event_handler' , 'trigger_elgg_event' => 'elgg_trigger_event' , 'register_plugin_hook' => 'elgg_register_plugin_hook_handler' , 'unregister_plugin_hook' => 'elgg_unregister_plugin_hook_handler' , 'trigger_plugin_hook' => 'elgg_trigger_plugin_hook' , 'friendly_title' => 'elgg_get_friendly_title' , 'friendly_time' => 'elgg_view_friendly_time' , 'page_owner' => 'elgg_get_page_owner_guid' , 'page_owner_entity' => 'elgg_get_page_owner_entity' , 'set_page_owner' => 'elgg_set_page_owner_guid' , 'set_context' => 'elgg_set_context' , 'get_context' => 'elgg_get_context' , 'get_plugin_name' => 'elgg_get_calling_plugin_id' , 'is_plugin_enabled' => 'elgg_is_active_plugin' , 'set_user_validation_status' => 'elgg_set_user_validation_status' , 'get_loggedin_user' => 'elgg_get_logged_in_user_entity' , 'get_loggedin_userid' => 'elgg_get_logged_in_user_guid' , 'isloggedin' => 'elgg_is_logged_in' , 'isadminloggedin' => 'elgg_is_admin_logged_in' , 'load_plugins' => '_elgg_load_plugins' , 'set_plugin_usersetting' => 'elgg_set_plugin_user_setting' , 'clear_plugin_usersetting' => 'elgg_unset_plugin_user_setting' , 'get_plugin_usersetting' => 'elgg_get_plugin_user_setting' , 'set_plugin_setting' => 'elgg_set_plugin_setting' , 'get_plugin_setting' => 'elgg_get_plugin_setting' , 'clear_plugin_setting' => 'elgg_unset_plugin_setting' , 'clear_all_plugin_settings' => 'elgg_unset_all_plugin_settings' , 'set_view_location' => 'elgg_set_view_location' , 'get_metadata' => 'elgg_get_metadata_from_id' , 'get_annotation' => 'elgg_get_annotation_from_id' , 'register_page_handler' => 'elgg_register_page_handler' , 'unregister_page_handler' => 'elgg_unregister_page_handler' , 'register_entity_type' => 'elgg_register_entity_type' , 'elgg_view_register_simplecache' => 'elgg_register_simplecache_view' , 'elgg_view_regenerate_simplecache' => 'elgg_regenerate_simplecache' , 'elgg_view_enable_simplecache' => 'elgg_enable_simplecache' , 'elgg_view_disable_simplecache' => 'elgg_disable_simplecache' , 'remove_widget_type' => 'elgg_unregister_widget_type' , 'widget_type_exists' => 'elgg_is_widget_type' , 'get_widget_types' => 'elgg_get_widget_types' , 'display_widget' => 'elgg_view_entity' , 'invalidate_cache_for_entity' => '_elgg_invalidate_cache_for_entity' , 'cache_entity' => '_elgg_cache_entity' , 'retrieve_cached_entity' => '_elgg_retrieve_cached_entity' , ) , '1.9' => array ( 'setup_db_connections' => '_elgg_services()->db->setupConnections' , 'get_db_link' => '_elgg_services()->db->getLink' , 'get_db_error' => 'mysql_error' , 'execute_delayed_query' => '_elgg_services()->db->registerDelayedQuery' , 'elgg_regenerate_simplecache' => 'elgg_invalidate_simplecache' , 'elgg_get_filepath_cache' => 'elgg_get_system_cache' , 'elgg_filepath_cache_reset' => 'elgg_reset_system_cache' , 'elgg_filepath_cache_save' => 'elgg_save_system_cache' , 'elgg_filepath_cache_load' => 'elgg_load_system_cache' , 'elgg_enable_filepath_cache' => 'elgg_enable_system_cache' , 'elgg_disable_filepath_cache' => 'elgg_disable_system_cache' , 'unregister_entity_type' => 'elgg_unregister_entity_type' , 'autop' => 'elgg_autop' , 'xml_to_object' => 'new ElggXMLElement' , 'unregister_notification_handler' => 'elgg_unregister_notification_method' , ) , '1.10' => array ( 'file_get_general_file_type' => 'elgg_get_file_simple_type' , 'file_get_simple_type' => 'elgg_get_file_simple_type' , ) , ) ; $ result = array ( ) ; foreach ( $ data as $ version => $ rows ) { if ( ! $ maxVersion || version_compare ( $ version , $ maxVersion , '<=' ) ) { $ result = array_merge ( $ result , $ rows ) ; } } return $ result ; }
Just basic function renames from A to B
4,469
public function createToken ( string $ tokenSalt ) : Token { $ this -> setToken ( Token :: create ( $ this , $ tokenSalt ) ) ; return $ this -> token ( ) ; }
creates new token for the user with given token salt
4,470
public function bindFetcher ( $ fetcherKey , $ relationshipName , $ callback = null ) { if ( $ callback !== null ) { $ this -> fetcherRelationships [ $ fetcherKey ] [ ] = $ relationshipName ; } $ callback = $ callback ? : $ relationshipName ; $ this -> fetchers [ $ fetcherKey ] = $ callback ; }
Adds the callback to fetch a resolved relationship for a parameter on a resolver .
4,471
protected function buildParametersForResolver ( $ resolver , array $ parents , array $ defaultParameters ) { $ reflector = $ this -> getCallReflector ( $ resolver ) ; $ parameters = $ reflector -> getParameters ( ) ; $ defaultParameters = array_reverse ( $ defaultParameters ) ; return array_map ( function ( \ ReflectionParameter $ parameter ) use ( & $ defaultParameters , $ parents ) { $ parameterClass = $ parameter -> getClass ( ) ; if ( $ parameterClass === null ) { return array_pop ( $ defaultParameters ) ; } $ fetched = $ this -> findFetchedResource ( $ parameter , $ parameterClass ) ; if ( $ fetched !== null ) { return $ fetched ; } $ parent = $ this -> findParent ( $ parameterClass , $ parents ) ; if ( $ parent !== null ) { return $ parent ; } foreach ( $ this -> customParameterResolvers as $ parameterResolver ) { $ resolved = $ this -> callResolver ( $ parameterResolver , [ $ parameter , Arr :: get ( $ this -> resource , 'id' ) , Arr :: get ( $ this -> resource , 'type' ) , ] ) ; if ( $ resolved !== null ) { return $ resolved ; } } if ( $ this -> container -> has ( $ parameterClass -> getName ( ) ) ) { return $ this -> container -> get ( $ parameterClass -> getName ( ) ) ; } return null ; } , $ parameters ) ; }
Build the parameters needed for the function given
4,472
protected function findParent ( \ ReflectionClass $ class , $ parents ) { $ parents = array_reverse ( $ parents ) ; foreach ( array_reverse ( $ parents ) as $ parent ) { if ( $ class -> getName ( ) === get_class ( $ parent ) ) { return $ parent ; } } foreach ( array_reverse ( $ parents ) as $ parent ) { if ( $ class -> isInstance ( $ parent ) ) { return $ parent ; } } return null ; }
Try to find a parent that matches the class
4,473
private function getResolverForType ( $ type ) { $ resolver = Arr :: get ( $ this -> resolvers , $ type ) ; if ( $ resolver !== null ) { return $ resolver ; } $ parts = explode ( '.' , $ type ) ; if ( count ( $ parts ) > 1 ) { array_shift ( $ parts ) ; return $ this -> getResolverForType ( implode ( '.' , $ parts ) ) ; } return null ; }
Find the resolver for the type given
4,474
protected function callResolver ( $ resolver , $ parameters ) { if ( is_string ( $ resolver ) ) { return call_user_func_array ( $ resolver , $ parameters ) ; } if ( count ( $ parameters ) === 0 ) { return $ resolver ( ) ; } if ( count ( $ parameters ) === 1 ) { return $ resolver ( $ parameters [ 0 ] ) ; } if ( count ( $ parameters ) === 2 ) { return $ resolver ( $ parameters [ 0 ] , $ parameters [ 1 ] ) ; } if ( count ( $ parameters ) === 3 ) { return $ resolver ( $ parameters [ 0 ] , $ parameters [ 1 ] , $ parameters [ 2 ] ) ; } if ( count ( $ parameters ) === 4 ) { return $ resolver ( $ parameters [ 0 ] , $ parameters [ 1 ] , $ parameters [ 2 ] , $ parameters [ 3 ] ) ; } return call_user_func_array ( $ resolver , $ parameters ) ; }
Call the resolver with the given parameters .
4,475
protected function recordFetchedRelationship ( RelationshipResource $ relationship ) { $ this -> fetchedRelationships [ ] = $ this -> resource [ 'type' ] . '.' . $ relationship -> getName ( ) . '.' . $ relationship -> getType ( ) ; }
Save that a resource has been fetched .
4,476
public function set ( $ key , $ value ) { $ this -> loadIfNeeded ( ) ; $ this -> array [ $ key ] = $ value ; $ this -> saver -> save ( $ this -> fileName , $ this -> array , $ this -> fileMap ) ; }
Set a given configuration value and save file
4,477
public function setAll ( $ array ) { $ this -> array = $ array ; $ this -> fileMap = null ; $ this -> saver -> save ( $ this -> fileName , $ this -> array , $ this -> fileMap ) ; }
Change all configuration values and save file
4,478
public function toString ( ) { $ arguments = $ this -> getIterator ( ) ; $ params = array ( ) ; $ optionals = array ( ) ; foreach ( $ arguments as $ argument ) { if ( $ argument -> isOptional ( ) ) { $ optionals [ ] = $ argument -> toString ( ) ; } else { $ params [ ] = $ argument -> toString ( ) ; } } return implode ( ', ' , array_merge ( $ params , $ optionals ) ) ; }
Returns the arguments in string .
4,479
public function getCapability ( $ capabilityName ) { if ( isset ( $ this -> _device -> capabilities [ $ capabilityName ] ) ) { return $ this -> _device -> capabilities [ $ capabilityName ] ; } $ key = $ this -> _device -> id . "_" . $ capabilityName ; $ capabilityValue = $ this -> _cacheProvider -> get ( $ key ) ; if ( empty ( $ capabilityValue ) ) { $ capabilityValue = $ this -> _deviceRepository -> getCapabilityForDevice ( $ this -> _device -> fallBack , $ capabilityName ) ; $ this -> _cacheProvider -> put ( $ key , $ capabilityValue ) ; } return $ capabilityValue ; }
Returns the value of a given capability name
4,480
public function getAll ( $ service , $ page = 1 , $ perPage = 25 ) { $ params = array ( 'page' => $ page , 'per_page' => $ perPage ) ; return $ this -> _user -> get ( 'account/identity/limit/' . $ service , $ params ) ; }
Get all the limits for a service
4,481
public function create ( $ identity , $ service , $ total_allowance = false , $ analyze_queries = false ) { $ params = array ( 'service' => $ service , ) ; if ( $ total_allowance ) { $ params [ 'total_allowance' ] = $ total_allowance ; } if ( $ analyze_queries ) { $ params [ 'analyze_queries' ] = $ analyze_queries ; } return $ this -> _user -> post ( 'account/identity/' . $ identity . '/limit' , $ params ) ; }
Create a limit for a service
4,482
public function update ( $ identity , $ service , $ total_allowance = false , $ analyze_queries = false ) { $ params = array ( ) ; if ( $ total_allowance ) { $ params [ 'total_allowance' ] = $ total_allowance ; } if ( $ analyze_queries ) { $ params [ 'analyze_queries' ] = $ analyze_queries ; } return $ response = $ this -> _user -> put ( 'account/identity/' . $ identity . '/limit/' . $ service , $ params ) ; }
Update the limit for an service
4,483
public function getAll ( $ label = null , $ page = 1 , $ perPage = 25 ) { $ params = array ( 'page' => $ page , 'per_page' => $ perPage ) ; if ( $ label !== null ) { $ params [ 'label' ] = $ label ; } return $ this -> _user -> get ( 'account/identity' , $ params ) ; }
Gets all the identities
4,484
public function create ( $ label , $ master = false , $ status = 'active' ) { $ params = array ( 'label' => $ label , 'master' => $ master , 'status' => $ status ) ; return $ this -> _user -> post ( 'account/identity' , $ params ) ; }
Creates an identity
4,485
public function update ( $ identity , $ label = null , $ master = null , $ status = null ) { $ params = array ( ) ; if ( ! is_null ( $ label ) ) { $ params [ 'label' ] = $ label ; } if ( ! is_null ( $ master ) ) { $ params [ 'master' ] = $ master ; } if ( ! is_null ( $ status ) ) { $ params [ 'status' ] = $ status ; } return $ this -> _user -> put ( 'account/identity/' . $ identity , $ params ) ; }
Updates an identity
4,486
public static function createFromProperty ( PropertyInterface $ property ) { $ argument = new self ( ) ; $ argument -> setName ( $ property -> getName ( ) ) -> setType ( $ property -> getType ( ) ) ; return $ argument ; }
Creates Argument from Property Object .
4,487
protected function getCssContent ( ) { $ styleString = "" ; if ( class_exists ( "\\DOMDocument" ) ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadHTML ( $ this -> getHtmlContent ( ) ) ; foreach ( $ doc -> getElementsByTagName ( 'style' ) as $ styleNode ) { $ styleString .= $ styleNode -> nodeValue . "\r\n" ; } } else { throw new \ RuntimeException ( "Required extension 'dom' seems to be missing." ) ; } return $ styleString ; }
Gets the CSS content extracted from the HTML source content .
4,488
function create_hash ( $ password ) { $ encrypt_method = "AES-256-CBC" ; $ key = hash ( 'sha256' , $ secret_key ) ; $ iv = substr ( hash ( 'sha256' , $ secret_iv ) , 0 , 16 ) ; $ salt = base64_encode ( openssl_encrypt ( $ string , $ encrypt_method , $ key , 0 , $ iv ) ) ; return PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITERATIONS . ":" . $ salt . ":" . base64_encode ( $ this -> pbkdf2 ( PBKDF2_HASH_ALGORITHM , $ password , $ salt , PBKDF2_ITERATIONS , PBKDF2_HASH_BYTES , true ) ) ; }
These constants may be changed without breaking existing hashes .
4,489
public static function addProducer ( Producer $ producer ) { $ appId = $ producer -> getAppId ( ) ; if ( array_key_exists ( $ appId , static :: $ producers ) ) { throw new Exception \ FacadeException ( "Producer with {$appId} already exists!" ) ; } static :: $ producers [ $ appId ] = $ producer ; return true ; }
Add producer to facade
4,490
public static function addBuilder ( $ appId , $ builderFunction ) { if ( array_key_exists ( $ appId , static :: $ builders ) ) { throw new Exception \ FacadeException ( "Builder with {$appId} already exists!" ) ; } if ( ! is_callable ( $ builderFunction ) ) { throw new Exception \ FacadeException ( "Builder function for {$appId} is not callable!" ) ; } static :: $ builders [ $ appId ] = $ builderFunction ; return true ; }
Add Builder to facade builder scope
4,491
public static function getProducer ( $ appId = Producer :: DEFAULT_APP_ID ) { if ( null === $ appId ) { $ appId = Producer :: DEFAULT_APP_ID ; } if ( ! array_key_exists ( $ appId , static :: $ producers ) ) { if ( array_key_exists ( $ appId , static :: $ builders ) ) { $ func = static :: $ builders [ $ appId ] ; static :: addProducer ( $ func ( $ appId ) ) ; unset ( static :: $ builders [ $ appId ] ) ; return static :: getProducer ( $ appId ) ; } throw new Exception \ FacadeException ( "Producer with appId: '{$appId}' not exists yet!" ) ; } return static :: $ producers [ $ appId ] ; }
Get producer by id
4,492
public static function getProducersStats ( ) { $ producersStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ producersStats [ $ appId ] = $ producer -> getStats ( ) ; } return $ producersStats ; }
Get producer statistic
4,493
public static function getQueuesStats ( ) { $ queuesStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ queuesStats [ $ appId ] = $ producer -> getQueue ( ) -> getStats ( ) ; } return $ queuesStats ; }
Get queues statistic
4,494
public static function getJobsReserved ( ) { $ jobsReserved = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ jobsReserved [ $ appId ] = $ producer -> getQueue ( ) -> getJobReserved ( ) ; } return $ jobsReserved ; }
Get all reserved jobs
4,495
public static function getManagersStats ( ) { $ managersStats = [ ] ; foreach ( static :: $ producers as $ appId => $ producer ) { $ redis = $ producer -> getRedis ( ) ; $ keys = [ 'stat' => $ redis -> keys ( Manager :: REDIS_NS_STATS . '*' ) , 'live' => $ redis -> keys ( Manager :: REDIS_NS_LIVE . '*' ) ] ; foreach ( $ keys as $ type => $ statsKeys ) { foreach ( $ statsKeys as $ statsKey ) { $ parse = Manager :: parseManagerStatKey ( $ statsKey ) ; if ( $ appId != $ parse [ 'appId' ] ) { continue ; } $ statsItemData = $ redis -> hgetall ( $ statsKey ) ; $ statsItemData [ 'workerClass' ] = $ parse [ 'workerClass' ] ; $ statsItemData [ 'appId' ] = $ parse [ 'appId' ] ; $ managersStats [ $ parse [ 'appId' ] ] [ $ type ] [ ] = $ statsItemData ; } } } return $ managersStats ; }
Get all managers statistic
4,496
public function link ( Form \ Element \ Link $ element ) { $ html = '<label>' . $ element -> getLabel ( ) . '</label>' ; $ html .= '<p>' . html ( 'a' , [ 'href' => $ element -> getValue ( ) , 'target' => '_blank' ] , $ element -> getValue ( ) ) . '</p>' ; $ class = Style :: FORM_GROUP_CLASS ; $ html = html ( 'div' , compact ( 'class' ) , $ html ) ; return $ html ; }
Render a link element
4,497
public function date ( Form \ Element \ Date $ element ) { if ( $ hasError = ! $ element -> getValidator ( ) -> isValid ( ) ) { $ element -> removeAttribute ( 'data-trigger' ) ; if ( empty ( $ element -> getAttribute ( 'data-placement' ) ) ) { $ element -> addAttribute ( 'data-placement' , 'bottom' ) ; } $ message = '' ; foreach ( $ element -> getValidator ( ) -> getErrors ( ) as $ error ) { $ message .= $ error . ' ' ; } $ element -> addAttribute ( 'data-original-title' , $ message ) ; $ element -> addAttribute ( 'data-toggle' , 'tooltip' ) ; } $ element -> addClass ( 'date-picker' ) ; $ element -> addClass ( Style :: FORM_ELEMENT_CONTROL ) ; $ label = '' ; $ element -> addAttribute ( 'value' , $ element -> getDisplayValue ( ) ) ; if ( $ element -> getForm ( ) -> hasLabel ( ) ) { $ label = '<label for="' . $ element -> getName ( ) . '">' . $ element -> getLabel ( ) . ( $ element -> hasRule ( 'required' ) ? ' *' : '' ) . '</label>' ; } $ html = $ label . html ( 'input' , $ element -> getAttributes ( ) ) ; $ class = Style :: FORM_GROUP_CLASS ; if ( $ hasError ) { $ class .= ' ' . Style :: FORM_GROUP_ERROR ; } $ html = html ( 'div' , compact ( 'class' ) , $ html ) ; return $ html ; }
Render a date element
4,498
public static function getDayTimestamp ( $ now = null , $ offset = 8 ) { $ now = $ now === null ? time ( ) : $ now ; $ gtm0 = $ now - ( $ now % 86400 ) ; $ dayline = ( $ now - $ gtm0 ) / 3600 ; if ( $ dayline + $ offset > 23 ) { return $ gtm0 + 86400 + $ offset * 3600 * - 1 ; } else { return $ gtm0 + $ offset * 3600 * - 1 ; } }
get the timestamp at current dat start
4,499
public static function getHourTimestamp ( $ now = null ) { $ now = $ now === null ? time ( ) : $ now ; $ diff = $ now % 3600 ; return $ now - $ diff ; }
get the timestamp at current hour start