idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
58,100 | public function decryptStringResponseWithSharedKey ( ResponseInterface $ response , SharedEncryptionKey $ key ) : string { return Simple :: decrypt ( ( string ) $ response -> getBody ( ) , $ key ) ; } | Decrypt an HTTP response with a pre - shared key then get the body as a string . |
58,101 | public function createSymmetricAuthenticatedJsonRequest ( string $ method , string $ uri , array $ arrayToJsonify , SharedAuthenticationKey $ key , array $ headers = [ ] ) : RequestInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new... | Create an HTTP request object with a JSON body that is authenticated with a pre - shared key . The authentication tag is stored in a Body - HMAC - SHA512256 header . |
58,102 | public function createSymmetricAuthenticatedJsonResponse ( int $ status , array $ arrayToJsonify , SharedAuthenticationKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) ... | Create an HTTP response object with a JSON body that is authenticated with a pre - shared key . The authentication tag is stored in a Body - HMAC - SHA512256 header . |
58,103 | public function createSymmetricEncryptedJsonRequest ( string $ method , string $ uri , array $ arrayToJsonify , SharedEncryptionKey $ key , array $ headers = [ ] ) : RequestInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new Invalid... | Create an HTTP request object with a JSON body that is encrypted with a pre - shared key . |
58,104 | public function createSymmetricEncryptedJsonResponse ( int $ status , array $ arrayToJsonify , SharedEncryptionKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw ... | Create an HTTP response object with a JSON body that is encrypted with a pre - shared key . |
58,105 | public function createSealedJsonRequest ( string $ method , string $ uri , array $ arrayToJsonify , SealingPublicKey $ key , array $ headers = [ ] ) : RequestInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new InvalidMessageExceptio... | Create an HTTP request object with a JSON body that is encrypted with the server s public key . |
58,106 | public function createSealedJsonResponse ( int $ status , array $ arrayToJsonify , SealingPublicKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new InvalidMess... | Create an HTTP response object with a JSON body that is encrypted with the server s public key . |
58,107 | public function createSignedJsonRequest ( string $ method , string $ uri , array $ arrayToJsonify , SigningSecretKey $ key , array $ headers = [ ] ) : RequestInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new InvalidMessageExceptio... | Creates a JSON - signed API request to be sent to an API . Enforces hard - coded Ed25519 keys . |
58,108 | public function createSignedJsonResponse ( int $ status , array $ arrayToJsonify , SigningSecretKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { list ( $ body , $ headers ) = $ this -> makeJSON ( $ arrayToJsonify , $ headers ) ; if ( ! \ is_string ( $ body ) ) { throw new InvalidMess... | Creates a JSON - signed API response to be returned from an API . Enforces hard - coded Ed25519 keys . |
58,109 | public function createSymmetricAuthenticatedRequest ( string $ method , string $ uri , string $ body , SharedAuthenticationKey $ key , array $ headers = [ ] ) : RequestInterface { $ mac = \ ParagonIE_Sodium_Compat :: crypto_auth ( $ body , $ key -> getString ( true ) ) ; if ( isset ( $ headers [ Sapient :: HEADER_SIGNA... | Authenticate your HTTP request with a pre - shared key . |
58,110 | public function createSymmetricAuthenticatedResponse ( int $ status , string $ body , SharedAuthenticationKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { $ mac = \ ParagonIE_Sodium_Compat :: crypto_auth ( $ body , $ key -> getString ( true ) ) ; if ( isset ( $ headers [ Sapient :: H... | Authenticate your HTTP response with a pre - shared key . |
58,111 | public function createSymmetricEncryptedRequest ( string $ method , string $ uri , string $ body , SharedEncryptionKey $ key , array $ headers = [ ] ) : RequestInterface { return new Request ( $ method , $ uri , $ headers , Base64UrlSafe :: encode ( Simple :: encrypt ( $ body , $ key ) ) ) ; } | Encrypt your HTTP request with a pre - shared key . |
58,112 | public function createSymmetricEncryptedResponse ( int $ status , string $ body , SharedEncryptionKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { return new Response ( $ status , $ headers , Base64UrlSafe :: encode ( Simple :: encrypt ( $ body , $ key ) ) , $ version ) ; } | Encrypt your HTTP response with a pre - shared key . |
58,113 | public function createSealedRequest ( string $ method , string $ uri , string $ body , SealingPublicKey $ key , array $ headers = [ ] ) : RequestInterface { $ sealed = Simple :: seal ( $ body , $ key ) ; return new Request ( $ method , $ uri , $ headers , Base64UrlSafe :: encode ( $ sealed ) ) ; } | Encrypt your HTTP request with the server s public key so that only the server can decrypt the message . |
58,114 | public function createSealedResponse ( int $ status , string $ body , SealingPublicKey $ key , array $ headers = [ ] , string $ version = '1.1' ) : ResponseInterface { $ sealed = Simple :: seal ( $ body , $ key ) ; return new Response ( $ status , $ headers , Base64UrlSafe :: encode ( $ sealed ) , $ version ) ; } | Encrypt your HTTP response with the client s public key so that only the client can decrypt the message . |
58,115 | public function stringToStream ( string $ input ) : StreamInterface { $ stream = stream_for ( $ input ) ; if ( ! ( $ stream instanceof StreamInterface ) ) { throw new \ TypeError ( 'Could not convert string to a stream' ) ; } return $ stream ; } | Adapter - specific way of converting a string into a StreamInterface |
58,116 | protected function makeJSON ( array $ arrayToJsonify , array $ headers ) : array { if ( empty ( $ headers [ 'Content-Type' ] ) ) { $ headers [ 'Content-Type' ] = 'application/json' ; } $ body = \ json_encode ( $ arrayToJsonify , JSON_PRETTY_PRINT ) ; return [ $ body , $ headers ] ; } | JSON encode body add Content - Type header . |
58,117 | public function eof ( ) { if ( ! \ is_resource ( $ this -> stream ) ) { throw new \ TypeError ( ) ; } return $ this -> isAttached ( ) ? \ feof ( $ this -> stream ) : true ; } | Returns true if the stream is at the end of the stream . |
58,118 | public static function fromString ( string $ input ) : StreamInterface { $ stream = \ fopen ( 'php://temp' , 'w+' ) ; if ( ! \ is_resource ( $ stream ) ) { throw new \ Error ( 'Could not create stream' ) ; } \ fwrite ( $ stream , $ input ) ; \ rewind ( $ stream ) ; return new static ( $ stream ) ; } | Create a Stream object from a string . |
58,119 | public static function encrypt ( string $ plaintext , SharedEncryptionKey $ key ) : string { $ nonce = random_bytes ( \ ParagonIE_Sodium_Compat :: CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES ) ; return $ nonce . \ ParagonIE_Sodium_Compat :: crypto_aead_xchacha20poly1305_ietf_encrypt ( $ plaintext , $ nonce , $ nonce ,... | Simple authenticated encryption XChaCha20 - Poly1305 |
58,120 | public static function decrypt ( string $ ciphertext , SharedEncryptionKey $ key ) : string { $ nonce = \ ParagonIE_Sodium_Core_Util :: substr ( $ ciphertext , 0 , 24 ) ; $ result = \ ParagonIE_Sodium_Compat :: crypto_aead_xchacha20poly1305_ietf_decrypt ( \ ParagonIE_Sodium_Core_Util :: substr ( $ ciphertext , 24 ) , $... | Simple authenticated decryption XChaCha20 - Poly1305 |
58,121 | public static function seal ( string $ plaintext , SealingPublicKey $ publicKey ) : string { $ ephemeralSecret = SealingSecretKey :: generate ( ) ; $ sharedSecret = static :: keyExchange ( $ ephemeralSecret , $ publicKey , false , 56 ) ; $ ephemeralPublicKey = $ ephemeralSecret -> getPublickey ( ) -> getString ( true )... | Encrypt a message with a public key so that it can only be decrypted with the corresponding secret key . |
58,122 | public static function unseal ( string $ ciphertext , SealingSecretKey $ secretKey ) : string { $ ephemeralPublicKey = \ ParagonIE_Sodium_Core_Util :: substr ( $ ciphertext , 0 , 32 ) ; $ sharedSecret = static :: keyExchange ( $ secretKey , new SealingPublicKey ( $ ephemeralPublicKey ) , true , 56 ) ; $ sharedKey = \ P... | Decrypt a message with your secret key . |
58,123 | public function authenticateRequestWithSharedKey ( RequestInterface $ request , SharedAuthenticationKey $ key ) : RequestInterface { $ mac = \ ParagonIE_Sodium_Compat :: crypto_auth ( ( string ) $ request -> getBody ( ) , $ key -> getString ( true ) ) ; return $ request -> withAddedHeader ( self :: HEADER_AUTH_NAME , B... | Authenticate an HTTP request with a pre - shared key . |
58,124 | public function authenticateResponseWithSharedKey ( ResponseInterface $ response , SharedAuthenticationKey $ key ) : ResponseInterface { $ mac = \ ParagonIE_Sodium_Compat :: crypto_auth ( ( string ) $ response -> getBody ( ) , $ key -> getString ( true ) ) ; return $ response -> withAddedHeader ( self :: HEADER_AUTH_NA... | Authenticate an HTTP response with a pre - shared key . |
58,125 | public function decryptRequestWithSharedKey ( RequestInterface $ request , SharedEncryptionKey $ key ) : RequestInterface { $ encrypted = Base64UrlSafe :: decode ( ( string ) $ request -> getBody ( ) ) ; return $ request -> withBody ( $ this -> adapter -> stringToStream ( Simple :: decrypt ( $ encrypted , $ key ) ) ) ;... | Decrypt an HTTP request with a pre - shared key . |
58,126 | public function decryptResponseWithSharedKey ( ResponseInterface $ response , SharedEncryptionKey $ key ) : ResponseInterface { $ encrypted = Base64UrlSafe :: decode ( ( string ) $ response -> getBody ( ) ) ; return $ response -> withBody ( $ this -> adapter -> stringToStream ( Simple :: decrypt ( $ encrypted , $ key )... | Decrypt an HTTP response with a pre - shared key . |
58,127 | public function encryptRequestWithSharedKey ( RequestInterface $ request , SharedEncryptionKey $ key ) : RequestInterface { $ encrypted = Base64UrlSafe :: encode ( Simple :: encrypt ( ( string ) $ request -> getBody ( ) , $ key ) ) ; return $ request -> withBody ( $ this -> adapter -> stringToStream ( $ encrypted ) ) ;... | Encrypt an HTTP request with a pre - shared key . |
58,128 | public function encryptResponseWithSharedKey ( ResponseInterface $ response , SharedEncryptionKey $ key ) : ResponseInterface { $ encrypted = Base64UrlSafe :: encode ( Simple :: encrypt ( ( string ) $ response -> getBody ( ) , $ key ) ) ; return $ response -> withBody ( $ this -> adapter -> stringToStream ( $ encrypted... | Encrypt an HTTP response with a pre - shared key . |
58,129 | public function sealRequest ( RequestInterface $ request , SealingPublicKey $ publicKey ) : RequestInterface { $ sealed = Simple :: seal ( ( string ) $ request -> getBody ( ) , $ publicKey ) ; return $ request -> withBody ( $ this -> adapter -> stringToStream ( Base64UrlSafe :: encode ( $ sealed ) ) ) ; } | Encrypt an HTTP request body with a public key . |
58,130 | public function sealResponse ( ResponseInterface $ response , SealingPublicKey $ publicKey ) : ResponseInterface { $ sealed = Simple :: seal ( ( string ) $ response -> getBody ( ) , $ publicKey ) ; return $ response -> withBody ( $ this -> adapter -> stringToStream ( Base64UrlSafe :: encode ( $ sealed ) ) ) ; } | Encrypt an HTTP response body with a public key . |
58,131 | public function signRequest ( RequestInterface $ request , SigningSecretKey $ secretKey ) : RequestInterface { $ signature = \ ParagonIE_Sodium_Compat :: crypto_sign_detached ( ( string ) $ request -> getBody ( ) , $ secretKey -> getString ( true ) ) ; return $ request -> withAddedHeader ( ( string ) static :: HEADER_S... | Add an Ed25519 signature to an HTTP request object . |
58,132 | public function signResponse ( ResponseInterface $ response , SigningSecretKey $ secretKey ) : ResponseInterface { $ signature = \ ParagonIE_Sodium_Compat :: crypto_sign_detached ( ( string ) $ response -> getBody ( ) , $ secretKey -> getString ( true ) ) ; return $ response -> withAddedHeader ( ( string ) static :: HE... | Add an Ed25519 signature to an HTTP response object . |
58,133 | public function verifySignedRequest ( RequestInterface $ request , SigningPublicKey $ publicKey ) : RequestInterface { $ headers = $ request -> getHeader ( ( string ) static :: HEADER_SIGNATURE_NAME ) ; if ( ! $ headers ) { throw new HeaderMissingException ( 'No signed request header (' . ( string ) static :: HEADER_SI... | Verifies the signature contained in the Body - Signature - Ed25519 header is valid for the HTTP Request body provided . Will either return the request given or throw an InvalidMessageException if the signature is invalid . Will also throw a HeaderMissingException is there is no Body - Signature - Ed25519 header . |
58,134 | public function verifySignedResponse ( ResponseInterface $ response , SigningPublicKey $ publicKey ) : ResponseInterface { $ headers = $ response -> getHeader ( ( string ) static :: HEADER_SIGNATURE_NAME ) ; if ( ! $ headers ) { throw new HeaderMissingException ( 'No signed response header (' . ( string ) static :: HEA... | Verifies the signature contained in the Body - Signature - Ed25519 header is valid for the HTTP Response body provided . Will either return the response given or throw an InvalidMessageException if the signature is invalid . Will also throw a HeaderMissingException is there is no Body - Signature - Ed25519 header . |
58,135 | public function verifySymmetricAuthenticatedRequest ( RequestInterface $ request , SharedAuthenticationKey $ key ) : RequestInterface { $ headers = $ request -> getHeader ( ( string ) static :: HEADER_AUTH_NAME ) ; if ( ! $ headers ) { throw new HeaderMissingException ( 'No signed request header (' . ( string ) static ... | Verify that the Body - HMAC - SHA512256 header correctly authenticates the HTTP Request . Will either return the request given or throw an InvalidMessageException if the signature is invalid . Will also throw a HeaderMissingException is there is no Body - HMAC - SHA512256 header . |
58,136 | public function verifySymmetricAuthenticatedResponse ( ResponseInterface $ response , SharedAuthenticationKey $ key ) : ResponseInterface { $ headers = $ response -> getHeader ( ( string ) static :: HEADER_SIGNATURE_NAME ) ; if ( ! $ headers ) { throw new HeaderMissingException ( 'No signed response header (' . ( strin... | Verify that the Body - HMAC - SHA512256 header correctly authenticates the HTTP Response . Will either return the response given or throw an InvalidMessageException if the signature is invalid . Will also throw a HeaderMissingException is there is no Body - HMAC - SHA512256 header . |
58,137 | protected function addDoctrineTypes ( Connection $ connection ) { $ name = $ connection -> getDriverName ( ) ; foreach ( array_get ( $ this -> types , $ name , [ ] ) as $ type => $ handler ) { if ( ! Type :: hasType ( $ type ) ) { Type :: addType ( $ type , $ handler ) ; } $ connection -> getDoctrineConnection ( ) -> g... | Add Doctrine types for the connection . |
58,138 | protected function getPortableTableEnumColumnDefinition ( array $ tableColumn ) { $ tableColumn = array_change_key_case ( $ tableColumn , CASE_LOWER ) ; $ dbType = strtolower ( $ tableColumn [ 'type' ] ) ; $ dbType = strtok ( $ dbType , '(), ' ) ; $ type = $ this -> _platform -> getDoctrineTypeMapping ( $ dbType ) ; if... | Gets Table Column Definition for Enum Column Type . |
58,139 | protected function getEnumOptions ( $ tableColumn ) { $ type = $ tableColumn [ 'type' ] ; if ( starts_with ( $ type , 'enum(' ) && ends_with ( $ type , ')' ) ) { return explode ( "','" , trim ( substr ( $ type , strlen ( 'enum(' ) , - 1 ) , "'" ) ) ; } return [ ] ; } | Get enum options from the column . |
58,140 | public function getRequiredFields ( ) { $ requiredNames = $ this -> getController ( ) -> data ( ) -> Fields ( ) -> filter ( 'Required' , true ) -> column ( 'Name' ) ; $ requiredNames = array_merge ( $ requiredNames , $ this -> getEmailRecipientRequiredFields ( ) ) ; $ required = new RequiredFields ( $ requiredNames ) ;... | Get the required form fields for this form . |
58,141 | public function getAttributes ( ) { $ attrs = parent :: getAttributes ( ) ; $ attrs [ 'class' ] = $ attrs [ 'class' ] . ' userform' ; $ attrs [ 'data-livevalidation' ] = ( bool ) $ this -> controller -> EnableLiveValidation ; $ attrs [ 'data-toperrors' ] = ( bool ) $ this -> controller -> DisplayErrorMessagesAtTop ; re... | Override some we can add UserForm specific attributes to the form . |
58,142 | protected function getEmailRecipientRequiredFields ( ) { $ requiredFields = [ ] ; $ recipientFieldsMap = [ 'EmailAddress' => 'SendEmailToField' , 'EmailSubject' => 'SendEmailSubjectField' , 'EmailReplyTo' => 'SendEmailFromField' ] ; foreach ( $ this -> getController ( ) -> data ( ) -> EmailRecipients ( ) as $ recipient... | Push fields into the RequiredFields array if they are used by any Email recipients . Ignore if there is a backup i . e . the plain string field is set |
58,143 | public function clearEmptySteps ( ) { foreach ( $ this as $ field ) { if ( $ field instanceof UserFormsStepField && count ( $ field -> getChildren ( ) ) === 0 ) { $ this -> remove ( $ field ) ; } } } | Remove all empty steps |
58,144 | public function duplicate ( $ doWrite = true , $ manyMany = 'many_many' ) { if ( $ manyMany === 'many_many' && ! $ this -> manyMany ( ) ) { $ manyMany = null ; } $ clonedNode = parent :: duplicate ( true , $ manyMany ) ; foreach ( $ this -> Options ( ) as $ field ) { $ newField = $ field -> duplicate ( false ) ; $ newF... | Duplicate a pages content . We need to make sure all the fields attached to that page go with it |
58,145 | protected function getOptionsMap ( ) { $ optionSet = $ this -> Options ( ) ; $ optionMap = $ optionSet -> map ( 'Value' , 'Title' ) ; if ( $ optionMap instanceof Map ) { return $ optionMap -> toArray ( ) ; } return $ optionMap ; } | Gets map of field options suitable for use in a form |
58,146 | protected function getCanCreateContext ( $ args ) { if ( isset ( $ args [ 1 ] [ 'Parent' ] ) ) { return $ args [ 1 ] [ 'Parent' ] ; } if ( Controller :: has_curr ( ) && Controller :: curr ( ) instanceof CMSMain ) { return Controller :: curr ( ) -> currentPage ( ) ; } return null ; } | Helper method to check the parent for this object |
58,147 | protected function getDisplayRuleFields ( ) { if ( $ this -> Required ) { return FieldList :: create ( LiteralField :: create ( 'DisplayRulesNotEnabled' , '<div class="alert alert-warning">' . _t ( __CLASS__ . '.DISPLAY_RULES_DISABLED' , 'Display rules are not enabled for required fields. Please uncheck "Is this field ... | Return fields to display on the Display Rules tab |
58,148 | protected function generateName ( ) { do { $ classNamePieces = explode ( '\\' , static :: class ) ; $ class = array_pop ( $ classNamePieces ) ; $ entropy = substr ( sha1 ( uniqid ( ) ) , 0 , 5 ) ; $ name = "{$class}_{$entropy}" ; $ exists = EditableFormField :: get ( ) -> filter ( 'Name' , $ name ) -> count ( ) > 0 ; }... | Generate a new non - conflicting Name value |
58,149 | public function canEdit ( $ member = null ) { $ parent = $ this -> Parent ( ) ; if ( $ parent && $ parent -> exists ( ) ) { return $ parent -> canEdit ( $ member ) && ! $ this -> isReadonly ( ) ; } elseif ( ! $ this -> exists ( ) && Controller :: has_curr ( ) ) { $ controller = Controller :: curr ( ) ; if ( $ controlle... | Return whether a user can edit this form field based on whether they can edit the page |
58,150 | public function canView ( $ member = null ) { $ parent = $ this -> Parent ( ) ; if ( $ parent && $ parent -> exists ( ) ) { return $ parent -> canView ( $ member ) ; } return true ; } | Return whether a user can view this form field based on whether they can view the page regardless of the ReadOnly status of the field |
58,151 | public function setAllowedCss ( array $ allowed ) { if ( is_array ( $ allowed ) ) { foreach ( $ allowed as $ k => $ v ) { self :: $ allowed_css [ $ k ] = ( ! is_null ( $ v ) ) ? $ v : $ k ; } } } | Set the allowed css classes for the extraClass custom setting |
58,152 | public function getIcon ( ) { $ classNamespaces = explode ( "\\" , static :: class ) ; $ shortClass = end ( $ classNamespaces ) ; $ resource = ModuleLoader :: getModule ( 'silverstripe/userforms' ) -> getResource ( 'images/' . strtolower ( $ shortClass ) . '.png' ) ; if ( ! $ resource -> exists ( ) ) { return '' ; } re... | Get the path to the icon for this field type relative to the site root . |
58,153 | public function getFieldValidationOptions ( ) { $ fields = new FieldList ( CheckboxField :: create ( 'Required' , _t ( __CLASS__ . '.REQUIRED' , 'Is this field Required?' ) ) -> setDescription ( _t ( __CLASS__ . '.REQUIRED_DESCRIPTION' , 'Please note that conditional fields can\'t be required' ) ) , TextField :: create... | Append custom validation fields to the default Validation section in the editable options view |
58,154 | public function doUpdateFormField ( $ field ) { $ this -> extend ( 'beforeUpdateFormField' , $ field ) ; $ this -> updateFormField ( $ field ) ; $ this -> extend ( 'afterUpdateFormField' , $ field ) ; } | Updates a formfield with extensions |
58,155 | public function getInlineTitleField ( $ column ) { return TextField :: create ( $ column , false ) -> setAttribute ( 'placeholder' , _t ( __CLASS__ . '.TITLE' , 'Title' ) ) -> setAttribute ( 'data-placeholder' , _t ( __CLASS__ . '.TITLE' , 'Title' ) ) ; } | Get the formfield to use when editing the title inline |
58,156 | public function getEditableFieldClasses ( $ includeLiterals = true ) { $ classes = ClassInfo :: getValidSubClasses ( EditableFormField :: class ) ; $ editableFieldClasses = [ ] ; foreach ( $ classes as $ class ) { if ( Config :: inst ( ) -> get ( $ class , 'abstract' , Config :: UNINHERITED ) || Config :: inst ( ) -> g... | Get the list of classes that can be selected and used as data - values |
58,157 | public function formatDisplayRules ( ) { $ holderSelector = $ this -> getSelectorOnly ( ) ; $ result = [ 'targetFieldID' => $ holderSelector , 'conjunction' => $ this -> DisplayRulesConjunctionNice ( ) , 'selectors' => [ ] , 'events' => [ ] , 'operations' => [ ] , 'initialState' => $ this -> ShowOnLoadNice ( ) , 'view'... | Extracts info from DisplayRules into array so UserDefinedForm - > buildWatchJS can run through it . |
58,158 | protected function getFormParent ( ) { if ( $ this -> FormID && $ this -> FormClass ) { $ formClass = $ this -> FormClass ; return $ formClass :: get ( ) -> byID ( $ this -> FormID ) ; } $ sessionNamespace = $ this -> config ( ) -> get ( 'session_namespace' ) ? : CMSMain :: class ; $ formID = Controller :: curr ( ) -> ... | Get instance of UserForm when editing in getCMSFields |
58,159 | protected function getRulesConfig ( ) { if ( ! $ this -> getFormParent ( ) ) { return null ; } $ formFields = $ this -> getFormParent ( ) -> Fields ( ) ; $ config = GridFieldConfig :: create ( ) -> addComponents ( new GridFieldButtonRow ( 'before' ) , new GridFieldToolbarHeader ( ) , new GridFieldAddNewInlineButton ( )... | Generate a gridfield config for editing filter rules |
58,160 | public function canSend ( $ data , $ form ) { $ customRules = $ this -> CustomRules ( ) ; if ( ! $ customRules -> count ( ) ) { return true ; } $ isAnd = $ this -> CustomRulesCondition === 'And' ; foreach ( $ customRules as $ customRule ) { $ matches = $ customRule -> matches ( $ data ) ; if ( $ isAnd && ! $ matches ) ... | Determine if this recipient may receive notifications for this submission |
58,161 | public function emailTemplateExists ( $ template = '' ) { $ t = ( $ template ? $ template : $ this -> EmailTemplate ) ; return array_key_exists ( $ t , ( array ) $ this -> getEmailTemplateDropdownValues ( ) ) ; } | Make sure the email template saved against the recipient exists on the file system . |
58,162 | public function getEmailBodyContent ( ) { if ( $ this -> SendPlain ) { return DBField :: create_field ( 'HTMLText' , $ this -> EmailBody ) -> Plain ( ) ; } return DBField :: create_field ( 'HTMLText' , $ this -> EmailBodyHtml ) ; } | Get the email body for the current email format |
58,163 | public function getEmailTemplateDropdownValues ( ) { $ templates = [ ] ; $ finder = new FileFinder ( ) ; $ finder -> setOption ( 'name_regex' , '/^.*\.ss$/' ) ; $ parent = $ this -> getFormParent ( ) ; if ( ! $ parent ) { return [ ] ; } $ emailTemplateDirectory = $ parent -> config ( ) -> get ( 'email_template_director... | Gets a list of email templates suitable for populating the email template dropdown . |
58,164 | public function validate ( ) { $ result = parent :: validate ( ) ; $ checkEmail = [ 'EmailAddress' => 'EMAILADDRESSINVALID' , 'EmailFrom' => 'EMAILFROMINVALID' , 'EmailReplyTo' => 'EMAILREPLYTOINVALID' , ] ; foreach ( $ checkEmail as $ check => $ translation ) { if ( $ this -> $ check ) { $ addresses = explode ( ',' , ... | Validate that valid email addresses are being used |
58,165 | protected function sanitiseContent ( $ content ) { if ( ! HTMLEditorField :: config ( ) -> get ( 'sanitise_server_side' ) ) { return $ content ; } $ htmlValue = Injector :: inst ( ) -> create ( 'HTMLValue' , $ content ) ; $ santiser = Injector :: inst ( ) -> create ( HTMLEditorSanitiser :: class , $ this -> getEditorCo... | Safely sanitise html content if enabled |
58,166 | public function getFormField ( ) { $ defaultValue = $ this -> DefaultToToday ? DBDatetime :: now ( ) -> Format ( 'yyyy-MM-dd' ) : $ this -> Default ; $ field = FormField :: create ( $ this -> Name , $ this -> Title ? : false , $ defaultValue ) -> setFieldHolderTemplate ( EditableFormField :: class . '_holder' ) -> setT... | Return the form field |
58,167 | public function getOptions ( ) { $ options = parent :: getOptions ( ) ; foreach ( $ options as $ option ) { $ option -> Name = "{$this->name}[]" ; } return $ options ; } | jQuery validate requires that the value of the option does not contain the actual value of the input . |
58,168 | public function getClassesCreate ( $ grid ) { $ classes = $ this -> getClasses ( ) ; if ( empty ( $ classes ) && $ grid ) { $ classes = array ( $ grid -> getModelClass ( ) ) ; } return array_filter ( $ classes , function ( $ class ) { return singleton ( $ class ) -> canCreate ( ) ; } ) ; } | Gets the list of classes which can be created with checks for permissions . Will fallback to the default model class for the given DataGrid |
58,169 | public function setClasses ( $ classes ) { if ( ! is_array ( $ classes ) ) { $ classes = $ classes ? array ( $ classes ) : array ( ) ; } $ this -> modelClasses = $ classes ; } | Specify the classes to create |
58,170 | public function run ( $ request ) { $ schema = DataObject :: getSchema ( ) ; foreach ( $ this -> tables as $ db ) { $ columns = $ schema -> databaseFields ( $ db ) ; $ query = "SHOW COLUMNS FROM $db" ; $ liveColumns = DB :: query ( $ query ) -> column ( ) ; $ backedUp = 0 ; $ query = "SHOW TABLES LIKE 'Backup_$db'" ; $... | Publish the existing forms . |
58,171 | protected function onBeforeDelete ( ) { if ( $ this -> Values ( ) ) { foreach ( $ this -> Values ( ) as $ value ) { $ value -> delete ( ) ; } } parent :: onBeforeDelete ( ) ; } | Before we delete this form make sure we delete all the field values so that we don t leave old data round . |
58,172 | public function updateCMSFields ( FieldList $ fields ) { $ fieldEditor = $ this -> getFieldEditorGrid ( ) ; $ fields -> insertAfter ( new Tab ( 'FormFields' , _t ( __CLASS__ . '.FORMFIELDS' , 'Form Fields' ) ) , 'Main' ) ; $ fields -> addFieldToTab ( 'Root.FormFields' , $ fieldEditor ) ; return $ fields ; } | Adds the field editor to the page . |
58,173 | public function getFieldEditorGrid ( ) { Requirements :: javascript ( 'silverstripe/userforms:client/dist/js/userforms-cms.js' ) ; $ fields = $ this -> owner -> Fields ( ) ; $ this -> createInitialFormStep ( true ) ; $ editableColumns = new GridFieldEditableColumns ( ) ; $ fieldClasses = singleton ( EditableFormField :... | Gets the field editor for adding and removing EditableFormFields . |
58,174 | public function createInitialFormStep ( $ force = false ) { if ( ! $ this -> owner -> exists ( ) ) { return ; } $ fields = $ this -> owner -> Fields ( ) ; $ firstField = $ fields -> first ( ) ; if ( $ firstField instanceof EditableFormStep ) { return ; } if ( ! $ force && ! $ firstField ) { return ; } $ next = 2 ; fore... | A UserForm must have at least one step . If no steps exist create an initial step and put all fields inside it . |
58,175 | public function onAfterPublish ( ) { $ seenIDs = [ ] ; foreach ( $ this -> owner -> Fields ( ) as $ field ) { $ seenIDs [ ] = $ field -> ID ; $ field -> doPublish ( Versioned :: DRAFT , Versioned :: LIVE ) ; $ field -> destroy ( ) ; } $ live = Versioned :: get_by_stage ( EditableFormField :: class , Versioned :: LIVE )... | Remove any orphaned child records on publish |
58,176 | public function onAfterUnpublish ( ) { foreach ( $ this -> owner -> Fields ( ) as $ field ) { $ field -> deleteFromStage ( Versioned :: LIVE ) ; } } | Remove all fields from the live stage when unpublishing the page |
58,177 | public function onAfterDuplicate ( $ oldPage , $ doWrite , $ manyMany ) { $ fieldGroups = [ ] ; foreach ( $ oldPage -> Fields ( ) as $ field ) { $ newField = $ field -> duplicate ( false ) ; $ newField -> ParentID = $ this -> owner -> ID ; $ newField -> ParentClass = $ this -> owner -> ClassName ; $ newField -> Version... | When duplicating a UserDefinedForm duplicate all of its fields and display rules |
58,178 | protected function getMergeFieldsMap ( $ fields = [ ] ) { $ data = ArrayData :: create ( [ ] ) ; foreach ( $ fields as $ field ) { $ data -> setField ( $ field -> Name , DBField :: create_field ( 'Text' , $ field -> Value ) ) ; } return $ data ; } | Allows the use of field values in email body . |
58,179 | public function finished ( ) { $ submission = $ this -> getRequest ( ) -> getSession ( ) -> get ( 'userformssubmission' . $ this -> ID ) ; if ( $ submission ) { $ submission = SubmittedForm :: get ( ) -> byId ( $ submission ) ; } $ referrer = isset ( $ _GET [ 'referrer' ] ) ? urldecode ( $ _GET [ 'referrer' ] ) : null ... | This action handles rendering the finished message which is customizable by editing the ReceivedFormSubmission template . |
58,180 | public function preview ( ) { Config :: nest ( ) ; Config :: modify ( ) -> set ( SSViewer :: class , 'theme_enabled' , true ) ; $ content = $ this -> customise ( [ 'Body' => $ this -> record -> getEmailBodyContent ( ) , 'HideFormData' => ( bool ) $ this -> record -> HideFormData , 'Fields' => $ this -> getPreviewFieldD... | Renders a preview of the recipient email . |
58,181 | protected function getPreviewFieldData ( ) { $ data = ArrayList :: create ( ) ; $ fields = $ this -> record -> Form ( ) -> Fields ( ) -> filter ( 'ClassName:not' , [ EditableLiteralField :: class , EditableFormHeading :: class , ] ) ; foreach ( $ fields as $ field ) { $ data -> push ( ArrayData :: create ( [ 'Name' => ... | Get some placeholder field values to display in the preview |
58,182 | public function buildExpression ( ) { $ formFieldWatch = $ this -> ConditionField ( ) ; $ action = $ formFieldWatch -> getJsEventHandler ( ) ; $ checkboxField = $ formFieldWatch -> isCheckBoxField ( ) ; $ radioField = $ formFieldWatch -> isRadioField ( ) ; $ target = sprintf ( '$("%s")' , $ formFieldWatch -> getSelecto... | Substitutes configured rule logic with it s JS equivalents and returns them as array elements |
58,183 | public function getFormattedValue ( ) { $ name = $ this -> getFileName ( ) ; $ link = $ this -> getLink ( ) ; $ title = _t ( __CLASS__ . '.DOWNLOADFILE' , 'Download File' ) ; if ( $ link ) { return DBField :: create_field ( 'HTMLText' , sprintf ( '%s - <a href="%s" target="_blank">%s</a>' , $ name , $ link , $ title ) ... | Return the value of this field for inclusion into things such as reports . |
58,184 | public function getLink ( ) { if ( $ file = $ this -> UploadedFile ( ) ) { if ( trim ( $ file -> getFilename ( ) , '/' ) != trim ( ASSETS_DIR , '/' ) ) { return $ this -> UploadedFile ( ) -> AbsoluteLink ( ) ; } } } | Return the link for the file attached to this submitted form field . |
58,185 | public function mutate ( $ name , $ items ) { $ modelClass = "\\NEM\\Models\\" . Str :: studly ( $ name ) ; if ( ! class_exists ( $ modelClass ) ) { throw new BadMethodCallException ( "Model class '" . $ modelClass . "' could not be found in \\NEM\\Model namespace." ) ; } if ( $ items instanceof ModelCollection ) retur... | Collect several items into a Collection of Models . |
58,186 | public function extend ( ) { return [ "rentalFeeSink" => $ this -> rentalFeeSink ( ) -> address ( ) -> toClean ( ) , "rentalFee" => empty ( $ this -> parent ) ? Fee :: ROOT_PROVISION_NAMESPACE : Fee :: SUB_PROVISION_NAMESPACE , "parent" => $ this -> parent , "newPart" => $ this -> newPart , "type" => TransactionType ::... | Return specialized fields array for Namespace Provision Transactions . |
58,187 | protected function normalizeHeaders ( array $ headers ) { if ( empty ( $ headers [ "User-Agent" ] ) ) $ headers [ "User-Agent" ] = "evias NEM Blockchain Wrapper" ; if ( empty ( $ headers [ "Accept" ] ) ) $ headers [ "Accept" ] = "application/json" ; if ( empty ( $ headers [ "Content-Type" ] ) ) $ headers [ "Content-Typ... | This method makes sure mandatory headers are added in case they are not present . |
58,188 | static public function create ( string $ namespace , string $ mosaic = null ) { if ( empty ( $ mosaic ) ) { $ fullyQualifiedName = $ namespace ; $ splitRegexp = "/([^:]+):([^:]+)/" ; $ namespace = preg_replace ( $ splitRegexp , "$1" , $ fullyQualifiedName ) ; $ mosaic = preg_replace ( $ splitRegexp , "$2" , $ fullyQual... | Class method to create a new Mosaic object from namespace name and mosaic mosaic name . |
58,189 | static public function fromPublicKey ( $ publicKey , $ networkId = 104 ) { if ( $ publicKey instanceof Buffer ) { $ pubKeyBuf = $ publicKey ; } elseif ( $ publicKey instanceof KeyPair ) { $ pubKeyBuf = $ publicKey -> getPublicKey ( null ) ; } elseif ( is_string ( $ publicKey ) && ctype_xdigit ( $ publicKey ) ) { $ pubK... | Generate an address corresponding to a publicKey public key . |
58,190 | public function toClean ( $ string = null ) { $ attrib = $ string ; if ( ! $ attrib && isset ( $ this -> attributes [ "address" ] ) ) $ attrib = $ this -> attributes [ "address" ] ; return strtoupper ( preg_replace ( "/[^a-zA-Z0-9]+/" , "" , $ attrib ) ) ; } | Helper to clean an address of any non alpha - numeric characters back to the actual Base32 representation of the address . |
58,191 | public function extend ( ) { $ version = $ this -> getAttribute ( "version" ) ; $ oneByOld = [ Transaction :: VERSION_2 => Transaction :: VERSION_1 , Transaction :: VERSION_2_TEST => Transaction :: VERSION_1_TEST , Transaction :: VERSION_2_MIJIN => Transaction :: VERSION_1_MIJIN , ] ; if ( in_array ( $ version , array_... | The Multisig transaction type adds offsets otherTrans and signatures . |
58,192 | public function setOtherTrans ( Transaction $ otherTrans ) { $ this -> setAttribute ( "otherTrans" , $ otherTrans -> toDTO ( "transaction" ) ) ; return $ this -> otherTrans ( $ otherTrans -> toDTO ( "transaction" ) ) ; } | Setter for the otherTrans DTO property . |
58,193 | public function otherTrans ( array $ transaction = null ) { $ morphed = Transaction :: create ( $ transaction ? : $ this -> getAttribute ( "otherTrans" ) ) ; if ( $ morphed -> type === TransactionType :: MULTISIG ) { throw new InvalidArgumentException ( "It is forbidden to nest a Multisig transaction in another Multisi... | Mutator for the otherTrans sub DTO . |
58,194 | public function derivePublicKey ( KeyPair $ keyPair ) { $ buffer = new Buffer ; $ hashedSecret = Encryption :: hash ( "keccak-512" , $ keyPair -> getSecretKey ( ) -> getBinary ( ) , true ) ; $ safeSecret = Buffer :: clampBits ( $ hashedSecret ) ; $ publicKey = ParagonIE_Sodium_Core_Ed25519 :: sk_to_pk ( $ safeSecret ) ... | Derive the public key from the KeyPair s secret . |
58,195 | static public function fromMicro ( $ amount , $ divisibility = 6 ) { $ amt = new Amount ( [ "amount" => $ amount ] ) ; $ amt -> setDivisibility ( $ divisibility ) ; return $ amt ; } | Factory for Amount models with MICRO amounts and provided divisibility . |
58,196 | public function toDTO ( $ filterByKey = null ) { $ toDTO = [ "amount" => $ this -> toMicro ( ) ] ; if ( $ filterByKey && isset ( $ toDTO [ $ filterByKey ] ) ) return $ toDTO [ $ filterByKey ] ; return $ toDTO ; } | Amount DTO automatically returns MICRO amount . |
58,197 | public function toMicro ( ) { $ inner = $ this -> getAttribute ( "amount" , false ) ; $ decimals = $ this -> getDivisibility ( ) ; if ( is_integer ( $ inner ) ) { $ attrib = $ inner ; } elseif ( is_float ( $ inner ) ) { $ attrib = $ inner * pow ( 10 , $ decimals ) ; } elseif ( is_string ( $ inner ) ) { $ isFloat = fals... | Helper to return a MICRO amount . This means to get the smallest unit of an Amount on the NEM Blockchain . Maximum Divisibility is up to 6 decimal places . |
58,198 | public function toUnit ( ) { if ( $ this -> divisibility <= 0 ) return $ this -> toMicro ( ) ; $ div = pow ( 10 , $ this -> getDivisibility ( ) ) ; return ( $ this -> toMicro ( ) / $ div ) ; } | Helper to return UNITs amounts . This method will return floating point numbers . The divisibility can be set using setDivisibility in case of different mosaics . |
58,199 | public function setDivisibility ( $ divisibility ) { if ( ! is_integer ( $ divisibility ) || $ divisibility < 0 ) $ divisibility = 6 ; $ this -> divisibility = $ divisibility ; return $ this ; } | Setter for the divisibility property . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.