idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
5,000 | private static function getFullNamespace ( $ filename ) { $ lines = file ( $ filename ) ; $ namespaceLine = preg_grep ( '/^namespace /' , $ lines ) ; $ namespaceLine = array_shift ( $ namespaceLine ) ; $ match = array ( ) ; preg_match ( '#(namespace)(\\s+)([A-Za-z0-9\\\\]+?)(\\s*);#sm' , $ namespaceLine , $ match ) ; $... | Get full namespace from file . |
5,001 | private static function getClassName ( $ filename ) { $ directoriesAndFilename = explode ( '/' , $ filename ) ; $ filename = array_pop ( $ directoriesAndFilename ) ; $ nameAndExtension = explode ( '.' , $ filename ) ; $ className = array_shift ( $ nameAndExtension ) ; return $ className ; } | Get class name from file . |
5,002 | public static function Attributes ( $ user ) { $ user = ( array ) $ user ; $ attributes = $ user [ 'Attributes' ] ; if ( is_string ( $ attributes ) ) $ attributes = unserialize ( $ attributes ) ; if ( ! is_array ( $ attributes ) ) $ attributes = array ( ) ; return $ attributes ; } | Reliably get the attributes from any user array or object |
5,003 | public function CheckPermission ( $ User , $ Permission , $ Options = array ( ) ) { if ( is_numeric ( $ User ) ) { $ User = $ this -> GetID ( $ User ) ; } $ User = ( object ) $ User ; if ( $ User -> Banned || $ User -> Deleted ) return FALSE ; if ( $ User -> Admin ) return TRUE ; if ( $ User -> UserID == 0 ) $ Permissi... | Checks the specified user s for the given permission . Returns a boolean value indicating if the action is permitted . |
5,004 | public function Merge ( $ OldUserID , $ NewUserID ) { $ OldUser = $ this -> GetID ( $ OldUserID , DATASET_TYPE_ARRAY ) ; $ NewUser = $ this -> GetID ( $ NewUserID , DATASET_TYPE_ARRAY ) ; if ( ! $ OldUser || ! $ NewUser ) { throw new Gdn_UserException ( "Could not find one or both users to merge." ) ; } $ Map = array (... | Merge the old user into the new user . |
5,005 | public function UnBan ( $ UserID , $ Options = array ( ) ) { $ User = $ this -> GetID ( $ UserID , DATASET_TYPE_ARRAY ) ; if ( ! $ User ) throw NotFoundException ( ) ; if ( ! $ User [ 'Banned' ] ) throw new Gdn_UserException ( T ( "The user isn't banned." ) ) ; $ this -> SetField ( $ UserID , 'Banned' , FALSE ) ; if ( ... | Unban a user . |
5,006 | public function Connect ( $ UniqueID , $ ProviderKey , $ UserData , $ Options = array ( ) ) { Trace ( 'UserModel->Connect()' ) ; $ UserID = FALSE ; if ( ! isset ( $ UserData [ 'UserID' ] ) ) { $ Auth = $ this -> GetAuthentication ( $ UniqueID , $ ProviderKey ) ; $ UserID = GetValue ( 'UserID' , $ Auth ) ; if ( $ UserID... | Connect a user with a foreign authentication system . |
5,007 | public function JoinUsers ( & $ Data , $ Columns , $ Options = array ( ) ) { $ UserIDs = array ( ) ; foreach ( $ Data as $ Row ) { foreach ( $ Columns as $ ColumnName ) { $ ID = GetValue ( $ ColumnName , $ Row ) ; if ( is_numeric ( $ ID ) ) $ UserIDs [ $ ID ] = 1 ; } } $ Users = $ this -> GetIDs ( array_keys ( $ UserID... | Add user data to a result set . |
5,008 | public function DefinePermissions ( $ UserID , $ Serialize = TRUE ) { if ( Gdn :: Cache ( ) -> ActiveEnabled ( ) ) { $ PermissionsIncrement = $ this -> GetPermissionsIncrement ( ) ; $ UserPermissionsKey = FormatString ( self :: USERPERMISSIONS_KEY , array ( 'UserID' => $ UserID , 'PermissionsIncrement' => $ Permissions... | Load and compile user permissions |
5,009 | public static function CompilePermissions ( $ Permissions ) { $ Compiled = array ( ) ; foreach ( $ Permissions as $ i => $ Row ) { $ JunctionID = array_key_exists ( 'JunctionID' , $ Row ) ? $ Row [ 'JunctionID' ] : null ; unset ( $ Row [ 'JunctionColumn' ] , $ Row [ 'JunctionColumn' ] , $ Row [ 'JunctionID' ] , $ Row [... | Take raw permission definitions and create |
5,010 | public function GetApplicants ( ) { $ ApplicantRoleID = ( int ) C ( 'Garden.Registration.ApplicantRoleID' , 0 ) ; if ( $ ApplicantRoleID == 0 ) return new Gdn_DataSet ( ) ; return $ this -> SQL -> Select ( 'u.*' ) -> From ( 'User u' ) -> Join ( 'UserRole ur' , 'u.UserID = ur.UserID' ) -> Where ( 'ur.RoleID' , $ Applica... | Returns all users in the applicant role |
5,011 | public function GetAuthentication ( $ UniqueID , $ Provider ) { return $ this -> SQL -> GetWhere ( 'UserAuthentication' , array ( 'ForeignUserKey' => $ UniqueID , 'ProviderKey' => $ Provider ) ) -> FirstRow ( DATASET_TYPE_ARRAY ) ; } | Get the a user authentication row . |
5,012 | public function GetSummary ( $ OrderFields = '' , $ OrderDirection = 'asc' , $ Limit = FALSE , $ Offset = FALSE ) { $ this -> UserQuery ( TRUE ) ; return $ this -> SQL -> Where ( 'u.Deleted' , 0 ) -> OrderBy ( $ OrderFields , $ OrderDirection ) -> Limit ( $ Limit , $ Offset ) -> Get ( ) ; } | Retrieve a summary of safe user information for external API calls . |
5,013 | public function GetSystemUserID ( ) { $ SystemUserID = C ( 'Garden.SystemUserID' ) ; if ( $ SystemUserID ) return $ SystemUserID ; $ SystemUser = array ( 'Name' => T ( 'System' ) , 'Photo' => Asset ( '/applications/dashboard/design/images/usericon.png' , TRUE ) , 'Password' => RandomString ( '20' ) , 'HashMethod' => 'R... | Retrieves a system user id that can be used to perform non - real - person tasks . |
5,014 | public static function GivePoints ( $ UserID , $ Points , $ Source = 'Other' , $ Timestamp = FALSE ) { if ( ! $ Timestamp ) $ Timestamp = time ( ) ; if ( is_array ( $ Source ) ) { $ CategoryID = GetValue ( 'CategoryID' , $ Source , 0 ) ; $ Source = $ Source [ 0 ] ; } else { $ CategoryID = 0 ; } if ( $ CategoryID > 0 ) ... | Add points to a user s total . |
5,015 | protected static function _GivePoints ( $ UserID , $ Points , $ SlotType , $ Source = 'Total' , $ CategoryID = 0 , $ Timestamp = FALSE ) { $ TimeSlot = gmdate ( 'Y-m-d' , Gdn_Statistics :: TimeSlotStamp ( $ SlotType , $ Timestamp ) ) ; $ Px = Gdn :: Database ( ) -> DatabasePrefix ; $ Sql = "insert {$Px}UserPoints (User... | Add points to a user s total in a specific timeslot . |
5,016 | public function SaveAdminUser ( $ FormPostValues ) { $ UserID = 0 ; $ Name = GetValue ( 'Name' , $ FormPostValues , '' ) ; $ FormPostValues [ 'Email' ] = GetValue ( 'Email' , $ FormPostValues , strtolower ( $ Name . '@' . Gdn_Url :: Host ( ) ) ) ; $ FormPostValues [ 'ShowEmail' ] = '0' ; $ FormPostValues [ 'TermsOfServ... | Create an admin user account |
5,017 | public function TagSearch ( $ Search ) { $ Search = trim ( str_replace ( array ( '%' , '_' ) , array ( '\%' , '\_' ) , $ Search ) ) ; $ Results = $ this -> SQL -> Select ( 'UserID' , '' , 'id' ) -> Select ( 'Name' , '' , 'name' ) -> From ( 'User' ) -> Like ( 'Name' , $ Search , 'right' ) -> Where ( 'Deleted' , 0 ) -> L... | A simple search for tag queries . |
5,018 | public function InsertForApproval ( $ FormPostValues , $ Options = array ( ) ) { $ RoleIDs = C ( 'Garden.Registration.ApplicantRoleID' ) ; if ( ! $ RoleIDs ) { throw new Exception ( T ( 'The default role has not been configured.' ) , 400 ) ; } $ this -> DefineSchema ( ) ; $ this -> Validation -> ApplyRule ( 'Email' , '... | To be used for approval registration |
5,019 | public function InsertForBasic ( $ FormPostValues , $ CheckCaptcha = TRUE , $ Options = array ( ) ) { $ RoleIDs = Gdn :: Config ( 'Garden.Registration.DefaultRoles' ) ; if ( ! is_array ( $ RoleIDs ) || count ( $ RoleIDs ) == 0 ) throw new Exception ( T ( 'The default role has not been configured.' ) , 400 ) ; if ( GetV... | To be used for basic registration and captcha registration |
5,020 | public function ValidateCredentials ( $ Email = '' , $ ID = 0 , $ Password ) { $ this -> EventArguments [ 'Credentials' ] = array ( 'Email' => $ Email , 'ID' => $ ID , 'Password' => $ Password ) ; $ this -> FireEvent ( 'BeforeValidateCredentials' ) ; if ( ! $ Email && ! $ ID ) throw new Exception ( 'The email or id is ... | Validate User Credential |
5,021 | public function Approve ( $ UserID , $ Email ) { $ ApplicantRoleID = C ( 'Garden.Registration.ApplicantRoleID' , 0 ) ; $ RoleData = $ this -> GetRoles ( $ UserID ) ; if ( $ RoleData -> NumRows ( ) == 0 ) { throw new Exception ( T ( 'ErrorRecordNotFound' ) ) ; } else { $ AppRoles = $ RoleData -> Result ( DATASET_TYPE_AR... | Approve a membership applicant . |
5,022 | public function Delete ( $ UserID , $ Options = array ( ) ) { if ( $ UserID == $ this -> GetSystemUserID ( ) ) { $ this -> Validation -> AddValidationResult ( '' , 'You cannot delete the system user.' ) ; return FALSE ; } $ Content = array ( ) ; $ this -> GetDelete ( 'UserAuthentication' , array ( 'UserID' => $ UserID ... | Delete a single user . |
5,023 | public function GetDelete ( $ Table , $ Where , & $ Data ) { if ( is_array ( $ Data ) ) { $ Result = $ this -> SQL -> GetWhere ( $ Table , $ Where ) -> ResultArray ( ) ; if ( empty ( $ Result ) ) return ; if ( isset ( $ Data [ $ Table ] ) ) { $ Data [ $ Table ] = array_merge ( $ Data [ $ Table ] , $ Result ) ; } else {... | Get rows from a table then delete them . |
5,024 | public function ReduceInviteCount ( $ UserID , $ ReduceBy = 1 ) { $ CurrentCount = $ this -> GetInvitationCount ( $ UserID ) ; if ( $ CurrentCount == - 1 ) return TRUE ; if ( $ ReduceBy > $ CurrentCount ) $ ReduceBy = $ CurrentCount ; $ this -> SQL -> Update ( $ this -> Name ) -> Set ( 'CountInvitations' , 'CountInvita... | Reduces the user s CountInvitations value by the specified amount . |
5,025 | public function IncreaseInviteCount ( $ UserID , $ IncreaseBy = 1 ) { $ CurrentCount = $ this -> GetInvitationCount ( $ UserID ) ; if ( $ CurrentCount == - 1 ) return TRUE ; $ this -> SQL -> Update ( $ this -> Name ) -> Set ( 'CountInvitations' , 'CountInvitations + ' . $ IncreaseBy , FALSE ) -> Where ( 'UserID' , $ Us... | Increases the user s CountInvitations value by the specified amount . |
5,026 | public function SaveAbout ( $ UserID , $ About ) { $ About = substr ( $ About , 0 , 1000 ) ; $ this -> SetField ( $ UserID , 'About' , $ About ) ; } | Saves the user s About field . |
5,027 | public function SavePreference ( $ UserID , $ Preference , $ Value = '' ) { $ Session = Gdn :: Session ( ) ; if ( $ UserID == $ Session -> UserID ) $ Session -> SetPreference ( $ Preference , $ Value , FALSE ) ; return $ this -> SaveToSerializedColumn ( 'Preferences' , $ UserID , $ Preference , $ Value ) ; } | Saves a user preference to the database . |
5,028 | public function SaveAttribute ( $ UserID , $ Attribute , $ Value = '' ) { $ Session = Gdn :: Session ( ) ; if ( $ UserID == $ Session -> UserID ) $ Session -> SetAttribute ( $ Attribute , $ Value ) ; return $ this -> SaveToSerializedColumn ( 'Attributes' , $ UserID , $ Attribute , $ Value ) ; } | Saves a user attribute to the database . |
5,029 | public function Synchronize ( $ UserKey , $ Data ) { $ UserID = 0 ; $ Attributes = ArrayValue ( 'Attributes' , $ Data ) ; if ( is_string ( $ Attributes ) ) $ Attributes = @ unserialize ( $ Attributes ) ; if ( ! is_array ( $ Attributes ) ) $ Attributes = array ( ) ; if ( ! isset ( $ Data [ 'UserID' ] ) || $ Data [ 'User... | Synchronizes the user based on a given UserKey . |
5,030 | public static function RateLimit ( $ User , $ PasswordOK ) { if ( ! Gdn :: Cache ( ) -> ActiveEnabled ( ) ) return FALSE ; $ UserRateKey = FormatString ( self :: LOGIN_RATE_KEY , array ( 'Source' => $ User -> UserID ) ) ; $ UserRate = ( int ) Gdn :: Cache ( ) -> Get ( $ UserRateKey ) ; $ UserRate += 1 ; Gdn :: Cache ( ... | Check and apply login rate limiting |
5,031 | public function GetUserFromCache ( $ UserToken , $ TokenType ) { if ( $ TokenType == 'name' ) { $ UserNameKey = FormatString ( self :: USERNAME_KEY , array ( 'Name' => md5 ( $ UserToken ) ) ) ; $ UserID = Gdn :: Cache ( ) -> Get ( $ UserNameKey ) ; if ( $ UserID === Gdn_Cache :: CACHEOP_FAILURE ) return FALSE ; $ UserT... | Get a user from the cache by name or ID |
5,032 | public function UserCache ( $ User ) { $ UserID = GetValue ( 'UserID' , $ User , NULL ) ; if ( is_null ( $ UserID ) || ! $ UserID ) return FALSE ; $ Cached = TRUE ; $ UserKey = FormatString ( self :: USERID_KEY , array ( 'UserID' => $ UserID ) ) ; $ Cached = $ Cached & Gdn :: Cache ( ) -> Store ( $ UserKey , $ User , a... | Cache user object |
5,033 | public function UserCacheRoles ( $ UserID , $ RoleIDs ) { if ( is_null ( $ UserID ) || ! $ UserID ) return FALSE ; $ Cached = TRUE ; $ UserRolesKey = FormatString ( self :: USERROLES_KEY , array ( 'UserID' => $ UserID ) ) ; $ Cached = $ Cached & Gdn :: Cache ( ) -> Store ( $ UserRolesKey , $ RoleIDs ) ; return $ Cached... | Cache user s roles |
5,034 | public function ClearCache ( $ UserID , $ CacheTypesToClear = NULL ) { if ( is_null ( $ UserID ) || ! $ UserID ) return FALSE ; if ( is_null ( $ CacheTypesToClear ) ) $ CacheTypesToClear = array ( 'user' , 'roles' , 'permissions' ) ; if ( in_array ( 'user' , $ CacheTypesToClear ) ) { $ UserKey = FormatString ( self :: ... | Delete cached data for user |
5,035 | protected function adminGroup ( Closure $ callback ) { $ attributes = $ this -> getAdminAttributes ( ) ; $ this -> prefix ( Arr :: get ( $ attributes , 'prefix' , 'dashboard' ) ) -> name ( Arr :: get ( $ attributes , 'name' , 'admin::' ) ) -> namespace ( $ this -> adminNamespace ) -> middleware ( Arr :: get ( $ attribu... | Group the routes with admin attributes . |
5,036 | protected function _setOperatorString ( $ operatorString ) { if ( ! is_string ( $ operatorString ) && ! ( $ operatorString instanceof Stringable ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Argument is not a string or stringable object' ) , null , null , $ operatorString ) ; } $ this -> opera... | Sets the operator string for this instance . |
5,037 | public static function getFactory ( string $ p_dsn , $ p_key1 = null , $ p_key2 = null ) { $ parts = explode ( ':' , $ p_dsn ) ; $ storage = null ; switch ( strtolower ( $ parts [ 0 ] ) ) { case 'mysql' : $ provider = new \ FreeFW \ Storage \ PDO \ Mysql ( $ p_dsn , $ p_key1 , $ p_key2 ) ; $ storage = new \ FreeFW \ St... | Get new StorageInterface |
5,038 | public static function Pdp ( array $ a , array $ b ) { $ w ; $ w = 0 + $ a [ 0 ] * $ b [ 0 ] + $ a [ 1 ] * $ b [ 1 ] + $ a [ 2 ] * $ b [ 2 ] ; return $ w ; } | - - - - - - - i a u P d p - - - - - - - |
5,039 | protected function _containerListGet ( $ key , $ list ) { $ list = $ this -> _normalizeIterable ( $ list ) ; foreach ( $ list as $ _container ) { if ( $ this -> _containerHas ( $ _container , $ key ) ) { return $ this -> _containerGet ( $ _container , $ key ) ; } } throw $ this -> _createNotFoundException ( $ this -> _... | Retrieves a service from the list of containers . |
5,040 | public function send ( $ text = null ) { if ( $ text ) { $ this -> withText ( $ text ) ; } $ this -> response = $ this -> client -> sendMessage ( $ this ) ; return $ this ; } | Send the message to Slack . |
5,041 | public function setIcon ( $ icon ) { $ this -> icon = $ icon ; $ type = mb_substr ( $ icon , 0 , 1 ) === ':' && mb_substr ( $ icon , - 1 ) === ':' ? 'iconEmoji' : 'iconUrl' ; $ this -> $ type = $ icon ; return $ this ; } | Send message with this icon . |
5,042 | public final function handle ( ehough_shortstop_api_HttpRequest $ request ) { $ logger = $ this -> getLogger ( ) ; $ isDebugEnabled = $ logger -> isHandling ( ehough_epilog_Logger :: DEBUG ) ; if ( $ isDebugEnabled ) { $ logger -> debug ( sprintf ( 'Preparing to handle %s' , $ request ) ) ; } $ this -> prepareToHandleN... | Execute the given HTTP request . |
5,043 | protected function getLiveTable ( ) { return $ this -> getDataObject ( $ this -> getList ( ) ) -> stageTable ( $ this -> getBaseTable ( ) , Versioned :: LIVE ) ; } | Answers the live table for the data object queried by the source data list . |
5,044 | public function getFormattedName ( ) : ? string { if ( ! $ this -> hasFormattedName ( ) ) { $ this -> setFormattedName ( $ this -> getDefaultFormattedName ( ) ) ; } return $ this -> formattedName ; } | Get formatted name |
5,045 | public function authorized ( $ model , $ relations , $ user = null ) { $ owner = $ this -> owner ; $ query = $ this -> getRelatedUserQuery ( $ model , $ relations , $ user ) ; if ( ! empty ( $ query -> where ) ) { $ owner -> andWhere ( $ query -> where ) ; $ owner -> addParams ( $ query -> params ) ; } return $ owner ;... | Warning! Main table in the current query should have the t alias set . |
5,046 | public function getRelatedUserQuery ( $ model , $ relations , $ user = null , $ baseConditions = [ ] , $ baseParams = [ ] , $ primaryKey = null ) { if ( $ user === null ) { $ user = \ Yii :: $ app -> user -> identity ; } $ query = new Query ; if ( $ user === null ) { return $ query -> andWhere ( '1=0' ) ; } if ( $ prim... | Joins conditions obtained from getCompositeRelatedConditions into one condition using a subquery . |
5,047 | private function addIndexesSection ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> fixXmlConfig ( 'index' ) -> children ( ) -> arrayNode ( 'indexes' ) -> useAttributeAsKey ( 'name' ) -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'index_name' ) -> info ( 'Defaults to the name of the index, but can be modif... | Adds the configuration for the indexes key . |
5,048 | protected function searchField ( ) { if ( isset ( $ this -> htmlOptions [ 'class' ] ) ) $ this -> htmlOptions [ 'class' ] .= ' search-query' ; else $ this -> htmlOptions [ 'class' ] = 'search-query' ; $ this -> htmlOptions [ 'placeholder' ] = $ this -> model -> getAttributeLabel ( $ this -> attribute ) ; echo $ this ->... | Renders a text field . |
5,049 | public function getShowInfo ( $ id ) { $ showInfo = array ( ) ; $ crawler = $ this -> request ( 'GET' , $ this -> baseUrl . '/title/' . $ id . '/' ) ; $ showInfo [ 'title' ] = $ crawler -> filterXPath ( '//h1/span[@itemprop="name"]' ) -> text ( ) ; $ nextEpisode = $ crawler -> filterXPath ( '//div[@class="next-episode"... | Returns information for a specified TV show . |
5,050 | public function getSeasonEpisodes ( $ id , $ season ) { $ crawler = $ this -> request ( 'GET' , $ this -> baseUrl . '/title/' . $ id . '/episodes?season=' . $ season ) ; $ divs = $ crawler -> filterXPath ( '//div[contains(@class, "eplist")]/div[contains(@class, "list_item")]/div[@class="info"]' ) ; $ episodes = array (... | Returns a list of episodes for a specified season of a TV show . |
5,051 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; $ srvConfig = isset ( $ config [ 'modules' ] [ 'Grid\Paragraph' ] ) ? $ config [ 'modules' ] [ 'Grid\Paragraph' ] : array ( ) ; return new Customization ( isset ( $ srvConfig [ 'customiz... | Create the customization - service |
5,052 | public function label ( $ name , $ value , $ attributes = [ ] ) { if ( isset ( $ attributes [ 'for' ] ) ) { $ attributes [ 'id' ] = $ attributes [ 'for' ] ; } list ( $ attributes ) = $ this -> _prepare ( $ name , $ attributes ) ; $ attributes [ 'for' ] = $ attributes [ 'id' ] ; unset ( $ attributes [ 'id' ] ) ; unset (... | Outputs the HTML for a < ; label> ; . |
5,053 | public function error ( $ name , $ attributes = [ ] ) { if ( ! isset ( $ this -> _errors [ $ name ] ) ) return '' ; list ( $ attributes ) = $ this -> _prepare ( $ name , $ attributes ) ; $ attributes [ 'data-error-for' ] = $ attributes [ 'id' ] ; unset ( $ attributes [ 'id' ] ) ; $ attributes = $ this -> _arrayToAttrib... | Outputs the HTML for an error < ; span> ; . |
5,054 | public function textarea ( $ name , $ attributes = [ ] ) { list ( $ attributes , $ value ) = $ this -> _prepare ( $ name , $ attributes ) ; $ attributes = $ this -> _arrayToAttributesString ( $ attributes ) ; $ value = $ this -> _escape ( $ value ) ; return "<textarea{$attributes}>{$value}</textarea>" ; } | Outputs the HTML for a < ; textarea> ; field . |
5,055 | public function radio ( $ name , $ value , $ attributes = [ ] ) { if ( isset ( $ this -> _input [ $ name ] ) ) { if ( $ this -> _input [ $ name ] === $ value ) $ attributes [ 'checked' ] = 'checked' ; else unset ( $ attributes [ 'checked' ] ) ; } return $ this -> _getDefaultInputHtml ( 'radio' , $ name , $ attributes ,... | Outputs the HTML for an < ; input type = radio > ; field . |
5,056 | public function select ( $ name , $ values , $ attributes = [ ] ) { list ( $ attributes , $ selected_value ) = $ this -> _prepare ( $ name , $ attributes ) ; $ attributes = $ this -> _arrayToAttributesString ( $ attributes ) ; $ content = "<select{$attributes}>" ; $ content .= $ this -> select_option ( $ values , $ sel... | Outputs the HTML for a < ; select> ; field . |
5,057 | public function select_option ( $ values , $ selected_value ) { $ content = '' ; foreach ( $ values as $ value => $ title ) { if ( is_array ( $ title ) ) { $ label = $ this -> _escape ( $ value ) ; $ content .= "<optgroup label=\"{$label}\">" ; $ content .= $ this -> select_option ( $ title , $ selected_value ) ; $ con... | Outputs the HTML for an < ; option> ; field . |
5,058 | protected function _getDefaultInputHtml ( $ type , $ name , $ attributes , $ value_fixed = null ) { list ( $ attributes , $ value ) = $ this -> _prepare ( $ name , $ attributes ) ; $ attributes [ 'type' ] = ! isset ( $ attributes [ 'type' ] ) ? $ type : $ attributes [ 'type' ] ; if ( is_scalar ( $ value ) ) $ attribute... | Method to output an < ; input> ; field . Used by many other field methods . |
5,059 | protected function _prepare ( $ name , $ attributes ) { if ( isset ( $ this -> _errors [ $ name ] ) ) { if ( isset ( $ attributes [ 'class' ] ) ) { $ attributes [ 'class' ] .= ' ' . self :: $ error_class ; } else { $ attributes [ 'class' ] = self :: $ error_class ; } } if ( ! isset ( $ attributes [ 'name' ] ) ) { $ att... | Used to create attributes all input fields must have . |
5,060 | protected function _arrayToAttributesString ( array $ attributes ) { $ attributes_string = '' ; foreach ( $ attributes as $ key => $ value ) { $ attributes_string .= ' ' . $ key . '="' . $ this -> _escape ( $ value ) . '"' ; } return $ attributes_string ; } | Creates an attribute string from an associative array . |
5,061 | public static function toString ( $ value ) { if ( $ value == null ) { return null ; } $ reflection = new \ ReflectionClass ( static :: class ) ; $ values = $ reflection -> getConstants ( ) ; if ( static :: isValid ( $ value , $ reflection ) ) { $ constName = array_search ( $ value , $ values ) ; return static :: Wordi... | Return the String Key Value of the supplied const value |
5,062 | public static function toSelect ( $ selectedValue = null , array $ options = null ) { $ selectOptions = array ( ) ; $ selectOptions [ 'class' ] = $ options [ 'class' ] ?? "" ; $ selectOptions [ 'id' ] = $ options [ 'id' ] ?? "" ; $ selectOptions [ 'name' ] = $ options [ 'name' ] ?? "" ; $ reflection = new \ ReflectionC... | Generate an HTML Select input for this Enum type if selected value is supplied it will be selected . |
5,063 | public function onException ( FilterExceptionEvent $ event ) { static $ handling ; if ( true === $ handling ) { return false ; } $ handling = true ; $ exception = $ event -> getException ( ) ; $ request = $ event -> getRequest ( ) ; $ request = $ this -> duplicateRequest ( $ exception , $ request ) ; try { $ response =... | Exception event handler . |
5,064 | protected function duplicateRequest ( \ Exception $ exception , Request $ request ) { $ attributes = [ '_controller' => $ this -> controller , 'exception' => $ exception , 'format' => $ request -> getRequestFormat ( ) ] ; $ request = $ request -> duplicate ( null , null , $ attributes ) ; $ request -> setMethod ( 'GET'... | Creates a request for the exception to the exception controller . |
5,065 | private function __getMethods ( $ object ) { $ reflection = new ReflectionClass ( $ object ) ; $ methods = $ reflection -> getMethods ( ) ; $ this -> builtInMethods = array ( ) ; if ( ! empty ( $ methods ) ) { foreach ( $ methods as $ method ) { if ( ! empty ( $ method -> name ) ) { $ methodProp = new ReflectionMethod ... | Analyzes self methods using reflection |
5,066 | private function __extractDocString ( $ DocComment , $ lines = null , $ parse_tags = false ) { $ split = preg_split ( "/\r\n|\n|\r/" , $ DocComment ) ; $ _tmp = array ( ) ; $ _l = 1 ; foreach ( $ split as $ id => $ row ) { $ _row = trim ( $ row , "* /\n\t\r" ) ; if ( ! empty ( $ _row ) AND $ _row [ 0 ] != '@' ) { $ _tm... | Manipulates a DocString and returns a readable string |
5,067 | public function generate ( ) : string { try { return DefuseKey :: createNewRandomKey ( ) -> saveToAsciiSafeString ( ) ; } catch ( EnvironmentIsBrokenException $ e ) { throw new CryptoException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Generates a new key |
5,068 | public function render ( ) { $ max_label_length = $ this -> max_label_length + 5 ; $ dashes = str_repeat ( '-' , $ max_label_length + 39 ) . "\n" ; $ margin = str_repeat ( ' ' , 2 ) ; $ header = sprintf ( "%s %-{$max_label_length}s %-12s %-12s %s\n" , $ margin , 'label' , 'time (ms)' , 'perc' , 'memory' ) ; $ body = ''... | Render as a string for the console . |
5,069 | protected function memoryToString ( $ mem ) { $ abs = abs ( $ mem ) ; if ( $ abs < 1024 ) { return "$mem Bytes" ; } elseif ( $ abs < 1048576 ) { return round ( $ mem / 1024 , 2 ) . " KB" ; } else { return round ( $ mem / 1048576 , 2 ) . " MB" ; } } | Convert memory to a human readable string for the console . |
5,070 | private function isEmpty ( $ table ) { $ table = $ this -> db -> quoteName ( $ table ) ; return $ this -> db -> scalar ( "SELECT COUNT(*) FROM {$table}" ) == 0 ; } | Determine if the table is empty . |
5,071 | protected function assertLabel ( $ label ) { $ utf8 = mb_convert_encoding ( $ label , 'UTF-8' , 'auto' ) ; if ( ! preg_match_all ( static :: STRICT_LABEL_PATTERN , $ utf8 , $ matches ) ) { $ message = sprintf ( 'Could not serialize LTSV label = %s. It contains an illegal character.' , $ label ) ; throw new \ RuntimeExc... | Assert that label is strictly valid . |
5,072 | protected function assertValue ( $ value ) { $ utf8 = mb_convert_encoding ( $ value , 'UTF-8' , 'auto' ) ; if ( ! preg_match_all ( static :: STRICT_VALUE_PATTERN , $ utf8 , $ matches ) ) { $ message = sprintf ( 'Could not serialize LTSV value = %s. It contains an illegal character.' , $ value ) ; throw new \ RuntimeExc... | Assert that value is strictly valid . |
5,073 | protected function formatMessage ( $ query , $ previous ) { $ response = $ previous -> getResponse ( ) ; return 'Request returned with [' . $ response -> getReasonPhrase ( ) . '] (' . $ response -> getEffectiveUrl ( ) . ')' ; } | Format the request error message . |
5,074 | public static function niceShort ( $ dateString = null ) { $ date = ( $ dateString == null ) ? time ( ) : strtotime ( $ dateString ) ; $ y = ( self :: isThisYear ( $ date ) ) ? '' : ' Y' ; if ( self :: isToday ( $ date ) ) { $ ret = sprintf ( 'Today, %s' , date ( "g:i a" , $ date ) ) ; } elseif ( self :: wasYesterday (... | Returns a formatted descriptive date string for given datetime string . |
5,075 | public static function Rxp ( array $ r , array $ p , array & $ rp ) { $ w ; $ wrp = [ ] ; $ i ; $ j ; for ( $ j = 0 ; $ j < 3 ; $ j ++ ) { $ w = 0.0 ; for ( $ i = 0 ; $ i < 3 ; $ i ++ ) { $ w += $ r [ $ j ] [ $ i ] * $ p [ $ i ] ; } $ wrp [ $ j ] = $ w ; } IAU :: Cp ( $ wrp , $ rp ) ; return ; } | - - - - - - - i a u R x p - - - - - - - |
5,076 | public function get ( $ key = null , $ defaultValue = null ) { $ conditions = compact ( 'key' ) ; if ( $ key === null ) { return $ this -> find ( 'all' , $ conditions ) ; } else { $ value = $ this -> field ( 'value' , $ conditions ) ; return $ this -> find ( 'count' , array ( 'conditions' => $ conditions ) ) ? $ value ... | Return variable value from storage . If variable not exists return default value |
5,077 | public function increaseBy ( $ key , $ value ) { $ valueOld = $ this -> get ( $ key , 0 ) ; if ( is_numeric ( $ value ) && is_numeric ( $ valueOld ) ) { $ this -> add ( $ key , $ value + $ valueOld ) ; return $ value + $ valueOld ; } } | Increase numeric variable value . If variable not found creates it with initial value - zero |
5,078 | public function parse ( ) { try { $ this -> ensureFileIsReadable ( ) ; } catch ( InvalidPathException $ e ) { return [ ] ; } $ filePath = $ this -> filePath ; $ lines = $ this -> readLinesFromFile ( $ filePath ) ; $ data = [ ] ; foreach ( $ lines as $ line ) { if ( ! $ this -> isComment ( $ line ) && $ this -> looksLik... | Load the environment if we need to or can . |
5,079 | public function gender ( $ short = true ) { $ gender = 'Male' ; foreach ( $ this -> female as $ female ) { if ( strpos ( $ this -> last , $ female ) !== false ) { $ gender = 'Female' ; break ; } } if ( $ gender != 'Female' ) { foreach ( array ( 'Hajah' , 'Hajjah' , 'Hjh.' , 'Puan' , 'Pn.' , 'Cik' ) as $ female ) { if (... | Get the gender from full name . Gender are check from their middle name salutation and collection of female name . |
5,080 | private function parser ( ) { $ full_name = $ this -> name ; $ full_name = trim ( str_replace ( ' ' , ' ' , $ full_name ) ) ; $ full_name = htmlspecialchars_decode ( htmlspecialchars ( $ full_name , ENT_QUOTES ) ) ; $ full_name = strtolower ( $ full_name ) ; foreach ( $ this -> salutations as $ salute ) { if ( strpos ... | Parsing complex Malay names into their individual components |
5,081 | private function addSalutation ( $ salute ) { if ( is_array ( $ salute ) ) { foreach ( $ salute as $ tabik ) { $ this -> salutations [ ] = htmlspecialchars ( $ tabik , ENT_QUOTES ) ; } } else { $ this -> salutations [ ] = htmlspecialchars ( $ salute , ENT_QUOTES ) ; } } | Adds an salutation element at the end of the collection . |
5,082 | private function addMiddle ( $ middle ) { if ( is_array ( $ middle ) ) { foreach ( $ middle as $ mid ) { $ this -> middles [ ] = $ mid ; } } else { $ this -> middles [ ] = $ middle ; } } | Adds an middle element at the end of the collection . |
5,083 | public function safe_ucfirst ( $ separator , $ word ) { $ parts = explode ( $ separator , $ word ) ; foreach ( $ parts as $ word ) { $ words [ ] = ( $ this -> is_camel_case ( $ word ) ) ? $ word : ucfirst ( strtolower ( $ word ) ) ; } return implode ( $ separator , $ words ) ; } | helper public function for fix_case |
5,084 | public function contactableAttendees ( ) { $ attendees = $ this -> Attendees ( ) ; foreach ( $ this -> stat ( "registrant_fields" ) as $ field ) { $ attendees = $ attendees -> where ( "\"" . $ field . "\" IS NOT NULL" ) ; } return $ attendees ; } | Get attendees that have populated registrant details . |
5,085 | public function getMainContactField ( $ forcedropdown = false ) { $ attendees = $ this -> contactableAttendees ( ) ; if ( $ attendees -> count ( ) === 1 && ! $ forcedropdown ) { return HiddenField :: create ( "RegistrantAttendeeID" ) -> setValue ( $ attendees -> first ( ) -> ID ) ; } $ source = $ attendees -> map ( ) -... | Field for capturing which attendee is the main contact |
5,086 | public function getRegistrantContactFieldsGroup ( ) { $ fieldNames = array_unique ( $ this -> stat ( 'registrant_fields' ) ) ; $ fields = FieldList :: create ( ) ; if ( $ fieldNames ) { $ scaffolded = $ this -> scaffoldFormFields ( array ( 'restrictFields' => $ fieldNames , 'fieldClasses' => array ( 'Email' => 'EmailFi... | Fields for capturing details of person doing registration . |
5,087 | public function getTicketQuantities ( ) { $ quantities = array ( ) ; foreach ( $ this -> Tickets ( ) as $ ticket ) { $ quantities [ $ ticket -> ID ] = $ this -> Attendees ( ) -> filter ( "TicketID" , $ ticket -> ID ) -> count ( ) ; } return $ quantities ; } | Get an array of ticketid = > quantity |
5,088 | public function createAttendee ( EventTicket $ ticket ) { $ attendee = new EventAttendee ( ) ; $ attendee -> TicketID = $ ticket -> ID ; $ attendee -> write ( ) ; $ this -> Attendees ( ) -> add ( $ attendee ) ; return $ attendee ; } | Create an attendee in this registration with the given ticket . |
5,089 | public function getDescription ( ) { $ parts = array ( ) ; foreach ( $ this -> getTicketQuantities ( ) as $ ticketid => $ quantity ) { if ( $ ticket = EventTicket :: get ( ) -> byID ( $ ticketid ) ) { $ parts [ ] = $ quantity . "x" . $ ticket -> Title ; } } return $ this -> Event ( ) -> Title . ": " . implode ( "," , $... | Generate a desicrption of the tickets in the registration |
5,090 | public function getLogger ( ) { if ( $ this -> logger ) { return $ this -> logger ; } $ this -> setLogger ( CoreLib \ getLogger ( ) ) ; return $ this -> logger ; } | Provides a single instance of a configured Logger to all extenders of CoreObject |
5,091 | public function numberFormat ( ) { $ num = ( float ) ( ( string ) $ this -> getRequiredParameter ( 'number' ) ) ; $ decimals = intval ( ( string ) $ this -> getParameter ( 'decimals' ) ) ; return number_format ( $ num , $ decimals ) ; } | Formats a number using php builtin number_format |
5,092 | public function stringArrayToJson ( ) { $ value = $ this -> getParameter ( 'value' ) ; if ( ! is_array ( $ value ) ) { $ value = explode ( $ this -> getParameter ( 'delimiter' , ',' ) , $ value ) ; } $ value = array_map ( 'trim' , $ value ) ; if ( empty ( $ value ) ) { return '[]' ; } $ value = array_filter ( $ value ,... | Returns a string array to json and removes empty items . |
5,093 | public function stringArrayToCsv ( ) { $ value = $ this -> getParameter ( 'value' ) ; if ( ! is_array ( $ value ) ) { $ value = explode ( $ this -> getParameter ( 'delimiter' , ',' ) , $ value ) ; } $ value = array_map ( 'trim' , $ value ) ; if ( empty ( $ value ) ) { return '' ; } $ value = array_filter ( $ value , 's... | Returns a string array to csv and removes empty items . |
5,094 | public function editAction ( Request $ request , Advert $ advert ) { $ deleteForm = $ this -> createDeleteForm ( $ advert ) ; $ editForm = $ this -> createEditForm ( $ advert ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ em = $ this -> getDoctrine ... | Displays a form to edit an existing Advert entity . |
5,095 | private function createEditForm ( Advert $ entity ) { $ formConfig = array ( ) ; $ user = $ this -> container -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; if ( $ user -> isGranted ( 'ROLE_ADMIN' ) || $ user -> isGranted ( 'ROLE_SUPER_ADMIN' ) ) { $ formConfig [ 'admin' ] = true ; } $ form = $ th... | Creates a form to edit a Advert entity . |
5,096 | public function deleteAction ( Request $ request , Advert $ advert ) { $ form = $ this -> createDeleteForm ( $ advert ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ purchases = $ em -> getRepository ( 'Ecomme... | Deletes a Category entity . |
5,097 | private function createDeleteForm ( Advert $ advert ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'ecommerce_advert_delete' , array ( 'id' => $ advert -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a Advert entity . |
5,098 | public static function createConnectionUsingPHPAMQPLib ( AMQPServerConfigurationInterface $ config , $ sslCAPath = null , $ sslHost = null ) { if ( $ config -> getSSL ( ) === true ) { $ sslOptions = [ 'verify_peer' => true , ] ; if ( $ sslCAPath !== null ) { $ sslOptions [ 'capath' ] = $ sslCAPath ; } if ( $ sslHost !=... | Create a connection using PHPAMQPLib . |
5,099 | public function getRoadMap ( ) { $ road_map = new RoadMap ( ) ; $ road_map -> append ( new LessRoad ( "LESSCSS" , $ this -> generateCacheDir ( $ this -> getProjectRootDir ( ) ) ) ) ; $ road_map -> append ( new SourceRoad ( "ROOT" , $ this -> generateCacheDir ( $ this -> getProjectRootDir ( ) ) ) ) ; $ road_map -> appen... | Returns the roadmap for this project . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.