idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
14,700
public function mapDeviceName ( ? string $ deviceName ) : ? string { if ( null === $ deviceName ) { return null ; } $ brandName = null ; switch ( mb_strtolower ( $ deviceName ) ) { case '' : case 'unknown' : case 'other' : case 'various' : case 'android 1.6' : case 'android 2.0' : case 'android 2.1' : case 'android 2.2...
maps the brand name of a device from the device name
14,701
public static function mostSimilar ( $ needle , $ wordPool ) { $ distancePool = [ ] ; $ needle = mb_strtolower ( $ needle ) ; foreach ( $ wordPool as $ word ) { $ distance = similar_text ( $ needle , mb_strtolower ( $ word ) ) ; if ( ! isset ( $ distancePool [ $ distance ] ) ) { $ distancePool [ $ distance ] = [ ] ; } ...
Finds a string in a pool of strings which is most similar to the given needle .
14,702
public static function translit ( $ string , $ substChar = '?' , $ trim = true , $ removeDuplicates = true ) { if ( ! is_string ( $ string ) ) { if ( is_scalar ( $ string ) ) { $ string = ( string ) $ string ; } else { $ type = gettype ( $ string ) ; throw new \ InvalidArgumentException ( __METHOD__ . "() expects param...
Transliterates an UTF8 string to printable ASCII characters .
14,703
public static function slugify ( $ string ) { if ( ! is_string ( $ string ) ) { $ type = gettype ( $ string ) ; throw new \ InvalidArgumentException ( "Given argument is a $type, expected string." ) ; } if ( empty ( $ string ) ) { throw new \ InvalidArgumentException ( "Cannot slugify an empty string." ) ; } $ string =...
Returns a slugified version of the string .
14,704
public function readJson ( $ check_header = true , $ override = false ) { if ( ! is_null ( $ this -> from_json ) && ! $ override ) { return $ this -> from_json ; } $ this -> from_json = false ; if ( $ check_header ) { $ type = $ this -> server -> getIs ( "CONTENT_TYPE" ) ? $ this -> server -> get ( "CONTENT_TYPE" ) : $...
Load json content from body data
14,705
public function ip ( ) { if ( is_null ( $ this -> ip_address ) ) { $ remote = isset ( $ this -> server [ "REMOTE_ADDR" ] ) ; if ( $ remote && isset ( $ this -> server [ "HTTP_CLIENT_IP" ] ) ) { $ this -> ip_address = $ this -> server [ "HTTP_CLIENT_IP" ] ; } else if ( $ remote ) { $ this -> ip_address = $ _SERVER [ "RE...
Gets the request IP address
14,706
public function referer ( $ valid_host = false , $ valid_string = '' ) { $ ref = $ this -> server -> getOr ( 'HTTP_REFERER' , '' ) ; if ( $ ref ) { if ( $ valid_host ) { $ host = BASE_PROTOCOL . "://" . APP_HOST ; $ len = strlen ( $ host ) ; if ( substr ( $ ref , 0 , $ len ) !== $ host ) { return '' ; } if ( strlen ( $...
Gets the request referer
14,707
public function getRelation ( $ type ) { if ( ! isset ( $ this -> relations [ $ type ] ) ) { throw new RelationNotFoundException ( $ type ) ; } return $ this -> relations [ $ type ] ; }
Get a relation link .
14,708
public function hydrate ( Model $ model , \ Tapestry \ Entities \ File $ file , \ TapestryCloud \ Database \ Entities \ ContentType $ contentType = null ) { $ model -> setUid ( $ file -> getUid ( ) ) ; $ model -> setLastModified ( $ file -> getLastModified ( ) ) ; $ model -> setFilename ( $ file -> getFilename ( ) ) ; ...
File Hydration .
14,709
protected function copyMigrations ( ) : void { $ this -> stdout ( "\nCopy the migration files in a temp directory\n" , Console :: FG_YELLOW ) ; FileHelper :: removeDirectory ( $ this -> migrationPath ) ; FileHelper :: createDirectory ( $ this -> migrationPath ) ; if ( ! is_dir ( $ this -> migrationPath ) ) { $ this -> ...
Copy migrations to temp directory .
14,710
protected function clearNamespace ( string $ class ) { if ( file_exists ( $ class ) ) { $ content = file_get_contents ( $ class ) ; $ content = preg_replace ( '#^namespace\s+(.+?);$#sm' , ' ' , $ content ) ; file_put_contents ( $ class , $ content ) ; } }
Clear namespace to php class file .
14,711
public function update ( $ new_instance , $ old_instance ) { $ menus = get_terms ( 'nav_menu' , array ( 'hide_empty' => true ) ) ; $ selected_menu = isset ( $ _REQUEST [ $ this -> get_menu_field_id ( ) ] ) ? sanitize_text_field ( wp_unslash ( $ _REQUEST [ $ this -> get_menu_field_id ( ) ] ) ) : false ; foreach ( $ menu...
Save the menu slug
14,712
public function get_sub_menu_items ( $ menu_items , $ parent_id ) { $ items = [ ] ; foreach ( $ menu_items as $ menu_item ) { if ( intval ( $ parent_id ) === intval ( $ menu_item -> menu_item_parent ) ) { $ items [ ] = [ 'title' => $ menu_item -> title , 'link' => str_replace ( site_url ( ) , '' , $ menu_item -> url ) ...
Recursively get all sub menu items .
14,713
protected function buildClass ( $ name ) { $ className = $ this -> formatClassName ( $ name ) ; if ( ! class_exists ( $ className ) ) { throw new RuntimeException ( 'Enum ' . $ className . ' is not exists' ) ; } $ enum = new $ className ( ) ; if ( ! $ enum instanceof Enumable ) { throw new RuntimeException ( 'Enum ' . ...
Build a Enum class .
14,714
public function Initialize ( ) { $ this -> Head = new HeadModule ( $ this ) ; $ this -> AddCssFile ( 'setup.css' ) ; $ this -> AddJsFile ( 'jquery.js' ) ; SaveToConfig ( 'Garden.Errors.MasterView' , 'deverror.master.php' , array ( 'Save' => FALSE ) ) ; }
Add CSS & module set error master view . Automatically run on every use .
14,715
public function Index ( ) { $ this -> AddJsFile ( 'setup.js' ) ; $ this -> ApplicationFolder = 'dashboard' ; $ this -> MasterView = 'setup' ; $ Installed = C ( 'Garden.Installed' ) ; if ( $ Installed ) { $ this -> View = "AlreadyInstalled" ; $ this -> Render ( ) ; return ; } if ( ! $ this -> _CheckPrerequisites ( ) ) {...
The summary of all settings available .
14,716
private function _CheckPrerequisites ( ) { if ( version_compare ( phpversion ( ) , ENVIRONMENT_PHP_VERSION ) < 0 ) $ this -> Form -> AddError ( sprintf ( T ( 'You are running PHP version %1$s. Vanilla requires PHP %2$s or greater. You must upgrade PHP before you can continue.' ) , phpversion ( ) , ENVIRONMENT_PHP_VERSI...
Check minimum requirements for Garden .
14,717
public static function flatten ( array $ array , $ separator = '.' , $ prefix = '' ) { $ result = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ newPrefix = empty ( $ prefix ) ? $ key : "$prefix.$key" ; $ result = array_merge ( $ result , self :: flatten ( $ value , $ separator , $ newP...
Flattens a deep array to a single dimension .
14,718
private static function processReindexPath ( $ path ) { if ( is_string ( $ path ) || is_integer ( $ path ) ) { $ path = array ( array ( $ path ) ) ; } elseif ( is_array ( $ path ) && ! empty ( $ path ) && ! is_array ( $ path [ 0 ] ) ) { foreach ( $ path as $ key ) { if ( ! ( is_string ( $ key ) || is_integer ( $ key ) ...
Processes and validates the given index path .
14,719
public function setExpectedAndReceived ( $ expected , $ received ) { $ this -> expected = is_string ( $ expected ) ? $ expected : get_class ( $ expected ) ; $ this -> received = TypeHound :: fetch ( $ received ) ; $ this -> message = vsprintf ( 'An instance of a %s was expected but got %s' , [ $ this -> expected , $ th...
Set the expected class and the received value .
14,720
private function tryLogMessage ( $ message ) { $ messageId = null ; if ( $ message instanceof RemoteMessage ) $ messageId = $ message -> header ( ) -> uuid ( ) ; elseif ( $ message instanceof ProcessingMessage ) $ messageId = $ message -> uuid ( ) ; if ( ! $ messageId ) return ; $ entry = $ this -> messageLogger -> get...
Message is only logged if it is has a valid type and is not logged already otherwise it is ignored .
14,721
public function addChild ( RecursiveLeafInterface $ leaf ) { $ leaf -> setDepth ( $ this -> depth + 1 ) ; $ this -> children [ ] = $ leaf ; }
Adds the child leaf .
14,722
public function setUniqueKey ( $ uniqueKey ) { if ( ! is_null ( $ this -> uniqueKey ) ) { throw new RuntimeException ( 'The unique key was already set.' ) ; } if ( ! is_int ( $ uniqueKey ) && ! is_string ( $ uniqueKey ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid type of specified unique key; must be an...
Sets the unique key of leaf .
14,723
public function setDepth ( $ depth ) { if ( ! is_null ( $ this -> depth ) ) { throw new RuntimeException ( 'The depth was already set.' ) ; } if ( ! is_int ( $ depth ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid type of specified depth; must be an integer, ' . '"%s" received.' , gettype ( $ depth ) ) ) ...
Sets the depth of leaf in the tree .
14,724
protected static function getEndPointFromRequest ( Request $ request , array $ config ) { $ class = self :: getClassFromRequest ( $ request ) ; if ( class_exists ( $ class ) && $ request -> match ( $ class :: getPatterns ( ) ) ) { return [ 'endPoint' => $ class :: getEndpoint ( ) , 'params' => $ class :: getParams ( $ ...
Returns the oembed link from the request
14,725
public static function generateHash ( $ password ) { $ cost = 10 ; $ salt = strtr ( base64_encode ( mcrypt_create_iv ( 16 , MCRYPT_DEV_URANDOM ) ) , '+' , '.' ) ; $ salt = sprintf ( "$2a$%02d$" , $ cost ) . $ salt ; $ hash = crypt ( $ password , $ salt ) ; return $ hash ; }
generates the hash
14,726
private function AddOptionsField ( ) { $ name = 'Options' ; $ field = new Textarea ( $ name , $ this -> OptionsString ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> SetTransAttribute ( $ name , 'placeholder' ) ; $ this -> SetRequired ( $ name ) ; }
Adds the options textarea
14,727
protected function SaveElement ( ) { $ this -> radio -> SetLabel ( $ this -> Value ( 'Label' ) ) ; $ this -> radio -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> radio -> SetValue ( $ this -> Value ( 'Value' ) ) ; $ this -> radio -> SetRequired ( ( bool ) $ this -> Value ( 'Required' ) ) ; $ this -> radio -> Set...
Stores the radio content s base properties
14,728
private function FetchOptions ( ) { $ strOptions = $ this -> Value ( 'Options' ) ; $ lines = Str :: SplitLines ( $ strOptions ) ; $ result = array ( ) ; foreach ( $ lines as $ line ) { $ dpPos = strpos ( $ line , ':' ) ; if ( $ dpPos !== false ) { $ value = trim ( substr ( $ line , 0 , $ dpPos ) ) ; $ text = trim ( sub...
Fetches submitted options as array
14,729
public function group ( $ fields , $ rollup = false ) { $ this -> parts [ 'group' ] [ 'fields' ] = $ fields ; $ this -> parts [ 'group' ] [ 'rollup' ] = $ rollup ; return $ this ; }
Sets the group paramater for the query
14,730
protected function parseCols ( ) { if ( ! isset ( $ this -> parts [ 'cols' ] ) || ! is_array ( $ this -> parts [ 'cols' ] ) || count ( $ this -> parts [ 'cols' ] ) < 1 ) { return '*' ; } else { $ selectParts = [ ] ; foreach ( $ this -> parts [ 'cols' ] as $ itemSelect ) { if ( is_array ( $ itemSelect ) ) { $ field = is...
Parses SELECT entries
14,731
private function parseFrom ( ) { if ( ! empty ( $ this -> parts [ 'from' ] ) ) { $ parts = [ ] ; foreach ( $ this -> parts [ 'from' ] as $ key => $ item ) { if ( is_array ( $ item ) ) { $ table = isset ( $ item [ 0 ] ) ? $ item [ 0 ] : false ; $ alias = isset ( $ item [ 1 ] ) ? $ item [ 1 ] : false ; if ( is_object ( $...
Parses FROM entries
14,732
private function parseGroup ( ) { $ group = '' ; if ( isset ( $ this -> parts [ 'group' ] [ 'fields' ] ) ) { if ( is_array ( $ this -> parts [ 'group' ] [ 'fields' ] ) ) { $ groupFields = [ ] ; foreach ( $ this -> parts [ 'group' ] [ 'fields' ] as $ field ) { $ field = is_array ( $ field ) ? $ field : [ $ field ] ; $ c...
Parses GROUP entries
14,733
public function addServiceListener ( string $ eventName , array $ listener , $ priority = 0 ) : ContainerMediatorInterface { $ this -> checkEventName ( $ eventName ) ; $ this -> checkAllowedServiceListener ( $ listener ) ; $ priority = $ this -> getActualPriority ( $ eventName , $ priority ) ; if ( \ array_key_exists (...
Add a service as an event listener .
14,734
public function getServiceListeners ( string $ eventName = '' ) : array { $ this -> sortServiceListeners ( $ eventName ) ; if ( '' !== $ eventName ) { return \ array_key_exists ( $ eventName , $ this -> serviceListeners ) ? $ this -> serviceListeners [ $ eventName ] : [ ] ; } return $ this -> serviceListeners ; }
Get a list of service listeners for an event .
14,735
public function removeServiceListener ( string $ eventName , array $ listener , $ priority = 0 ) : ContainerMediatorInterface { $ this -> checkEventName ( $ eventName ) ; if ( ! \ array_key_exists ( $ eventName , $ this -> serviceListeners ) ) { return $ this ; } $ this -> checkAllowedServiceListener ( $ listener ) ; i...
Remove a service as an event listener .
14,736
public function configureAsseticBundle ( ContainerBuilder $ container , array $ config ) { foreach ( array_keys ( $ container -> getExtensions ( ) ) as $ name ) { switch ( $ name ) { case 'assetic' : $ this -> addJqueryInAssetic ( $ container , $ config [ 'assets' ] [ 'jquery' ] ) ; $ this -> addTwbsInAssetic ( $ conta...
Add assets to Assetic Bundle .
14,737
protected function addJqueryUIInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'js' ] !== false && $ config [ 'css' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'jqueryui_js' => $ config [ 'js' ] , 'jqueryui_css' => $ config [ 'css' ] , ) ,...
Adding jQuery UI in Assetic .
14,738
protected function addTwbsInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'twbs_dir' ] !== false && ! is_null ( $ config [ 'twbs_dir' ] ) ) { $ inputs = array ( ) ; foreach ( $ config [ 'js' ] as $ file ) { $ inputs [ ] = $ config [ 'twbs_dir' ] . '/' . $ file ; } $ container -> prependExt...
Adding Twitter Bootstrap in Assetic .
14,739
protected function addSelect2InAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'js' ] !== false && $ config [ 'css' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'select2_js' => $ config [ 'js' ] , 'select2_css' => $ config [ 'css' ] , ) , ) ...
Adding Select2 in Assetic .
14,740
protected function addBazingaJsTranslationInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'bz_translator_js' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'bz_translator_js' => $ config [ 'bz_translator_js' ] , 'bz_translator_config' => $ c...
Adding Bazinga Js Translation in Assetic .
14,741
protected function addTinyMCEInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'tinymce_dir' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'tinymce_js' => $ config [ 'tinymce_dir' ] . '/' . $ config [ 'js' ] , 'config' => $ config [ 'config' ...
Adding TinyMCE In Assetic .
14,742
protected function addJqueryTagsInputInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'js' ] !== false && $ config [ 'css' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'jquerytagsinput_js' => $ config [ 'js' ] , 'jquerytagsinput_css' => $ c...
Adding jQuery Tags Input Plugin in Assetic .
14,743
protected function addPrismJSInAssetic ( ContainerBuilder $ container , array $ config ) { if ( $ config [ 'js' ] !== false && $ config [ 'css' ] !== false ) { $ container -> prependExtensionConfig ( 'assetic' , array ( 'assets' => array ( 'prismjs_js' => $ config [ 'js' ] , 'prismjs_css' => $ config [ 'css' ] , ) , ) ...
Adding PrismJS in Assetic .
14,744
private function getRuleFactory ( string $ name ) : callable { if ( array_key_exists ( $ name , $ this -> factories ) ) { return $ this -> factories [ $ name ] ; } throw new RuleFactoryNotDefinedException ( $ name ) ; }
Return the rule factory associated to the given name .
14,745
public function parseRulesDefinition ( $ definition ) : RulesCollection { if ( is_callable ( $ definition ) ) { $ definition = [ $ definition ] ; } if ( is_string ( $ definition ) ) { $ definition = array_map ( 'trim' , explode ( '|' , $ definition ) ) ; } if ( is_array ( $ definition ) ) { $ keys = array_keys ( $ defi...
Return a rules collection from a rule definition . It can be either a callable an array of callables an array of factory names or a string of rule factory names .
14,746
private function parseRuleDefinition ( $ key , $ definition ) : Rule { if ( is_string ( $ definition ) ) { $ parts = preg_split ( '/:/' , $ definition , 2 ) ; $ factory_name = $ parts [ 0 ] ; $ parameters = $ parts [ 1 ] ?? null ; $ parameters = ! is_null ( $ parameters ) ? explode ( ',' , $ parameters ) : [ ] ; $ fact...
Return a rule from a rule key and the associated definition . It can be either a callable or a rule factory name with optional parameters .
14,747
public static function table ( $ data ) { $ in = new self ( ) ; $ in -> setData ( $ data ) ; $ in -> setOutput ( new Table ( ) ) ; return $ in ; }
Show the data in a html table .
14,748
public static function print_r ( $ data ) { $ in = new self ( ) ; $ in -> setData ( $ data ) ; $ in -> setOutput ( new PrintR ( ) ) ; return $ in ; }
Show the data in print_r form html .
14,749
public static function proxy ( $ request ) { if ( ! $ request instanceof Request ) { $ url = $ request ; $ request = new Request ( ) ; $ request -> setUrl ( $ url ) ; $ request -> setMethod ( Request :: METHOD_GET ) ; } return Client :: getInstance ( ) -> process ( $ request ) ; }
Proxy a request .
14,750
public function setRedirect ( $ url ) { $ this -> setHeader ( 'Location' , $ url ) ; $ this -> setStatus ( 302 ) ; $ this -> setData ( array ( 'message' => 'Redirecting to ' . $ url ) ) ; return $ this ; }
Set a response to be a redirect .
14,751
public function match ( $ methods , $ pattern , $ fn ) { $ pattern = $ this -> baseroute . '/' . trim ( $ pattern , '/' ) ; $ pattern = $ this -> baseroute ? rtrim ( $ pattern , '/' ) : $ pattern ; $ route = new Route ( $ pattern ) ; $ route -> setFunction ( $ fn ) ; $ route -> setModule ( $ this -> module ) ; foreach ...
Store a route and a handling function to be executed when accessed using one of the specified methods
14,752
public static function toSnakeCase ( $ name ) { $ temp_array = array ( ) ; for ( $ i = 0 ; $ i < strlen ( $ name ) ; $ i ++ ) { $ ascii_code = ord ( $ name [ $ i ] ) ; if ( $ ascii_code >= 65 && $ ascii_code <= 90 ) { if ( $ i == 0 ) { $ temp_array [ ] = chr ( $ ascii_code + 32 ) ; } else { $ temp_array [ ] = '_' . chr...
userName - > user_name
14,753
public function showAction ( Parameter $ entity ) { $ deleteForm = $ this -> createDeleteForm ( $ entity ) ; return array ( 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a parameter entity .
14,754
private function createDeleteForm ( Parameter $ entity ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'core_parameter_delete' , array ( 'id' => $ entity -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a parameter entity .
14,755
public function passes ( $ action = null ) { $ this -> data = $ this -> sanitize ( $ this -> data ) ; $ rules = $ this -> getRules ( $ action ) ; $ validator = $ this -> validator -> make ( $ this -> data , $ rules ) ; if ( $ validator -> fails ( ) ) { $ this -> errors = $ validator -> messages ( ) ; return false ; } r...
Pass the data and the rules to the validator .
14,756
public function exchangeArray ( $ dataSet ) { if ( is_object ( $ dataSet ) ) { switch ( true ) { case is_callable ( array ( $ dataSet , 'getArrayCopy' ) , false ) : $ dataSet = $ dataSet -> getArrayCopy ( ) ; break ; case is_callable ( array ( $ dataSet , 'toArray' ) , false ) : $ dataSet = $ dataSet -> toArray ( ) ; b...
This method was inspired by Zend Framework 2 . 2 . x PhpReferenceCompatibility class
14,757
public function exists ( $ func ) { if ( ! is_callable ( $ func , false , $ callable_name ) ) throw new \ InvalidArgumentException ( get_class ( $ this ) . '::exists - Un-callable "$func" value seen!' ) ; foreach ( $ this -> _storage as $ key => $ value ) { if ( call_user_func ( $ func , $ key , $ value ) ) return true...
Custom contains method
14,758
public function remove ( $ index ) { if ( isset ( $ this -> _storage [ $ index ] ) || array_key_exists ( $ index , $ this -> _storage ) ) { $ this -> _modified = true ; $ removed = $ this -> _storage [ $ index ] ; unset ( $ this -> _storage [ $ index ] ) ; return $ removed ; } return null ; }
Remove and return an element
14,759
public function map ( $ func ) { if ( is_callable ( $ func , false ) ) return $ this -> initNew ( array_map ( $ func , $ this -> _storage ) ) ; throw new \ InvalidArgumentException ( vsprintf ( '%s::map - Un-callable "$func" value seen!' , array ( get_class ( $ this ) ) ) ) ; }
Applies array_map to this collection and returns a new object .
14,760
public function filter ( $ func = null ) { if ( null === $ func ) return $ this -> initNew ( array_filter ( $ this -> _storage ) ) ; if ( is_callable ( $ func , false ) ) return $ this -> initNew ( array_filter ( $ this -> _storage , $ func ) ) ; throw new \ InvalidArgumentException ( vsprintf ( '%s::filter - Un-callab...
Applies array_filter to internal collection returns new instance with resulting values .
14,761
public function sort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return sort ( $ this -> _storage , $ flags ) ; }
Sort values by standard PHP sort method
14,762
public function rsort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return rsort ( $ this -> _storage , $ flags ) ; }
Reverse sort values
14,763
public function ksort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return ksort ( $ this -> _storage , $ flags ) ; }
Sort by keys
14,764
public function krsort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return krsort ( $ this -> _storage , $ flags ) ; }
Reverse sort by keys
14,765
public function asort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return asort ( $ this -> _storage , $ flags ) ; }
Sort values while retaining indices .
14,766
public function arsort ( $ flags = SORT_REGULAR ) { $ this -> _modified = true ; return arsort ( $ this -> _storage , $ flags ) ; }
Reverse sort values while retaining indices
14,767
private function _updateFirstLastKeys ( ) { end ( $ this -> _storage ) ; $ this -> _lastKey = key ( $ this -> _storage ) ; reset ( $ this -> _storage ) ; $ this -> _firstKey = key ( $ this -> _storage ) ; $ this -> _modified = false ; }
Update internal references to first and last keys in collection
14,768
public function notify ( $ type = 'default' ) { if ( isset ( $ this -> observers [ $ type ] ) ) { foreach ( $ this -> observers [ $ type ] as $ obs ) { $ obs -> update ( $ this ) ; } } return $ this ; }
Notify observers by type
14,769
public function mark_ready_for_dispatchAction ( Order $ order ) { $ order -> markReadyForDispatchBySeller ( ) ; $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ em -> persist ( $ order ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'Order_show' , array ( 'id' => $ order -> getNu...
mark ready for dispatch
14,770
public function mark_as_ready_to_pickupAction ( Order $ order ) { $ order -> markReadyForPickupFromHub ( ) ; $ message = \ Swift_Message :: newInstance ( ) -> setSubject ( 'Your order is ready to be picked up' ) -> setFrom ( array ( 'no-reply@harvestcloud.com' => 'Harvest Cloud' ) ) -> setTo ( array ( 'tom@templestreet...
mark as ready to pickup
14,771
public static function Atciqz ( $ rc , $ dc , iauASTROM & $ astrom , & $ ri , & $ di ) { $ pco = [ ] ; $ pnat = [ ] ; $ ppr = [ ] ; $ pi = [ ] ; $ w ; IAU :: S2c ( $ rc , $ dc , $ pco ) ; IAU :: Ldsun ( $ pco , $ astrom -> eh , $ astrom -> em , $ pnat ) ; IAU :: Ab ( $ pnat , $ astrom -> v , $ astrom -> em , $ astrom -...
- - - - - - - - - - i a u A t c i q z - - - - - - - - - -
14,772
public function addOption ( OptionInterface $ option ) : void { $ option -> setSelected ( $ option -> getValue ( ) === $ this -> value ) ; if ( $ option -> getValue ( ) === '' ) { $ this -> hasEmptyOption = true ; } $ this -> options [ ] = $ option ; }
Adds on option .
14,773
public static function sanitizeUrl ( $ url ) { $ url = trim ( $ url ) ; if ( ! $ url ) { return null ; } if ( ! preg_match ( "/^https?:\/\//i" , $ url ) ) { $ url = "http://" . $ url ; } return self :: sanitizeString ( $ url ) ; }
Prefixes the url with a protocol if it has none to prevent local lookups .
14,774
public static function sanitizeText ( $ text ) { if ( ! $ text ) { return null ; } $ allowedTagNames = [ "b" , "strong" , "i" , "em" , "br" ] ; $ marker = "\&8slkc7\\" ; $ allowedTagConversion = [ ] ; foreach ( $ allowedTagNames as $ allowedTagName ) { $ allowedTagConversion [ "<{$allowedTagName}>" ] = "{$marker}{$allo...
Same as sanitizeString but allows linebreaks and strong and italic text .
14,775
public static function sanitizeString ( $ string ) { if ( ! $ string ) { return null ; } $ string = str_ireplace ( [ "\r\n" , "\n" , "\r" ] , " " , $ string ) ; $ string = html_entity_decode ( $ string , ENT_NOQUOTES , "UTF-8" ) ; $ string = trim ( strip_tags ( $ string ) ) ; if ( ! $ string ) { return null ; } return ...
Trims string removes tags and linebreaks . Returns null if string equals false before or after conversion .
14,776
public static function sanitizeUrlParts ( $ urlPartOrUrlParts , ... $ additionalUrlParts ) { if ( is_array ( $ urlPartOrUrlParts ) ) { $ urlParts = $ urlPartOrUrlParts ; } else { $ urlParts = array_merge ( [ $ urlPartOrUrlParts ] , $ additionalUrlParts ) ; } $ sanitizedUrlParts = [ ] ; foreach ( $ urlParts as $ urlPart...
Sanitize or SEOify url part . Will result in a string with only dashes dots and alphanumeric characters . Arguments are joined by slashes . If an array of parts is given as the first argument each one will be processed and returned as one string with slashes between parts .
14,777
public static function explode ( $ string , $ characters = ";>|/\\<" ) { $ string = self :: sanitizeString ( $ string ) ; if ( $ string === null ) { return [ ] ; } $ splitRegex = "" ; for ( $ i = 0 ; $ i < strlen ( $ characters ) ; $ i ++ ) { $ splitRegex .= "\\" . $ characters [ $ i ] ; } $ splitRegex = "/[" . $ split...
Explodes a string into an array after performing sanitization on each element .
14,778
public static function implode ( $ array , $ separator = " > " ) { if ( $ array === null ) { return "" ; } $ elements = [ ] ; foreach ( $ array as $ rawElement ) { $ element = self :: sanitizeString ( $ rawElement ) ; if ( $ element !== null ) { $ elements [ ] = $ element ; } } return implode ( $ separator , $ elements...
Implodes an array into a string after performing sanitization on each element .
14,779
public static function startsWith ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , false , false , false ) ; }
Returns whether the value of the given strings start with any of the supplied options .
14,780
public static function endsWith ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , true , false , false ) ; }
Returns whether the value of the given strings end with any of the supplied options .
14,781
public static function startsWithInsensitive ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , false , false , true ) ; }
Returns whether the case insensitive value of the given strings start with any of the supplied options .
14,782
public static function endsWithInsensitive ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , true , false , true ) ; }
Returns whether the case insensitive value of the given string ends with any of the supplied options .
14,783
public static function startsWithAlphanumeric ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , false , true , false ) ; }
Returns whether the alphanumeric value of the given strings start with any of the supplied options .
14,784
public static function endsWithAlphanumeric ( $ stringOrStrings , $ optionOrOptions ) { return self :: startsWithInternal ( $ stringOrStrings , $ optionOrOptions , true , true , false ) ; }
Returns whether the alphanumeric value of the given strings end with any of the supplied options .
14,785
private static function startsWithInternal ( $ stringOrStrings , $ optionOrOptions , $ matchEnd , $ alphanumeric , $ caseInsensitive ) { $ strings = is_array ( $ stringOrStrings ) ? $ stringOrStrings : [ $ stringOrStrings ] ; $ options = is_array ( $ optionOrOptions ) ? $ optionOrOptions : [ $ optionOrOptions ] ; forea...
Internal method used by all startsWith and endsWith methods to keep code in one place .
14,786
public static function encodeUri ( $ uri ) { $ uri = self :: removeSchemeFromUri ( $ uri , $ scheme ) ; $ uri = rawurlencode ( $ uri ) ; $ uri = str_replace ( "%2F" , "/" , $ uri ) ; return $ scheme . $ uri ; }
Encodes a full URI leaving the slashes and scheme intact .
14,787
public static function formatPath ( $ pathOrPaths , ... $ additionalPaths ) { $ path = rawurldecode ( self :: mergePaths ( $ pathOrPaths , ... $ additionalPaths ) ) ; $ path = self :: removeSchemeFromUri ( $ path , $ scheme ) ; $ replacements = 0 ; do { $ path = str_replace ( [ "/./" , "//" ] , "/" , $ path , $ replace...
Formats a file path to a uniform representation . Multiple paths can be given and will be concatenated .
14,788
public static function formatAndResolvePath ( $ pathOrPaths , ... $ additionalPaths ) { $ path = rawurldecode ( self :: mergePaths ( $ pathOrPaths , ... $ additionalPaths ) ) ; $ path = realpath ( $ path ) ; if ( ! $ path ) { throw new DataHandlingException ( "Given path does not exist." ) ; } return self :: formatPath...
Resolves and formats a path .
14,789
public static function mergePaths ( $ pathOrPaths , ... $ additionalPaths ) { if ( is_array ( $ pathOrPaths ) ) { $ paths = $ pathOrPaths ; } else { $ paths = array_merge ( [ $ pathOrPaths ] , $ additionalPaths ) ; } $ paths = array_values ( $ paths ) ; $ prefix = "" ; $ suffix = "" ; if ( count ( $ paths ) > 0 ) { if ...
Merges path parts into one path . Only the first argument can cause the path to become absolute .
14,790
public static function makePathRelative ( $ path , $ rootDirectory ) { $ rootDirectory = self :: formatDirectory ( $ rootDirectory ) ; $ path = self :: formatPath ( $ path ) ; if ( ! self :: startsWith ( self :: formatDirectory ( $ path ) , $ rootDirectory ) ) { throw new DataHandlingException ( "Path is not part of th...
Makes given path relative to the given root directory .
14,791
public static function formatDirectory ( $ pathOrPaths , ... $ additionalPaths ) { $ directory = self :: formatPath ( $ pathOrPaths , ... $ additionalPaths ) ; if ( $ directory ) { $ directory = rtrim ( $ directory , "/" ) . "/" ; } return $ directory ; }
Formats a directory path to a uniform representation . Basically formatPath but with a trailing slash .
14,792
public static function formatAndResolveDirectory ( $ pathOrPaths , ... $ additionalPaths ) { $ directory = self :: formatAndResolvePath ( $ pathOrPaths , ... $ additionalPaths ) ; if ( $ directory ) { $ directory = rtrim ( $ directory , "/" ) . "/" ; } return $ directory ; }
Resolves and formats a directory .
14,793
public static function formatBytesize ( $ size ) { $ suffixes = [ "B" , "KiB" , "MiB" , "GiB" , "TiB" ] ; $ level = 1 ; for ( $ exponent = 0 ; $ exponent < count ( $ suffixes ) ; $ exponent ++ ) { $ nextLevel = pow ( 1024 , $ exponent + 1 ) ; if ( $ nextLevel > $ size ) { $ smallSize = $ size / $ level ; if ( $ smallSi...
Returns a suffixed and shortened indication of an amount of bytes .
14,794
public function authenticateSocial ( $ authResponse ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ return = false ; $ providerkey = $ authResponse [ 'auth' ] [ 'uid' ] ; $ query = 'SELECT * FROM `user_social` WHERE `providerkey` = ' . $ this -> db -> quoteValue ( $ providerkey ) ; $ users = $ this -> db -> qu...
check if auth response user exists in auth_social table does not load any user info
14,795
public function create ( $ vals ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ return = array ( 'success' => true , 'errorDesc' => '' , 'userid' => null , ) ; $ noQuoteCols = array ( 'createdon' , 'lastactivity' , ) ; $ vals = array_change_key_case ( $ vals ) ; $ vals [ 'createdon' ] = 'NOW()' ; $ vals [ 'las...
Creates user in DB Does NOT load user into current session
14,796
public function logout ( ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; if ( $ this -> auth ) { $ this -> setPersistToken ( false ) ; $ this -> log ( 'logout' ) ; } ArrayUtil :: path ( $ _SESSION , $ this -> cfg [ 'sessionPath' ] , array ( ) ) ; $ this -> userid = null ; $ this -> auth = 0 ; $ this -> debug -> ...
Log user out
14,797
public function search ( $ vals ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ this -> debug -> log ( 'vals' , $ vals ) ; $ return = array ( ) ; if ( $ vals ) { $ where = array ( ) ; $ where_or = array ( ) ; if ( ! empty ( $ vals [ 'username' ] ) ) { $ where_or [ ] = '`username` = ' . $ this -> db -> quoteVal...
search for user by username email or userid
14,798
public function setCurrent ( $ userid ) { $ this -> debug -> groupCollapsed ( __METHOD__ , $ userid ) ; Session :: start ( ) ; $ user = $ this -> get ( $ userid ) ; ArrayUtil :: path ( $ _SESSION , $ this -> cfg [ 'sessionPath' ] , array ( ) ) ; $ path = $ this -> cfg [ 'sessionPath' ] ; if ( ! \ is_array ( $ path ) ) ...
Set current user by userid
14,799
public function setPersistToken ( $ set = true ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; $ cookieParams = $ this -> cfg [ 'persistCookie' ] ; $ return = null ; if ( $ set ) { $ token = $ this -> genToken ( ) ; $ cookieParams [ 'value' ] = array ( 'username' => $ this -> user [ 'username' ] , 'token' => $ t...
sets cookie stores unsalted SHA1 hash in db