idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
50,500
|
private function checkMessageId ( $ id ) { if ( ! is_int ( $ id ) ) { throw new ImapClientException ( '$id must be an integer!' ) ; } ; if ( $ id <= 0 ) { throw new ImapClientException ( '$id must be greater then 0!' ) ; } ; if ( $ id > $ this -> countMessages ( ) ) { throw new ImapClientException ( '$id does not exist' ) ; } }
|
Check message id
|
50,501
|
public static function getById ( $ paymentId , $ apiContext = null ) { if ( isset ( $ apiContext ) ) { return Payment :: get ( $ paymentId , $ apiContext ) ; } return Payment :: get ( $ paymentId ) ; }
|
grape payment details using the paymentId
|
50,502
|
public static function getAll ( $ param , $ apiContext = null ) { if ( isset ( $ apiContext ) ) { return Payment :: all ( $ param , $ apiContext ) ; } return Payment :: all ( $ param ) ; }
|
grape all payment details
|
50,503
|
protected function hasInvalidCascadingRelationships ( ) { return array_filter ( $ this -> getCascadingDeletes ( ) , function ( $ relationship ) { return ! method_exists ( $ this , $ relationship ) || ! $ this -> { $ relationship } ( ) instanceof Relation ; } ) ; }
|
Determine if the current model has any invalid cascading relationships defined .
|
50,504
|
public static function debugLog ( string $ name , array $ arguments ) { $ logger = Config :: getLogger ( ) ; if ( $ logger ) { $ logger -> debug ( $ name , $ arguments ) ; } }
|
Log a debug message .
|
50,505
|
private static function unwrap ( array $ result ) : array { array_walk_recursive ( $ result , function ( & $ value ) { if ( $ value instanceof Image ) { $ value = $ value -> image ; } } ) ; return $ result ; }
|
Unwrap an array of stuff ready to pass down to the vips_ layer . We swap instances of the Image for the plain resource .
|
50,506
|
private static function errorVips ( ) { $ message = vips_error_buffer ( ) ; $ exception = new Exception ( $ message ) ; Utils :: errorLog ( $ message , $ exception ) ; throw $ exception ; }
|
Throw a vips error as an exception .
|
50,507
|
private static function runCmplx ( $ func , Image $ image ) : Image { $ original_format = $ image -> format ; if ( $ image -> format != 'complex' && $ image -> format != 'dpcomplex' ) { if ( $ image -> bands % 2 != 0 ) { throw new Exception ( 'not an even number of bands' ) ; } if ( $ image -> format != 'float' && $ image -> format != 'double' ) { $ image = $ image -> cast ( 'float' ) ; } if ( $ image -> format == 'double' ) { $ new_format = 'dpcomplex' ; } else { $ new_format = 'complex' ; } $ image = $ image -> copy ( [ 'format' => $ new_format , 'bands' => $ image -> bands / 2 ] ) ; } $ image = $ func ( $ image ) ; if ( $ original_format != 'complex' && $ original_format != 'dpcomplex' ) { if ( $ image -> format == 'dpcomplex' ) { $ new_format = 'double' ; } else { $ new_format = 'float' ; } $ image = $ image -> copy ( [ 'format' => $ new_format , 'bands' => $ image -> bands * 2 ] ) ; } return $ image ; }
|
Run a function expecting a complex image . If the image is not in complex format try to make it complex by joining adjacant bands as real and imaginary .
|
50,508
|
public static function newFromFile ( string $ filename , array $ options = [ ] ) : Image { Utils :: debugLog ( 'newFromFile' , [ 'instance' => null , 'arguments' => [ $ filename , $ options ] ] ) ; $ options = self :: unwrap ( $ options ) ; $ result = vips_image_new_from_file ( $ filename , $ options ) ; self :: errorIsArray ( $ result ) ; $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'newFromFile' , [ 'result' => $ result ] ) ; return $ result ; }
|
Create a new Image from a file on disc .
|
50,509
|
public static function newFromBuffer ( string $ buffer , string $ option_string = '' , array $ options = [ ] ) : Image { Utils :: debugLog ( 'newFromBuffer' , [ 'instance' => null , 'arguments' => [ $ buffer , $ option_string , $ options ] ] ) ; $ options = self :: unwrap ( $ options ) ; $ result = vips_image_new_from_buffer ( $ buffer , $ option_string , $ options ) ; self :: errorIsArray ( $ result ) ; $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'newFromBuffer' , [ 'result' => $ result ] ) ; return $ result ; }
|
Create a new Image from a compressed image held as a string .
|
50,510
|
public static function newFromArray ( array $ array , float $ scale = 1.0 , float $ offset = 0.0 ) : Image { Utils :: debugLog ( 'newFromArray' , [ 'instance' => null , 'arguments' => [ $ array , $ scale , $ offset ] ] ) ; $ result = vips_image_new_from_array ( $ array , $ scale , $ offset ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'newFromArray' , [ 'result' => $ result ] ) ; return $ result ; }
|
Create a new Image from a php array .
|
50,511
|
public static function newFromMemory ( string $ data , int $ width , int $ height , int $ bands , string $ format ) : Image { Utils :: debugLog ( 'newFromMemory' , [ 'instance' => null , 'arguments' => [ $ data , $ width , $ height , $ bands , $ format ] ] ) ; $ result = vips_image_new_from_memory ( $ data , $ width , $ height , $ bands , $ format ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'newFromMemory' , [ 'result' => $ result ] ) ; return $ result ; }
|
Wraps an Image around an area of memory containing a C - style array .
|
50,512
|
public function newFromImage ( $ value ) : Image { Utils :: debugLog ( 'newFromImage' , [ 'instance' => $ this , 'arguments' => [ $ value ] ] ) ; $ pixel = self :: black ( 1 , 1 ) -> add ( $ value ) -> cast ( $ this -> format ) ; $ image = $ pixel -> embed ( 0 , 0 , $ this -> width , $ this -> height , [ 'extend' => Extend :: COPY ] ) ; $ image = $ image -> copy ( [ 'interpretation' => $ this -> interpretation , 'xres' => $ this -> xres , 'yres' => $ this -> yres , 'xoffset' => $ this -> xoffset , 'yoffset' => $ this -> yoffset ] ) ; Utils :: debugLog ( 'newFromImage' , [ 'result' => $ image ] ) ; return $ image ; }
|
Create a new image from a constant .
|
50,513
|
public function writeToFile ( string $ filename , array $ options = [ ] ) { Utils :: debugLog ( 'writeToFile' , [ 'instance' => $ this , 'arguments' => [ $ filename , $ options ] ] ) ; $ options = self :: unwrap ( $ options ) ; $ result = vips_image_write_to_file ( $ this -> image , $ filename , $ options ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } }
|
Write an image to a file .
|
50,514
|
public function writeToBuffer ( string $ suffix , array $ options = [ ] ) : string { Utils :: debugLog ( 'writeToBuffer' , [ 'instance' => $ this , 'arguments' => [ $ suffix , $ options ] ] ) ; $ options = self :: unwrap ( $ options ) ; $ result = vips_image_write_to_buffer ( $ this -> image , $ suffix , $ options ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'writeToBuffer' , [ 'result' => $ result ] ) ; return $ result ; }
|
Write an image to a formatted string .
|
50,515
|
public function writeToMemory ( ) : string { Utils :: debugLog ( 'writeToMemory' , [ 'instance' => $ this , 'arguments' => [ ] ] ) ; $ result = vips_image_write_to_memory ( $ this -> image ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } Utils :: debugLog ( 'writeToMemory' , [ 'result' => $ result ] ) ; return $ result ; }
|
Write an image to a large memory array .
|
50,516
|
public function copyMemory ( ) : Image { Utils :: debugLog ( 'copyMemory' , [ 'instance' => $ this , 'arguments' => [ ] ] ) ; $ result = vips_image_copy_memory ( $ this -> image ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } $ result = self :: wrapResult ( $ result ) ; Utils :: debugLog ( 'copyMemory' , [ 'result' => $ result ] ) ; return $ result ; }
|
Copy to memory .
|
50,517
|
public function get ( string $ name ) { $ result = vips_image_get ( $ this -> image , $ name ) ; self :: errorIsArray ( $ result ) ; return self :: wrapResult ( $ result ) ; }
|
Get any property from the underlying image .
|
50,518
|
public function set ( string $ name , $ value ) { $ result = vips_image_set ( $ this -> image , $ name , $ value ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } }
|
Set any property on the underlying image .
|
50,519
|
public function remove ( string $ name ) { $ result = vips_image_remove ( $ this -> image , $ name ) ; if ( $ result === - 1 ) { self :: errorVips ( ) ; } }
|
Remove a field from the underlying image .
|
50,520
|
public function hasAlpha ( ) : bool { return $ this -> bands === 2 || ( $ this -> bands === 4 && $ this -> interpretation !== Interpretation :: CMYK ) || $ this -> bands > 4 ; }
|
Does this image have an alpha channel?
|
50,521
|
public function offsetGet ( $ offset ) : Image { return $ this -> offsetExists ( $ offset ) ? $ this -> extract_band ( $ offset ) : null ; }
|
Get band from image .
|
50,522
|
public function offsetSet ( $ offset , $ value ) { if ( $ offset === null ) { $ offset = $ this -> bands ; } if ( ! is_int ( $ offset ) ) { throw new \ BadMethodCallException ( 'Image::offsetSet: offset is not integer or null' ) ; } $ n_left = min ( $ this -> bands , max ( 0 , $ offset ) ) ; $ n_right = min ( $ this -> bands , max ( 0 , $ this -> bands - 1 - $ offset ) ) ; $ offset = $ this -> bands - $ n_right ; if ( $ n_left === 0 && ! ( $ value instanceof Image ) ) { $ value = self :: imageize ( $ this , $ value ) ; } $ components = [ ] ; if ( $ n_left > 0 ) { $ components [ ] = $ this -> extract_band ( 0 , [ 'n' => $ n_left ] ) ; } $ components [ ] = $ value ; if ( $ n_right > 0 ) { $ components [ ] = $ this -> extract_band ( $ offset , [ 'n' => $ n_right ] ) ; } $ head = array_shift ( $ components ) ; $ this -> image = $ head -> bandjoin ( $ components ) -> image ; }
|
Set a band .
|
50,523
|
public function offsetUnset ( $ offset ) { if ( is_int ( $ offset ) && $ offset >= 0 && $ offset < $ this -> bands ) { if ( $ this -> bands === 1 ) { throw new \ BadMethodCallException ( 'Image::offsetUnset: cannot delete final band' ) ; } $ components = [ ] ; if ( $ offset > 0 ) { $ components [ ] = $ this -> extract_band ( 0 , [ 'n' => $ offset ] ) ; } if ( $ offset < $ this -> bands - 1 ) { $ components [ ] = $ this -> extract_band ( $ offset + 1 , [ 'n' => $ this -> bands - 1 - $ offset ] ) ; } $ head = array_shift ( $ components ) ; if ( empty ( $ components ) ) { $ this -> image = $ head -> image ; } else { $ this -> image = $ head -> bandjoin ( $ components ) -> image ; } } }
|
Remove a band from an image .
|
50,524
|
public function bandrank ( $ other , array $ options = [ ] ) : Image { if ( $ other instanceof Image ) { $ other = [ $ other ] ; } else { $ other = ( array ) $ other ; } return self :: call ( 'bandrank' , $ this , $ other , $ options ) ; }
|
For each band element sort the array of input images and pick the median . Use the index option to pick something else .
|
50,525
|
public function polar ( ) : Image { return self :: runCmplx ( function ( $ image ) { return $ image -> complex ( OperationComplex :: POLAR ) ; } , $ this ) ; }
|
Return an image converted to polar coordinates .
|
50,526
|
public function rect ( ) : Image { return self :: runCmplx ( function ( $ image ) { return $ image -> complex ( OperationComplex :: RECT ) ; } , $ this ) ; }
|
Return an image converted to rectangular coordinates .
|
50,527
|
public function create ( ClientInterface $ client , $ wsdl , array $ options = [ ] ) { if ( $ this -> isHttpUrl ( $ wsdl ) ) { $ httpBindingPromise = $ client -> requestAsync ( 'GET' , $ wsdl ) -> then ( function ( ResponseInterface $ response ) use ( $ options ) { $ wsdl = $ response -> getBody ( ) -> __toString ( ) ; $ interpreter = new Interpreter ( 'data://text/plain;base64,' . base64_encode ( $ wsdl ) , $ options ) ; return new HttpBinding ( $ interpreter , new RequestBuilder ) ; } ) ; } else { $ httpBindingPromise = new FulfilledPromise ( new HttpBinding ( new Interpreter ( $ wsdl , $ options ) , new RequestBuilder ) ) ; } return new SoapClient ( $ client , $ httpBindingPromise ) ; }
|
Create an instance of SoapClientInterface .
|
50,528
|
public static function minifyString ( $ string ) { $ string = str_replace ( PHP_EOL , ' ' , $ string ) ; $ string = preg_replace ( '/[\r\n]+/' , "\n" , $ string ) ; return preg_replace ( '/[ \t]+/' , ' ' , $ string ) ; }
|
Remove all whitesapces line - breaks and tabs from string for better regex recognition
|
50,529
|
public function writeLine ( $ s ) { $ message = $ this -> cleanMessage ( $ s ) ; if ( ! empty ( $ message ) ) { $ this -> bag [ ] = array ( self :: LINE , $ message ) ; } }
|
Add a simple message
|
50,530
|
public function writeInfo ( $ s ) { $ message = $ this -> cleanMessage ( $ s ) ; if ( ! empty ( $ message ) ) { $ this -> bag [ ] = array ( self :: INFO , $ message ) ; } }
|
Add an info message
|
50,531
|
public function writeComment ( $ s ) { $ message = $ this -> cleanMessage ( $ s ) ; if ( ! empty ( $ message ) ) { $ this -> bag [ ] = array ( self :: COMMENT , $ message ) ; } }
|
Add a comment message
|
50,532
|
public function writeQuestion ( $ s ) { $ message = $ this -> cleanMessage ( $ s ) ; if ( ! empty ( $ message ) ) { $ this -> bag [ ] = array ( self :: QUESTION , $ message ) ; } }
|
Add a question message
|
50,533
|
protected function logInFile ( $ txt = '' , $ logFile = '/tmp/llh.log' ) { if ( ! is_string ( $ txt ) ) { $ txt = print_r ( $ txt , true ) ; } $ txt = '==> ' . date ( 'Y/m/d H:i:s' ) . ' ==> ' . $ txt . "\n" ; if ( self :: $ logInFileFirst === true ) { file_put_contents ( $ logFile , $ txt ) ; self :: $ logInFileFirst = false ; } else { file_put_contents ( $ logFile , $ txt , FILE_APPEND ) ; } }
|
Log in a file for debug purpose only
|
50,534
|
public function getPath ( $ path ) { if ( ! is_array ( $ path ) ) { $ path = [ $ path ] ; } $ search_for = [ '%BASE' , '%STORAGE' , ] ; $ replace_by = [ base_path ( ) , storage_path ( ) , ] ; if ( function_exists ( 'app_path' ) ) { $ search_for [ ] = '%APP' ; $ replace_by [ ] = app_path ( ) ; } if ( function_exists ( 'public_path' ) ) { $ search_for [ ] = '%PUBLIC' ; $ replace_by [ ] = public_path ( ) ; } $ folders = str_replace ( $ search_for , $ replace_by , $ path ) ; foreach ( $ folders as $ k => $ v ) { $ folders [ $ k ] = realpath ( $ v ) ; } return $ folders ; }
|
Return an absolute path without predefined variables
|
50,535
|
public function getFilesWithExtension ( $ path , $ ext = 'php' ) { if ( is_dir ( $ path ) ) { return new RegexIterator ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST , RecursiveIteratorIterator :: CATCH_GET_CHILD ) , '/^.+\.' . $ ext . '$/i' , RecursiveRegexIterator :: GET_MATCH ) ; } else { return [ ] ; } }
|
Return an iterator of files with specific extension in the provided paths and subpaths
|
50,536
|
public function extractTranslationFromPhpFile ( $ path , $ trans_methods ) { $ result = [ ] ; $ string = Tools :: minifyString ( file_get_contents ( $ path ) ) ; foreach ( array_flatten ( $ trans_methods ) as $ method ) { preg_match_all ( $ method , $ string , $ matches ) ; foreach ( $ matches [ 1 ] as $ k => $ v ) { if ( strpos ( $ v , '$' ) !== false ) { unset ( $ matches [ 1 ] [ $ k ] ) ; } if ( strpos ( $ v , '::' ) !== false ) { unset ( $ matches [ 1 ] [ $ k ] ) ; } } $ result = array_merge ( $ result , array_flip ( $ matches [ 1 ] ) ) ; } return $ result ; }
|
Extract all translations from the provided file
|
50,537
|
public function extractTranslationsFromFolders ( $ folders , $ trans_methods , $ php_file_extension = 'php' ) { $ lemmas = [ ] ; foreach ( $ folders as $ path ) { foreach ( $ this -> getFilesWithExtension ( $ path , $ php_file_extension ) as $ php_file_path => $ dumb ) { $ lemma = [ ] ; foreach ( $ this -> extractTranslationFromPhpFile ( $ php_file_path , $ trans_methods ) as $ k => $ v ) { $ a = $ this -> evalString ( $ k ) ; if ( is_string ( $ a ) ) { $ real_value = $ a ; $ lemma [ $ real_value ] = $ php_file_path ; } else { $ this -> messageBag -> writeError ( "Unable to understand string $k" ) ; } } $ lemmas = array_merge ( $ lemmas , $ lemma ) ; } } return $ lemmas ; }
|
Extract all translations from the provided folders
|
50,538
|
public function deleteBackupFiles ( $ lang_folder_path , $ days = 0 , $ dryRun = false , $ ext = 'php' ) { if ( $ days < 0 ) { return false ; } try { $ dir_lang = $ this -> getLangPath ( $ lang_folder_path ) ; } catch ( Exception $ e ) { switch ( $ e -> getCode ( ) ) { case self :: NO_LANG_FOLDER_FOUND_IN_THESE_PATHS : $ this -> messageBag -> writeError ( "No lang folder found in these paths:" ) ; foreach ( $ e -> getParameter ( ) as $ path ) { $ this -> messageBag -> writeError ( "- " . $ path ) ; } break ; case self :: NO_LANG_FOLDER_FOUND_IN_YOUR_CUSTOM_PATH : $ this -> messageBag -> writeError ( 'No lang folder found in your custom path: "' . $ e -> getParameter ( ) . '"' ) ; break ; } return false ; } $ return = true ; foreach ( $ this -> getBackupFiles ( $ dir_lang ) as $ file ) { $ fileDate = $ this -> getBackupFileDate ( $ file , $ ext ) ; if ( is_null ( $ fileDate ) ) { $ this -> messageBag -> writeError ( 'Unable to detect date in file ' . $ file ) ; $ return = false ; continue ; } if ( $ this -> isDateOlderThanDays ( $ fileDate , $ days ) ) { if ( $ dryRun === true ) { $ deleted = true ; } else { $ deleted = unlink ( $ file ) ; } if ( $ deleted === true ) { $ this -> messageBag -> writeInfo ( 'Deleting file ' . $ file ) ; } else { $ this -> messageBag -> writeError ( 'Unable to delete file ' . $ file ) ; $ return = false ; } } else { $ this -> messageBag -> writeInfo ( 'Skip file ' . $ file . ' (not older than ' . $ days . 'day' . Tools :: getPlural ( $ days ) . ')' ) ; } } return $ return ; }
|
Delete backup files
|
50,539
|
private function evalString ( $ str ) { $ a = false ; if ( class_exists ( 'ParseError' ) ) { try { $ a = eval ( "return $str;" ) ; } catch ( ParseError $ e ) { } } else { $ a = @ eval ( "return $str;" ) ; } return $ a ; }
|
Eval a PHP string and catch PHP Parse Error syntax
|
50,540
|
public function findLemma ( $ lemma , $ folders , $ trans_methods , $ regex = false , $ shortOutput = false , $ ext = 'php' ) { $ files = [ ] ; foreach ( $ folders as $ path ) { foreach ( $ this -> getFilesWithExtension ( $ path , $ ext ) as $ php_file_path => $ dumb ) { foreach ( $ this -> extractTranslationFromPhpFile ( $ php_file_path , $ trans_methods ) as $ k => $ v ) { $ a = $ this -> evalString ( $ k ) ; if ( is_string ( $ a ) ) { $ real_value = $ a ; $ found = false ; if ( $ regex ) { try { $ r = preg_match ( $ lemma , $ real_value ) ; } catch ( \ Exception $ e ) { $ this -> messageBag -> writeError ( "The argument is not a valid regular expression:" . str_replace ( 'preg_match():' , '' , $ e -> getMessage ( ) ) ) ; return false ; } if ( $ r === 1 ) { $ found = true ; } else { if ( $ r === false ) { $ this -> messageBag -> writeError ( "The argument is not a valid regular expression" ) ; return false ; } } } else { if ( ! ( strpos ( $ real_value , $ lemma ) === false ) ) { $ found = true ; } } if ( $ found === true ) { if ( $ shortOutput === true ) { $ php_file_path = $ this -> getShortPath ( $ php_file_path ) ; } $ files [ ] = $ php_file_path ; break ; } } else { $ this -> messageBag -> writeError ( "Unable to understand string $k" ) ; } } } } return $ files ; }
|
Get the list of PHP code files where a lemma is defined
|
50,541
|
private function getBackupFileDate ( $ file , $ ext = 'php' ) { $ matches = [ ] ; if ( preg_match ( '@^(.*)([0-9]{8}_[0-9]{6})\\.' . $ ext . '$@' , $ file , $ matches ) === 1 ) { return \ DateTime :: createFromFormat ( self :: BACKUP_DATE_FORMAT , $ matches [ 2 ] ) ; } else { return null ; } }
|
Return the date of a backup file
|
50,542
|
public function check ( string $ listId , string $ email ) : bool { $ result = $ this -> status ( $ listId , $ email ) ; return in_array ( $ result , [ 'subscribed' , 'pending' ] ) ; }
|
Checks to see if an email address is subscribed to a list
|
50,543
|
public function subscribe ( string $ listId , string $ email , array $ mergeFields = [ ] , bool $ confirm = true ) { if ( $ this -> status ( $ listId , $ email ) == 'subscribed' ) { $ confirm = false ; } $ this -> api -> addUpdate ( $ listId , $ email , $ mergeFields , $ confirm ) ; }
|
Ensures that existing subscribers are not asked to reconfirm
|
50,544
|
public function api ( string $ method , string $ endpoint , array $ data = [ ] ) : array { $ endpoint = '/' . ltrim ( $ endpoint , '/' ) ; return $ this -> api -> call ( $ method , $ endpoint , $ data ) ; }
|
Make an API call directly
|
50,545
|
public function status ( string $ status ) : Member { if ( ! in_array ( $ status , [ 'subscribed' , 'unsubscribed' , 'cleaned' , 'pending' ] ) ) { throw new \ InvalidArgumentException ( 'Status must be subscribed, unsubscribed, cleaned or pending' ) ; } $ this -> parameters [ 'status' ] = $ status ; return $ this ; }
|
Note this doesn t affect status_if_new therefore it s not possible to add a new member as unsubscribed or cleaned
|
50,546
|
public function end ( ) { if ( $ this -> capturing === false ) { throw new InvalidTagException ( "Markdown capturing have not been started." ) ; } $ this -> capturing = false ; $ text = ob_get_clean ( ) ; return $ this -> parse ( $ text ) ; }
|
Stop capturing output parse the string from markdown to HTML and return it . Throws an exception if outpout capturing hasn t been started yet .
|
50,547
|
public function boot ( ) { $ this -> publishes ( [ __DIR__ . '/../config/markdown.php' => config_path ( 'markdown.php' ) , ] ) ; Blade :: directive ( 'markdown' , function ( $ markdown ) { if ( $ markdown ) { return "<?php echo app('Indal\Markdown\Parser')->parse($markdown); ?>" ; } return "<?php app('Indal\Markdown\Parser')->begin() ?>" ; } ) ; Blade :: directive ( 'endmarkdown' , function ( ) { return "<?php echo app('Indal\Markdown\Parser')->end() ?>" ; } ) ; }
|
Bootstrap the Markdown Blade directives and publish the config file .
|
50,548
|
public function register ( ) { $ this -> app -> singleton ( Parser :: class , function ( $ app ) { return new Parser ( new ParsedownDriver ( config ( 'markdown' ) ?? [ ] ) ) ; } ) ; $ this -> app -> bind ( 'markdown' , Parser :: class ) ; }
|
Bind the Markdown facade and the parser class to the container .
|
50,549
|
public function getResults ( $ query ) { $ searchResults = [ ] ; if ( $ query == '' ) { return $ searchResults ; } if ( $ this -> searchEngineId == '' ) { throw new \ Exception ( 'You must specify a searchEngineId' ) ; } $ client = new Client ( ) ; $ result = $ client -> get ( 'http://www.google.com/cse' , [ 'query' => [ 'cx' => $ this -> searchEngineId , 'client' => 'google-csbe' , 'num' => 20 , 'output' => 'xml_no_dtd' , 'q' => $ query , ] , ] ) ; if ( $ result -> getStatusCode ( ) != 200 ) { throw new Exception ( 'Resultcode was not ok: ' . $ result -> getStatusCode ( ) ) ; } $ xml = simplexml_load_string ( $ result -> getBody ( ) ) ; if ( $ xml -> ERROR ) { throw new Exception ( 'XML indicated service error: ' . $ xml -> ERROR ) ; } if ( $ xml -> RES -> R ) { $ i = 0 ; foreach ( $ xml -> RES -> R as $ item ) { $ searchResults [ $ i ] [ 'name' ] = ( string ) $ item -> T ; $ searchResults [ $ i ] [ 'url' ] = ( string ) $ item -> U ; $ searchResults [ $ i ] [ 'snippet' ] = ( string ) $ item -> S ; $ searchResults [ $ i ] [ 'image' ] = $ this -> getPageMapProperty ( $ item , 'cse_image' , 'src' ) ; $ searchResults [ $ i ] [ 'product' ] [ 'name' ] = $ this -> getPageMapProperty ( $ item , 'product' , 'name' ) ; $ searchResults [ $ i ] [ 'product' ] [ 'brand' ] = $ this -> getPageMapProperty ( $ item , 'product' , 'brand' ) ; $ searchResults [ $ i ] [ 'product' ] [ 'price' ] = $ this -> getPageMapProperty ( $ item , 'product' , 'price' ) ; $ searchResults [ $ i ] [ 'product' ] [ 'image' ] = $ this -> getPageMapProperty ( $ item , 'product' , 'image' ) ; $ searchResults [ $ i ] [ 'product' ] [ 'identifier' ] = $ this -> getPageMapProperty ( $ item , 'product' , 'identifier' ) ; $ searchResults [ $ i ] [ 'offer' ] [ 'price' ] = $ this -> getPageMapProperty ( $ item , 'offer' , 'price' ) ; $ searchResults [ $ i ] [ 'offer' ] [ 'pricecurrency' ] = $ this -> getPageMapProperty ( $ item , 'offer' , 'pricecurrency' ) ; ++ $ i ; } } return $ searchResults ; }
|
Get results from a Google Custom Search Engine .
|
50,550
|
public function getPageMapProperty ( $ item , $ type , $ attribute ) { $ propertyArray = $ item -> PageMap -> xpath ( 'DataObject[@type="' . $ type . '"]/Attribute[@name="' . $ attribute . '"]/@value' ) ; if ( ! count ( $ propertyArray ) ) { return '' ; } return ( string ) $ propertyArray [ 0 ] ; }
|
Get a the value Pagemap property with the given name of the given type of the given item .
|
50,551
|
public function get ( $ key , $ default_value = null ) { if ( strpos ( $ key , '.' ) !== false ) { $ setting = $ this -> getSubValue ( $ key ) ; } else { if ( $ this -> hasByKey ( $ key ) ) { $ setting = $ this -> getByKey ( $ key ) ; } else { $ setting = $ default_value ; } } $ this -> resetLang ( ) ; if ( is_null ( $ setting ) ) { $ setting = $ default_value ; } return $ setting ; }
|
Return setting value or default value by key .
|
50,552
|
public function set ( $ key , $ value ) { if ( strpos ( $ key , '.' ) !== false ) { $ this -> setSubValue ( $ key , $ value ) ; } else { $ this -> setByKey ( $ key , $ value ) ; } $ this -> resetLang ( ) ; }
|
Set the setting by key and value .
|
50,553
|
public function forget ( $ key ) { if ( strpos ( $ key , '.' ) !== false ) { $ this -> forgetSubKey ( $ key ) ; } else { $ this -> forgetByKey ( $ key ) ; } $ this -> resetLang ( ) ; }
|
Delete a setting .
|
50,554
|
public function lang ( $ language ) { if ( empty ( $ language ) ) { $ this -> resetLang ( ) ; } else { $ this -> lang = $ language ; } return $ this ; }
|
Set the language to work with other functions .
|
50,555
|
protected function resetLang ( $ force = false ) { if ( $ this -> autoResetLang || $ force ) { $ this -> lang = null ; } return $ this ; }
|
Reset the language so we could switch to other local .
|
50,556
|
private function getProvider ( ) { $ app = $ this -> app ; $ version = intval ( $ app :: VERSION ) ; switch ( $ version ) { case 4 : return new ServiceProviderLaravel4 ( $ app ) ; case 5 : return new ServiceProviderLaravel5 ( $ app ) ; default : throw new RuntimeException ( 'Your version of Laravel is not supported' ) ; } }
|
Return the service provider for the particular Laravel version .
|
50,557
|
protected function getSwaggerDocumentation ( ) : Swagger { if ( ! $ this -> cache instanceof Cache ) { return \ Swagger \ scan ( $ this -> scanDir , $ this -> scanOptions ) ; } return $ this -> cache -> getOrSet ( $ this -> cacheKey , function ( ) { return \ Swagger \ scan ( $ this -> scanDir , $ this -> scanOptions ) ; } , $ this -> cacheDuration ) ; }
|
Scan the filesystem for swagger annotations and build swagger - documentation .
|
50,558
|
public function validate ( $ configuration , $ required ) { $ missing = '' ; foreach ( $ configuration as $ key => $ value ) { if ( in_array ( $ key , $ required ) && ( empty ( $ value ) || $ value == null || $ value == '' ) ) { $ missing .= ' ' . $ key ; } } if ( $ missing ) { throw new MissingConfigurationException ( 'Missed Configuration:' . $ missing ) ; } }
|
Checks for any required configuration is missed .
|
50,559
|
private function generateUrl ( $ path , $ prepend = '' ) { if ( isset ( $ this -> configurations [ 'bypass' ] ) && $ this -> configurations [ 'bypass' ] ) { return Request :: root ( ) . '/' . $ path ; } if ( ! isset ( $ path ) ) { throw new EmptyPathException ( 'Path does not exist.' ) ; } $ clean_path = $ prepend . $ this -> helper -> cleanPath ( $ path ) ; return $ this -> provider -> urlGenerator ( $ clean_path ) ; }
|
check if package is surpassed or not then prepare the path before generating the url .
|
50,560
|
private function init ( ) { $ this -> configurations = $ this -> helper -> getConfigurations ( ) ; $ this -> provider = $ this -> provider_factory -> create ( $ this -> configurations ) ; }
|
Read the configuration file and pass it to the provider factory to return an object of the default provider specified in the config file .
|
50,561
|
public function upload ( $ assets ) { $ connected = $ this -> connect ( ) ; if ( ! $ connected ) { return false ; } $ this -> console -> writeln ( '<fg=yellow>Comparing local files and bucket...</fg=yellow>' ) ; $ assets = $ this -> getFilesAlreadyOnBucket ( $ assets ) ; if ( count ( $ assets ) > 0 ) { $ this -> console -> writeln ( '<fg=yellow>Upload in progress......</fg=yellow>' ) ; foreach ( $ assets as $ file ) { try { $ this -> console -> writeln ( '<fg=cyan>' . 'Uploading file path: ' . $ file -> getRealpath ( ) . '</fg=cyan>' ) ; $ command = $ this -> s3_client -> getCommand ( 'putObject' , [ 'Bucket' => $ this -> getBucket ( ) , 'Key' => str_replace ( '\\' , '/' , $ file -> getPathName ( ) ) , 'Body' => fopen ( $ file -> getRealPath ( ) , 'r' ) , 'ACL' => $ this -> acl , 'CacheControl' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'cache-control' ] , 'Metadata' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'metadata' ] , 'Expires' => $ this -> default [ 'providers' ] [ 'aws' ] [ 's3' ] [ 'expires' ] , ] ) ; $ this -> s3_client -> execute ( $ command ) ; } catch ( S3Exception $ e ) { $ this -> console -> writeln ( '<fg=red>' . $ e -> getMessage ( ) . '</fg=red>' ) ; return false ; } } $ this -> console -> writeln ( '<fg=green>Upload completed successfully.</fg=green>' ) ; } else { $ this -> console -> writeln ( '<fg=yellow>No new files to upload.</fg=yellow>' ) ; } return true ; }
|
Upload assets .
|
50,562
|
public function emptyBucket ( ) { $ connected = $ this -> connect ( ) ; if ( ! $ connected ) { return false ; } $ this -> console -> writeln ( '<fg=yellow>Emptying in progress...</fg=yellow>' ) ; try { $ contents = $ this -> s3_client -> listObjects ( [ 'Bucket' => $ this -> getBucket ( ) , 'Key' => '' , ] ) ; if ( ! $ contents [ 'Contents' ] ) { $ this -> console -> writeln ( '<fg=green>The bucket ' . $ this -> getBucket ( ) . ' is already empty.</fg=green>' ) ; return true ; } $ empty = BatchDelete :: fromListObjects ( $ this -> s3_client , [ 'Bucket' => $ this -> getBucket ( ) , 'Prefix' => null , ] ) ; $ empty -> delete ( ) ; } catch ( S3Exception $ e ) { $ this -> console -> writeln ( '<fg=red>' . $ e -> getMessage ( ) . '</fg=red>' ) ; return false ; } $ this -> console -> writeln ( '<fg=green>The bucket ' . $ this -> getBucket ( ) . ' is now empty.</fg=green>' ) ; return true ; }
|
Empty bucket .
|
50,563
|
public function init ( $ configurations = array ( ) ) { $ this -> parseAndFillConfiguration ( $ configurations ) ; $ this -> included_directories = $ this -> default_include [ 'directories' ] ; $ this -> included_extensions = $ this -> default_include [ 'extensions' ] ; $ this -> included_patterns = $ this -> default_include [ 'patterns' ] ; $ this -> excluded_directories = $ this -> default_exclude [ 'directories' ] ; $ this -> excluded_files = $ this -> default_exclude [ 'files' ] ; $ this -> excluded_extensions = $ this -> default_exclude [ 'extensions' ] ; $ this -> excluded_patterns = $ this -> default_exclude [ 'patterns' ] ; $ this -> exclude_hidden = $ this -> default_exclude [ 'hidden' ] ; return $ this ; }
|
build a Asset object that contains the assets related configurations .
|
50,564
|
private function parseAndFillConfiguration ( $ configurations ) { $ this -> default_include = isset ( $ configurations [ 'include' ] ) ? array_merge ( $ this -> default_include , $ configurations [ 'include' ] ) : $ this -> default_include ; $ this -> default_exclude = isset ( $ configurations [ 'exclude' ] ) ? array_merge ( $ this -> default_exclude , $ configurations [ 'exclude' ] ) : $ this -> default_exclude ; }
|
Check if the config file has any missed attribute and if any attribute is missed will be overridden by a default attribute defined in this class .
|
50,565
|
private function includeThis ( AssetInterface $ asset_holder ) { $ this -> in ( $ asset_holder -> getIncludedDirectories ( ) ) ; foreach ( $ asset_holder -> getIncludedExtensions ( ) as $ extension ) { $ this -> name ( '*' . $ extension ) ; } foreach ( $ asset_holder -> getIncludedPatterns ( ) as $ pattern ) { $ this -> name ( $ pattern ) ; } $ this -> exclude ( $ asset_holder -> getExcludedDirectories ( ) ) ; }
|
Add the included directories and files .
|
50,566
|
private function excludeThis ( AssetInterface $ asset_holder ) { $ this -> ignoreDotFiles ( $ asset_holder -> getExcludeHidden ( ) ) ; foreach ( $ asset_holder -> getExcludedFiles ( ) as $ name ) { $ this -> notName ( $ name ) ; } $ excluded_extensions = $ asset_holder -> getExcludedExtensions ( ) ; if ( ! empty ( $ excluded_extensions ) ) { foreach ( $ asset_holder -> getExcludedExtensions ( ) as $ extension ) { $ this -> notName ( '*' . $ extension ) ; } } foreach ( $ asset_holder -> getExcludedPatterns ( ) as $ pattern ) { $ this -> notName ( $ pattern ) ; } }
|
exclude the ignored directories and files .
|
50,567
|
public function create ( $ configurations = array ( ) ) { $ provider = isset ( $ configurations [ 'default' ] ) ? $ configurations [ 'default' ] : null ; if ( ! $ provider ) { throw new MissingConfigurationException ( 'Missing Configurations: Default Provider' ) ; } $ driver_class = self :: DRIVERS_NAMESPACE . ucwords ( $ provider ) . 'Provider' ; if ( ! class_exists ( $ driver_class ) ) { throw new UnsupportedProviderException ( "CDN provider ($provider) is not supported" ) ; } $ driver_object = App :: make ( $ driver_class ) -> init ( $ configurations ) ; return $ driver_object ; }
|
Create and return an instance of the corresponding Provider concrete according to the configuration .
|
50,568
|
public function open ( array $ options = [ ] ) { $ options [ 'role' ] = 'form' ; if ( ! array_key_exists ( 'class' , $ options ) ) { $ options [ 'class' ] = $ this -> getType ( ) ; } if ( array_key_exists ( 'left_column_class' , $ options ) ) { $ this -> setLeftColumnClass ( $ options [ 'left_column_class' ] ) ; } if ( array_key_exists ( 'left_column_offset_class' , $ options ) ) { $ this -> setLeftColumnOffsetClass ( $ options [ 'left_column_offset_class' ] ) ; } if ( array_key_exists ( 'right_column_class' , $ options ) ) { $ this -> setRightColumnClass ( $ options [ 'right_column_class' ] ) ; } array_forget ( $ options , [ 'left_column_class' , 'left_column_offset_class' , 'right_column_class' ] ) ; if ( array_key_exists ( 'model' , $ options ) ) { return $ this -> model ( $ options ) ; } if ( array_key_exists ( 'error_bag' , $ options ) ) { $ this -> setErrorBag ( $ options [ 'error_bag' ] ) ; } return $ this -> form -> open ( $ options ) ; }
|
Open a form while passing a model and the routes for storing or updating the model . This will set the correct route along with the correct method .
|
50,569
|
public function close ( ) { $ this -> type = null ; $ this -> leftColumnClass = $ this -> rightColumnClass = null ; return $ this -> form -> close ( ) ; }
|
Reset and close the form .
|
50,570
|
protected function model ( $ options ) { $ model = $ options [ 'model' ] ; if ( isset ( $ options [ 'url' ] ) ) { array_forget ( $ options , [ 'model' , 'update' , 'store' ] ) ; $ options [ 'method' ] = isset ( $ options [ 'method' ] ) ? $ options [ 'method' ] : 'GET' ; return $ this -> form -> model ( $ model , $ options ) ; } if ( ! isset ( $ options [ 'store' ] ) && ! isset ( $ options [ 'update' ] ) ) { array_forget ( $ options , 'model' ) ; return $ this -> form -> model ( $ model , $ options ) ; } if ( ! is_null ( $ options [ 'model' ] ) && $ options [ 'model' ] -> exists ) { $ name = is_array ( $ options [ 'update' ] ) ? array_first ( $ options [ 'update' ] ) : $ options [ 'update' ] ; $ route = Str :: contains ( $ name , '@' ) ? 'action' : 'route' ; $ options [ $ route ] = array_merge ( ( array ) $ options [ 'update' ] , [ $ options [ 'model' ] -> getRouteKey ( ) ] ) ; $ options [ 'method' ] = 'PUT' ; } else { $ name = is_array ( $ options [ 'store' ] ) ? array_first ( $ options [ 'store' ] ) : $ options [ 'store' ] ; $ route = Str :: contains ( $ name , '@' ) ? 'action' : 'route' ; $ options [ $ route ] = $ options [ 'store' ] ; $ options [ 'method' ] = 'POST' ; } array_forget ( $ options , [ 'model' , 'update' , 'store' ] ) ; return $ this -> form -> model ( $ model , $ options ) ; }
|
Open a form configured for model binding .
|
50,571
|
public function staticField ( $ name , $ label = null , $ value = null , array $ options = [ ] ) { $ options = array_merge ( [ 'class' => 'form-control-static' ] , $ options ) ; if ( is_array ( $ value ) and isset ( $ value [ 'html' ] ) ) { $ value = $ value [ 'html' ] ; } else { $ value = e ( $ value ) ; } $ label = $ this -> getLabelTitle ( $ label , $ name ) ; $ inputElement = '<p' . $ this -> html -> attributes ( $ options ) . '>' . $ value . '</p>' ; $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => $ this -> getRightColumnClass ( ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ options ) . '</div>' ; return $ this -> getFormGroup ( $ name , $ label , $ wrapperElement ) ; }
|
Create a Bootstrap static field .
|
50,572
|
public function checkbox ( $ name , $ label = null , $ value = 1 , $ checked = null , array $ options = [ ] ) { $ inputElement = $ this -> checkboxElement ( $ name , $ label , $ value , $ checked , false , $ options ) ; $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => implode ( ' ' , [ $ this -> getLeftColumnOffsetClass ( ) , $ this -> getRightColumnClass ( ) ] ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ options ) . '</div>' ; return $ this -> getFormGroup ( $ name , null , $ wrapperElement ) ; }
|
Create a Bootstrap checkbox input .
|
50,573
|
public function checkboxElement ( $ name , $ label = null , $ value = 1 , $ checked = null , $ inline = false , array $ options = [ ] ) { $ label = $ label === false ? null : $ this -> getLabelTitle ( $ label , $ name ) ; $ labelOptions = $ inline ? [ 'class' => 'checkbox-inline' ] : [ ] ; $ inputElement = $ this -> form -> checkbox ( $ name , $ value , $ checked , $ options ) ; $ labelElement = '<label ' . $ this -> html -> attributes ( $ labelOptions ) . '>' . $ inputElement . $ label . '</label>' ; return $ inline ? $ labelElement : '<div class="checkbox">' . $ labelElement . '</div>' ; }
|
Create a single Bootstrap checkbox element .
|
50,574
|
public function checkboxes ( $ name , $ label = null , $ choices = [ ] , $ checkedValues = [ ] , $ inline = false , array $ options = [ ] ) { $ elements = '' ; foreach ( $ choices as $ value => $ choiceLabel ) { $ checked = in_array ( $ value , ( array ) $ checkedValues ) ; $ elements .= $ this -> checkboxElement ( $ name , $ choiceLabel , $ value , $ checked , $ inline , $ options ) ; } $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => $ this -> getRightColumnClass ( ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ elements . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ options ) . '</div>' ; return $ this -> getFormGroup ( $ name , $ label , $ wrapperElement ) ; }
|
Create a collection of Bootstrap checkboxes .
|
50,575
|
public function radio ( $ name , $ label = null , $ value = null , $ checked = null , array $ options = [ ] ) { $ inputElement = $ this -> radioElement ( $ name , $ label , $ value , $ checked , false , $ options ) ; $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => implode ( ' ' , [ $ this -> getLeftColumnOffsetClass ( ) , $ this -> getRightColumnClass ( ) ] ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . '</div>' ; return $ this -> getFormGroup ( null , $ label , $ wrapperElement ) ; }
|
Create a Bootstrap radio input .
|
50,576
|
public function radioElement ( $ name , $ label = null , $ value = null , $ checked = null , $ inline = false , array $ options = [ ] ) { $ label = $ label === false ? null : $ this -> getLabelTitle ( $ label , $ name ) ; $ value = is_null ( $ value ) ? $ label : $ value ; $ labelOptions = $ inline ? [ 'class' => 'radio-inline' ] : [ ] ; $ inputElement = $ this -> form -> radio ( $ name , $ value , $ checked , $ options ) ; $ labelElement = '<label ' . $ this -> html -> attributes ( $ labelOptions ) . '>' . $ inputElement . $ label . '</label>' ; return $ inline ? $ labelElement : '<div class="radio">' . $ labelElement . '</div>' ; }
|
Create a single Bootstrap radio input .
|
50,577
|
public function radios ( $ name , $ label = null , $ choices = [ ] , $ checkedValue = null , $ inline = false , array $ options = [ ] ) { $ elements = '' ; foreach ( $ choices as $ value => $ choiceLabel ) { $ checked = $ value === $ checkedValue ; $ elements .= $ this -> radioElement ( $ name , $ choiceLabel , $ value , $ checked , $ inline , $ options ) ; } $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => $ this -> getRightColumnClass ( ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ elements . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ options ) . '</div>' ; return $ this -> getFormGroup ( $ name , $ label , $ wrapperElement ) ; }
|
Create a collection of Bootstrap radio inputs .
|
50,578
|
public function label ( $ name , $ value = null , array $ options = [ ] ) { $ options = $ this -> getLabelOptions ( $ options ) ; $ escapeHtml = false ; if ( is_array ( $ value ) and isset ( $ value [ 'html' ] ) ) { $ value = $ value [ 'html' ] ; } elseif ( $ value instanceof HtmlString ) { $ value = $ value -> toHtml ( ) ; } else { $ escapeHtml = true ; } return $ this -> form -> label ( $ name , $ value , $ options , $ escapeHtml ) ; }
|
Create a Bootstrap label .
|
50,579
|
public function button ( $ value = null , array $ options = [ ] ) { $ options = array_merge ( [ 'class' => 'btn btn-primary' ] , $ options ) ; $ inputElement = $ this -> form -> button ( $ value , $ options ) ; $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => implode ( ' ' , [ $ this -> getLeftColumnOffsetClass ( ) , $ this -> getRightColumnClass ( ) ] ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . '</div>' ; return $ this -> getFormGroup ( null , null , $ wrapperElement ) ; }
|
Create a Boostrap button .
|
50,580
|
public function file ( $ name , $ label = null , array $ options = [ ] ) { $ label = $ this -> getLabelTitle ( $ label , $ name ) ; $ options = array_merge ( [ 'class' => 'filestyle' , 'data-buttonBefore' => 'true' ] , $ options ) ; $ options = $ this -> getFieldOptions ( $ options , $ name ) ; $ inputElement = $ this -> form -> input ( 'file' , $ name , null , $ options ) ; $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => $ this -> getRightColumnClass ( ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ options ) . '</div>' ; return $ this -> getFormGroup ( $ name , $ label , $ wrapperElement ) ; }
|
Create a Boostrap file upload button .
|
50,581
|
public function input ( $ type , $ name , $ label = null , $ value = null , array $ options = [ ] ) { $ label = $ this -> getLabelTitle ( $ label , $ name ) ; $ optionsField = $ this -> getFieldOptions ( array_except ( $ options , [ 'suffix' , 'prefix' ] ) , $ name ) ; $ inputElement = '' ; if ( isset ( $ options [ 'prefix' ] ) ) { $ inputElement = $ options [ 'prefix' ] ; } $ inputElement .= $ type === 'password' ? $ this -> form -> password ( $ name , $ optionsField ) : $ this -> form -> { $ type } ( $ name , $ value , $ optionsField ) ; if ( isset ( $ options [ 'suffix' ] ) ) { $ inputElement .= $ options [ 'suffix' ] ; } if ( isset ( $ options [ 'prefix' ] ) || isset ( $ options [ 'suffix' ] ) ) { $ inputElement = '<div class="input-group">' . $ inputElement . '</div>' ; } $ wrapperOptions = $ this -> isHorizontal ( ) ? [ 'class' => $ this -> getRightColumnClass ( ) ] : [ ] ; $ wrapperElement = '<div' . $ this -> html -> attributes ( $ wrapperOptions ) . '>' . $ inputElement . $ this -> getFieldError ( $ name ) . $ this -> getHelpText ( $ name , $ optionsField ) . '</div>' ; return $ this -> getFormGroup ( $ name , $ label , $ wrapperElement ) ; }
|
Create the input group for an element with the correct classes for errors .
|
50,582
|
public function addonButton ( $ label , $ options = [ ] ) { $ attributes = array_merge ( [ 'class' => 'btn' , 'type' => 'button' ] , $ options ) ; if ( isset ( $ options [ 'class' ] ) ) { $ attributes [ 'class' ] .= ' btn' ; } return '<div class="input-group-btn"><button ' . $ this -> html -> attributes ( $ attributes ) . '>' . $ label . '</button></div>' ; }
|
Create an addon button element .
|
50,583
|
public function addonIcon ( $ icon , $ options = [ ] ) { $ prefix = array_get ( $ options , 'prefix' , $ this -> getIconPrefix ( ) ) ; return '<div class="input-group-addon"><span ' . $ this -> html -> attributes ( $ options ) . '><i class="' . $ prefix . $ icon . '"></i></span></div>' ; }
|
Create an addon icon element .
|
50,584
|
public function hidden ( $ name , $ value = null , $ options = [ ] ) { return $ this -> form -> hidden ( $ name , $ value , $ options ) ; }
|
Create a hidden field .
|
50,585
|
protected function getLabelTitle ( $ label , $ name ) { if ( $ label === false ) { return null ; } if ( is_null ( $ label ) && Lang :: has ( "forms.{$name}" ) ) { return Lang :: get ( "forms.{$name}" ) ; } return $ label ? : str_replace ( '_' , ' ' , Str :: title ( $ name ) ) ; }
|
Get the label title for a form field first by using the provided one or titleizing the field name .
|
50,586
|
protected function getFormGroupWithoutLabel ( $ name , $ element ) { $ options = $ this -> getFormGroupOptions ( $ name ) ; return $ this -> toHtmlString ( '<div' . $ this -> html -> attributes ( $ options ) . '>' . $ element . '</div>' ) ; }
|
Get a form group comprised of a form element and errors .
|
50,587
|
protected function getFormGroupWithLabel ( $ name , $ value , $ element ) { $ options = $ this -> getFormGroupOptions ( $ name ) ; return $ this -> toHtmlString ( '<div' . $ this -> html -> attributes ( $ options ) . '>' . $ this -> label ( $ name , $ value ) . $ element . '</div>' ) ; }
|
Get a form group comprised of a label form element and errors .
|
50,588
|
public function getFormGroup ( $ name = null , $ label = null , $ wrapperElement ) { if ( is_null ( $ label ) ) { return $ this -> getFormGroupWithoutLabel ( $ name , $ wrapperElement ) ; } return $ this -> getFormGroupWithLabel ( $ name , $ label , $ wrapperElement ) ; }
|
Get a form group with or without a label .
|
50,589
|
protected function getFormGroupOptions ( $ name = null , array $ options = [ ] ) { $ class = 'form-group' ; if ( $ name ) { $ class .= ' ' . $ this -> getFieldErrorClass ( $ name ) ; } return array_merge ( [ 'class' => $ class ] , $ options ) ; }
|
Merge the options provided for a form group with the default options required for Bootstrap styling .
|
50,590
|
protected function getFieldOptions ( array $ options = [ ] , $ name = null ) { $ options [ 'class' ] = trim ( 'form-control ' . $ this -> getFieldOptionsClass ( $ options ) ) ; if ( $ name && ! array_key_exists ( 'id' , $ options ) ) { $ options [ 'id' ] = $ name ; } return $ options ; }
|
Merge the options provided for a field with the default options required for Bootstrap styling .
|
50,591
|
public function getFollowers ( ) { $ followers = array ( ) ; $ sections = $ this -> getSections ( ) ; if ( $ sections != null ) { foreach ( $ sections as $ section ) { $ users = $ section -> getUsers ( ) ; if ( $ users != null ) { foreach ( $ users as $ user ) { $ followers [ ] = $ user ; } } } } return $ followers ; }
|
Get Followers by iterating over all Sections
|
50,592
|
public function setProxy ( $ proxy , $ username = null , $ password = null ) { $ this -> proxy = $ proxy ; if ( $ username != null && $ password != null ) { $ this -> proxyCredentials = $ username . ":" . $ password ; } }
|
Set the HTTP Proxy to be used for Instagram API Requests
|
50,593
|
public function setupAsNewDevice ( ) { $ guidId = Uuid :: uuid4 ( ) -> toString ( ) ; $ phoneId = Uuid :: uuid4 ( ) -> toString ( ) ; $ rankToken = Uuid :: uuid4 ( ) -> toString ( ) ; $ googleAdId = Uuid :: uuid4 ( ) -> toString ( ) ; $ this -> setGuid ( $ guidId ) ; $ this -> setUuid ( $ guidId ) ; $ this -> setPhoneId ( $ phoneId ) ; $ this -> setRankToken ( $ rankToken ) ; $ this -> setGoogleAdId ( $ googleAdId ) ; }
|
Setup this instance with a fresh GUID UUID and Phone ID .
|
50,594
|
public function searchByQuery ( $ query ) { if ( $ query != null ) { $ this -> addParam ( "query" , $ query ) ; $ this -> addParam ( "rank_token" , $ this -> instagram -> getUserRankToken ( ) ) ; } }
|
Search Places by Query
|
50,595
|
public function searchByLocation ( $ lat , $ long ) { if ( $ lat != null && $ long != null ) { $ this -> addParam ( "lat" , $ lat ) ; $ this -> addParam ( "lng" , $ long ) ; } }
|
Search Places by Location
|
50,596
|
protected function cleanResponse ( ) { if ( ! $ this -> options [ 'strip_bad_chars' ] ) { return ; } $ count = 0 ; $ this -> __last_response = preg_replace ( '/(?!�?(9|A|D))(&#x[0-1]?[0-9A-F];)/' , ' ' , $ this -> __last_response , - 1 , $ count ) ; if ( $ this -> options [ 'warn_on_bad_chars' ] && $ count > 0 ) { trigger_error ( 'Invalid characters were stripped from the XML SOAP response.' , E_USER_WARNING ) ; } }
|
Cleans the response body by stripping bad characters if instructed to .
|
50,597
|
protected function curlOptions ( $ action , $ request ) { $ options = $ this -> options [ 'curlopts' ] + array ( CURLOPT_SSL_VERIFYPEER => true , CURLOPT_RETURNTRANSFER => true , CURLOPT_HTTPHEADER => $ this -> buildHeaders ( $ action ) , CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 , CURLOPT_HTTPAUTH => CURLAUTH_BASIC | CURLAUTH_NTLM , CURLOPT_USERPWD => $ this -> options [ 'user' ] . ':' . $ this -> options [ 'password' ] , ) ; $ options [ CURLOPT_HEADER ] = true ; $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = $ request ; return $ options ; }
|
Builds an array of curl options for the request
|
50,598
|
public function parseResponse ( $ response ) { $ info = curl_getinfo ( $ this -> ch ) ; $ this -> __last_response_headers = substr ( $ response , 0 , $ info [ 'header_size' ] ) ; $ this -> __last_response = substr ( $ response , $ info [ 'header_size' ] ) ; }
|
Pareses the response from a successful request .
|
50,599
|
protected function getTerminalWidth ( ) { if ( isset ( $ _SERVER [ 'COLUMNS' ] ) ) return ( int ) $ _SERVER [ 'COLUMNS' ] ; $ process = proc_open ( 'tput cols' , array ( 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) , $ pipes ) ; $ width = ( int ) stream_get_contents ( $ pipes [ 1 ] ) ; proc_close ( $ process ) ; return $ width ; }
|
Tries to figure out the width of the terminal
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.