idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
9,200
|
public function editAction ( Request $ request , $ series ) { $ series = $ this -> get ( 'oktolab_media' ) -> getSeries ( $ series ) ; $ form = $ this -> createForm ( SeriesType :: class , $ series ) ; $ form -> add ( 'submit' , SubmitType :: class , [ 'label' => 'oktolab_media.edit_series_button' , 'attr' => [ 'class' => 'btn btn-primary' ] ] ) ; $ form -> add ( 'delete' , SubmitType :: class , [ 'label' => 'oktolab_media.delete_series_button' , 'attr' => [ 'class' => 'btn btn-danger' ] ] ) ; if ( $ request -> getMethod ( ) == "POST" ) { $ form -> handleRequest ( $ request ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( $ form -> isValid ( ) || $ form -> get ( 'delete' ) -> isClicked ( ) ) { if ( $ form -> get ( 'submit' ) -> isClicked ( ) ) { $ em -> persist ( $ series ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'oktolab_media.success_edit_series' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'oktolab_series_show' , [ 'series' => $ series -> getUniqID ( ) ] ) ) ; } elseif ( $ form -> get ( 'delete' ) -> isClicked ( ) ) { $ this -> get ( 'oktolab_media_helper' ) -> deleteSeries ( $ series ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'oktolab_media.success_delete_series' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'oktolab_series' ) ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'oktolab_media.unknown_action_series' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'oktolab_series_show' , [ 'series' => $ series -> getUniqID ( ) ] ) ) ; } } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , 'oktolab_media.error_edit_series' ) ; } return [ 'form' => $ form -> createView ( ) ] ; }
|
Displays a form to edit an existing Series entity .
|
9,201
|
public function validate ( ) { if ( true === $ this -> enableReset && $ this -> getPost ( $ this -> strName . '_reset' ) ) { if ( null !== ( $ fileModel = FilesModel :: findByPk ( $ this -> varValue ) ) ) { $ file = new File ( $ fileModel -> path ) ; $ file -> delete ( ) ; } unset ( $ _FILES [ $ this -> strName ] ) ; return ; } parent :: validate ( ) ; $ file = $ _SESSION [ 'FILES' ] [ $ this -> strName ] ; if ( true === $ file [ 'uploaded' ] ) { $ this -> varValue = StringUtil :: uuidToBin ( $ file [ 'uuid' ] ) ; } else { $ this -> blnSubmitInput = false ; } }
|
Validate the user input and set the value .
|
9,202
|
public function create ( $ uid , $ stream ) { return new $ this -> mailClass ( $ uid , $ stream , $ this -> parseMailHeader ( $ stream , $ uid ) , $ this -> parseHeaders ( $ stream , $ uid ) , $ this -> parseBody ( $ stream , $ uid ) ) ; }
|
Create new mail from uid
|
9,203
|
protected function parseMailHeader ( $ stream , $ uid ) { $ header = imap_headerinfo ( $ stream , imap_msgno ( $ stream , $ uid ) ) ; return [ 'msgNo' => ( int ) $ header -> Msgno , 'subject' => $ this -> parseSubject ( $ header -> subject ) , 'date' => $ header -> udate , 'to' => isset ( $ header -> to ) ? $ this -> parseAddress ( $ header -> to ) : null , 'cc' => isset ( $ header -> cc ) ? $ this -> parseAddress ( $ header -> cc ) : null , 'bcc' => isset ( $ header -> bcc ) ? $ this -> parseAddress ( $ header -> bcc ) : null , 'sender' => isset ( $ header -> sender ) ? $ this -> parseAddress ( $ header -> sender ) : null , 'from' => isset ( $ header -> from ) ? $ this -> parseAddress ( $ header -> from ) : null , 'replyTo' => isset ( $ header -> reply_to ) ? $ this -> parseAddress ( $ header -> reply_to ) : null , 'recent' => $ this -> parseFlag ( 'R' , $ header -> Recent ) , 'unseen' => $ this -> parseFlag ( 'U' , $ header -> Unseen ) , 'flagged' => $ this -> parseFlag ( 'F' , $ header -> Flagged ) , 'answered' => $ this -> parseFlag ( 'A' , $ header -> Answered ) , 'deleted' => $ this -> parseFlag ( 'D' , $ header -> Deleted ) , 'draft' => $ this -> parseFlag ( 'X' , $ header -> Draft ) ] ; }
|
Parse the mail header
|
9,204
|
protected function parseAddress ( array $ addresses ) { return array_map ( function ( $ address ) { return ( object ) [ 'address' => $ address -> mailbox . '@' . $ address -> host , 'domain' => $ address -> host , 'name' => isset ( $ address -> personal ) ? static :: convertBodyEncoding ( $ address -> personal ) : null ] ; } , array_filter ( $ addresses , function ( $ address ) { return property_exists ( $ address , 'mailbox' ) && strtolower ( $ address -> mailbox ) !== 'undisclosed-recipients' ; } ) ) ; }
|
Parse email addresses from header
|
9,205
|
protected function parseSubject ( $ subject ) { $ subject = imap_mime_header_decode ( $ subject ) ; $ subjectParts = array_map ( function ( $ subj ) { if ( strtolower ( $ subj -> charset ) === 'default' ) { return $ subj -> text ; } return iconv ( $ subj -> charset , static :: $ charset , $ subj -> text ) ; } , $ subject ) ; return implode ( '' , $ subjectParts ) ; }
|
Parse the subject of the email
|
9,206
|
protected function parseHeaders ( $ stream , $ uid ) { $ rawHeaders = imap_fetchheader ( $ stream , $ uid , static :: $ fetchFlags ) ; $ headers = [ ] ; $ key = null ; foreach ( explode ( "\n" , $ rawHeaders ) as $ line ) { if ( $ line !== '' && ! preg_match ( '/^\s/' , $ line ) ) { list ( $ key , $ val ) = explode ( ':' , $ line , 2 ) ; $ headers [ $ key ] = trim ( $ val ) ; } elseif ( ! is_null ( $ key ) && ( $ trimmed = trim ( $ line ) ) !== '' ) { $ headers [ $ key ] = $ headers [ $ key ] . $ trimmed ; } } foreach ( $ headers as $ headerKey => $ headerValue ) { if ( preg_match ( '/(\w+)=(\S+);(?:\s|$)/' , $ headerValue ) ) { $ headers [ $ headerKey ] = $ this -> parseNestedKeyPairHeader ( $ headerValue ) ; } } return $ headers ; }
|
Parse the email headers into array structure
|
9,207
|
protected function parseNestedKeyPairHeader ( $ nestedPairs ) { return array_reduce ( explode ( ';' , $ nestedPairs ) , function ( $ result , $ pair ) { $ keyVal = explode ( '=' , $ pair , 2 ) ; $ key = trim ( array_shift ( $ keyVal ) ) ; $ val = trim ( implode ( '=' , $ keyVal ) ) ; if ( $ key !== '' && $ val !== '' ) { $ result [ $ key ] = $ val ; } return $ result ; } , [ ] ) ; }
|
Parse the any nested key - pair values in the header value
|
9,208
|
protected function parseBody ( $ stream , $ uid ) { $ struct = imap_fetchstructure ( $ stream , $ uid , static :: $ fetchFlags ) ; if ( ! isset ( $ struct -> parts ) ) { return array_filter ( [ $ this -> parsePart ( $ stream , $ uid , $ struct ) ] ) ; } $ parsedParts = [ ] ; foreach ( $ this -> flattenParts ( $ struct -> parts ) as $ partNo => $ part ) { $ parsedParts [ ] = $ this -> parsePart ( $ stream , $ uid , $ part , $ partNo ) ; } return array_filter ( $ parsedParts ) ; }
|
Parse the email body and its parts
|
9,209
|
protected function flattenParts ( array $ parts , array $ flattened = [ ] , $ pre = '' , $ idx = 1 , $ full = true ) { foreach ( $ parts as $ part ) { $ key = $ pre . $ idx ; $ flattened [ $ key ] = $ part ; if ( isset ( $ part -> parts ) ) { if ( $ part -> type == TYPEMULTIPART ) { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ key . '.' , 1 , false ) ; } elseif ( $ full ) { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ key . '.' ) ; } else { $ flattened = $ this -> flattenParts ( $ part -> parts , $ flattened , $ pre ) ; } unset ( $ flattened [ $ key ] -> parts ) ; } $ idx ++ ; } return $ flattened ; }
|
Flatten email structure recursively .
|
9,210
|
protected function parsePart ( $ stream , $ uid , $ part , $ partNo = 1 ) { if ( ! in_array ( $ part -> type , [ TYPETEXT , TYPEMULTIPART ] ) ) { return null ; } $ body = imap_fetchbody ( $ stream , $ uid , $ partNo , static :: $ bodyFlags ) ; $ body = static :: decode ( $ body , $ part -> encoding ) ; if ( '' !== ( $ charset = $ this -> findCharset ( $ part ) ) ) { $ body = static :: convertBodyEncoding ( $ body , $ charset , $ part -> encoding ) ; } return ( object ) [ 'body' => $ body , 'mime_type' => strtolower ( $ part -> subtype ) ] ; }
|
Parse individual part of the structure
|
9,211
|
protected static function decode ( $ body , $ encoding ) { if ( ENCQUOTEDPRINTABLE === $ encoding ) { return quoted_printable_decode ( $ body ) ; } if ( ENCBASE64 === $ encoding ) { return base64_decode ( $ body ) ; } return $ body ; }
|
Decode the body text
|
9,212
|
protected static function convertBodyEncoding ( $ body , $ charset = '' , $ encoding = - 1 ) { if ( '' === $ charset ) { $ charset = static :: $ charset ; } if ( ! mb_check_encoding ( $ body , $ charset ) ) { $ charset = mb_detect_encoding ( $ body ) ; } if ( $ charset === static :: $ charset ) { return $ body ; } if ( ! in_array ( $ charset , mb_list_encodings ( ) ) ) { $ charset = $ encoding === ENC7BIT ? 'US-ASCII' : static :: $ charset ; } return mb_convert_encoding ( $ body , static :: $ charset , $ charset ) ; }
|
Convert body encoding from given coding to default
|
9,213
|
protected function findCharset ( $ struct ) { if ( isset ( $ struct -> parameters ) ) { foreach ( $ struct -> parameters as $ param ) { if ( strtolower ( $ param -> attribute ) === 'charset' ) { return strtoupper ( $ param -> value ) ; } } } if ( isset ( $ struct -> dparameters ) ) { foreach ( $ struct -> dparameters as $ param ) { if ( strtolower ( $ param -> attribute ) === 'charset' ) { return strtoupper ( $ param -> value ) ; } } } return '' ; }
|
Locate the charset within the struct
|
9,214
|
public function offsetUnset ( $ offset ) { $ index = $ this -> getKeyIndex ( $ offset ) ; if ( $ index >= 0 ) { $ this -> values -> setSize ( $ index - 1 ) ; unset ( $ this -> keys [ $ offset ] , $ this -> values [ $ index ] ) ; } }
|
Unset an offset in the iterator .
|
9,215
|
public function transform ( $ value ) { if ( $ value === null || $ value == '' ) { return null ; } if ( ! ( $ value instanceof File ) ) { throw new TransformationFailedException ( 'Expected an instance of a concrete5 file object.' ) ; } return intval ( $ value -> getFileID ( ) ) ; }
|
Converts a concrete5 file object to an integer .
|
9,216
|
public function reverseTransform ( $ fID ) { if ( ! is_numeric ( $ fID ) || $ fID == 0 ) { return null ; } $ rep = $ this -> entityManager -> getRepository ( 'Concrete\Core\File\File' ) ; $ f = $ rep -> find ( $ fID ) ; if ( ! is_object ( $ f ) || $ f -> isError ( ) ) { throw new TransformationFailedException ( 'Invalid file ID.' ) ; } return $ f ; }
|
Converts an integer to a concrete5 file object .
|
9,217
|
private function regenerateTaskById ( $ id ) { try { $ response = $ this -> taskQueueService -> regenerateTask ( $ id ) ; if ( $ response ) { $ this -> output -> writeln ( "<info>Regeneration succes</info>" ) ; } else { $ this -> output -> writeln ( "<error>Regeneration succes</error>" ) ; } } catch ( TaskQueueServiceException $ e ) { $ this -> output -> writeln ( "<error>Error!:</error>" . $ e -> getMessage ( ) ) ; } }
|
Regenerates a task that has failed
|
9,218
|
static function __callstatic ( $ func , array $ args ) { if ( ! self :: $ fw ) self :: $ fw = Base :: instance ( ) ; return call_user_func_array ( array ( self :: $ fw , $ func ) , $ args ) ; }
|
Forward function calls to framework
|
9,219
|
public function getPageThemeLayout ( $ pageThemeId ) { $ themeModel = $ this -> getServiceLocator ( ) -> get ( 'pagebuilder\model\pageTheme' ) ; $ pageTheme = $ themeModel -> findObject ( $ pageThemeId ) ; return $ this -> getPageLayout ( $ pageTheme -> getPageId ( ) -> getId ( ) , $ pageTheme -> getThemeId ( ) -> getId ( ) ) ; }
|
Get Page theme layout
|
9,220
|
public function connect ( ) { if ( ! is_callable ( 'mysqli_connect' ) ) { throw new Exceptions \ UnableToConnectException ( 'MySQLi PHP extension is not available. It probably has not been ' . 'installed. Please install and configure it in order to use MySQL.' ) ; } $ host = $ this -> config [ 'MySQL' ] [ 'host' ] ; $ user = $ this -> config [ 'MySQL' ] [ 'user' ] ; $ password = $ this -> config [ 'MySQL' ] [ 'password' ] ; $ database = $ this -> config [ 'MySQL' ] [ 'database' ] ; $ port = $ this -> config [ 'MySQL' ] [ 'port' ] ; if ( $ this -> connected && ! mysqli_ping ( $ this -> link ) ) { $ this -> connected = false ; } if ( ! $ this -> connected ) { $ link = is_callable ( $ this -> config [ 'MySQL' ] [ 'link' ] ) ? $ this -> config [ 'MySQL' ] [ 'link' ] ( ) : null ; if ( $ this -> link = $ link ?? mysqli_connect ( $ host , $ user , $ password , $ database , $ port ) ) { $ this -> connected = true ; } else { $ this -> connected = false ; if ( $ host === 'localhost' && $ user === 'nymph' && $ password === 'password' && $ database === 'nymph' && $ link === null ) { throw new Exceptions \ NotConfiguredException ( ) ; } else { throw new Exceptions \ UnableToConnectException ( 'Could not connect: ' . mysqli_error ( $ this -> link ) ) ; } } } return $ this -> connected ; }
|
Connect to the MySQL database .
|
9,221
|
public function disconnect ( ) { if ( $ this -> connected ) { if ( is_a ( $ this -> link , 'mysqli' ) ) { unset ( $ this -> link ) ; } $ this -> link = null ; $ this -> connected = false ; } return $ this -> connected ; }
|
Disconnect from the MySQL database .
|
9,222
|
public function rewrite_rules_array ( array $ rules ) { if ( ! empty ( $ this -> classes ) ) { $ new_rewrite = [ ] ; $ error_message = [ ] ; foreach ( $ this -> classes as $ class_name ) { $ prefix = $ this -> get_prefix ( $ class_name ) ; if ( empty ( $ prefix ) ) { $ error_message [ ] = sprintf ( $ this -> __ ( '<code>%s</code> should have prefix property.' ) , $ class_name ) ; continue ; } $ new_rewrite [ trim ( $ prefix , '/' ) . '(/.*)?$' ] = "index.php?{$this->api_class}={$class_name}&{$this->api_vars}=\$matches[1]" ; } if ( ! empty ( $ new_rewrite ) ) { $ rules = array_merge ( $ new_rewrite , $ rules ) ; } if ( ! empty ( $ error_message ) ) { add_action ( 'admin_notices' , function ( ) use ( $ error_message ) { printf ( '<div class="error"><p>%s</p></div>' , implode ( '<br />' , $ error_message ) ) ; } ) ; } } return $ rules ; }
|
Add rewrite rules .
|
9,223
|
public function pre_get_posts ( \ WP_Query & $ wp_query ) { if ( ! is_admin ( ) && $ wp_query -> is_main_query ( ) && ( $ api_class = $ wp_query -> get ( $ this -> api_class ) ) ) { try { $ api_class = str_replace ( '\\\\' , '\\' , $ api_class ) ; if ( ! $ this -> is_valid_class ( $ api_class ) ) { throw new \ Exception ( $ this -> __ ( 'Specified URL is invalid.' ) , 404 ) ; } $ instance = $ api_class :: get_instance ( ) ; $ instance -> parse_request ( $ wp_query -> get ( $ this -> api_vars ) , $ wp_query ) ; } catch ( \ Exception $ e ) { switch ( $ e -> getCode ( ) ) { case 404 : $ wp_query -> set_404 ( ) ; break ; case 200 : case 201 : break ; default : wp_die ( $ e -> getMessage ( ) , get_status_header_desc ( $ e -> getCode ( ) ) , [ 'response' => $ e -> getCode ( ) , 'back_link' => true , ] ) ; break ; } } } }
|
Parse request and invoke REST class if possible
|
9,224
|
public function admin_init ( ) { if ( ! AjaxBase :: is_ajax ( ) && current_user_can ( 'manage_options' ) ) { if ( ! empty ( $ this -> classes ) ) { $ rewrites = '' ; foreach ( $ this -> classes as $ class_name ) { $ rewrites .= $ this -> get_prefix ( $ class_name ) ; } $ rewrites = md5 ( $ rewrites ) ; if ( get_option ( 'rewrite_rules' ) && $ this -> rewrite_md5 != $ rewrites ) { flush_rewrite_rules ( ) ; $ last_updated = current_time ( 'timestamp' ) ; update_option ( $ this -> option_name , $ last_updated ) ; update_option ( $ this -> rewrite_md5_name , $ rewrites ) ; $ message = sprintf ( $ this -> __ ( 'Rewrite rules updated. Last modified date is %s' ) , date_i18n ( get_option ( 'date_format' ) . ' ' . get_option ( 'time_format' ) , $ last_updated ) ) ; add_action ( 'admin_notices' , function ( ) use ( $ message ) { printf ( '<div class="updated"><p>%s</p></div>' , $ message ) ; } ) ; } } } }
|
Update rewrite rules if possible
|
9,225
|
public function get_prefix ( $ class_name ) { if ( ! empty ( $ class_name :: $ prefix ) ) { return $ class_name :: $ prefix ; } else { $ seg = explode ( '\\' , $ class_name ) ; $ base = $ seg [ count ( $ seg ) - 1 ] ; return $ this -> str -> camel_to_hyphen ( $ base ) ; } }
|
Get class prefix
|
9,226
|
public function prepare ( ) { $ dateFormatMethod = 'to' . strtolower ( $ this -> format ) . 'String' ; if ( null !== $ this -> pubDate ) { $ this -> pubDate = Carbon :: parse ( $ this -> pubDate ) -> { $ dateFormatMethod } ( ) ; } if ( null !== $ this -> updated ) { $ this -> updated = Carbon :: parse ( $ this -> updated ) -> { $ dateFormatMethod } ( ) ; } $ this -> title = strip_tags ( $ this -> title ) ; $ this -> autoFill ( ) ; }
|
Validate auto - fill and sanitize the entry
|
9,227
|
public function autoFill ( ) { $ dateFormatMethod = 'to' . strtolower ( $ this -> format ) . 'String' ; if ( null === $ this -> pubDate ) { $ this -> pubDate = Carbon :: parse ( 'now' ) -> { $ dateFormatMethod } ( ) ; } if ( null === $ this -> summary ) { $ summary = strip_tags ( $ this -> content ) ; $ this -> summary = substr ( $ summary , 0 , 144 ) . '...' ; } }
|
Fill the attributes that can be auto - generated
|
9,228
|
protected function buildAliases ( ) { $ this -> routes = ArrayHelper :: merge ( $ this -> defaultRoutes , $ this -> routes ) ; foreach ( $ this -> routes as $ alias => $ route ) { Yii :: setAlias ( $ alias , $ route ) ; } }
|
Sets needed routes aliases
|
9,229
|
public static function validar ( $ xml , $ schemaFile ) { libxml_use_internal_errors ( true ) ; libxml_clear_errors ( ) ; if ( is_file ( $ xml ) ) { $ xml = file_get_contents ( $ xml ) ; } $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; $ dom -> loadXML ( $ xml , LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG ) ; if ( ! $ dom -> schemaValidate ( $ schemaFile ) ) { $ errors = libxml_get_errors ( ) ; $ returnErrors = [ ] ; foreach ( $ errors as $ error ) { $ returnErrors [ ] = $ error -> message . 'at line ' . $ error -> line ; } $ msg = "Erro ao validar XML:\r\n" . implode ( "\r\n" , $ returnErrors ) ; throw new \ Exception ( $ msg ) ; } return true ; }
|
Valida um xml assinado .
|
9,230
|
public function override ( $ post_type , $ post ) { if ( $ this -> is_valid_post_type ( $ post_type ) ) { foreach ( $ this -> fields as $ name => $ vars ) { switch ( $ name ) { case 'excerpt' : remove_meta_box ( 'postexcerpt' , $ post_type , 'normal' ) ; break ; case 'post_format' : remove_meta_box ( 'formatdiv' , $ post_type , 'side' ) ; break ; default : if ( false !== array_search ( Taxonomy :: class , class_uses ( $ vars [ 'class' ] ) ) ) { if ( taxonomy_exists ( $ name ) ) { if ( is_taxonomy_hierarchical ( $ name ) ) { $ box_id = $ name . 'div' ; } else { $ box_id = 'tagsdiv-' . $ name ; } remove_meta_box ( $ box_id , $ post_type , 'side' ) ; } } else { } break ; } } } }
|
Override default meta box
|
9,231
|
public function render ( \ WP_Post $ post ) { $ this -> nonce_field ( ) ; $ this -> desc ( ) ; echo '<table class="table form-table wpametu-meta-table">' ; foreach ( $ this -> loop_fields ( ) as $ field ) { if ( ! is_wp_error ( $ field ) ) { $ field -> render ( $ post ) ; } else { printf ( '<div class="error"><p>%s</p></div>' , $ field -> get_error_message ( ) ) ; } } echo '</table>' ; }
|
Render meta box content
|
9,232
|
public function getList ( array $ query = [ ] ) { $ list = $ this -> pagination ( self :: DOMUSERP_API_OPERACIONAL . '/marcas/' . $ this -> brandId . '/modelos' , $ query ) ; return $ list ; }
|
List of product models
|
9,233
|
public function get ( $ id ) { $ data = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_OPERACIONAL . '/marcas/' . $ this -> brandId . '/modelos/' . $ id ) ; return $ data ; }
|
Gets the product models data according to the id parameter
|
9,234
|
protected function clearPreviousCollection ( Collection $ collection ) { if ( $ collection -> count ( ) ) { foreach ( $ collection as $ item ) { $ collection -> removeElement ( $ item ) ; } } }
|
Resets previous photo collection
|
9,235
|
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ output -> writeln ( 'Available templates:' ) ; foreach ( $ this -> factory -> getAllNames ( ) as $ template_name ) { $ output -> writeln ( '* ' . $ template_name ) ; } $ output -> writeln ( '' ) ; }
|
Retrieves all template names from the Template Factory and sends those to stdout .
|
9,236
|
public function setInput ( & $ post , & $ cookie , & $ files , & $ put , & $ delete , & $ data ) { $ this -> post = $ post ; $ this -> cookie = $ cookie ; $ this -> files = $ files ; $ this -> put = $ put ; $ this -> delete = $ delete ; $ this -> data = $ data ; }
|
Sets the input for the request
|
9,237
|
public function setInputArgsDelimiter ( $ input_args_delimiter ) { $ args = preg_replace ( "~^.{" . strlen ( $ this -> path ) . "}/?~" , "" , $ this -> request ) ; $ args = preg_replace ( "~\?.*?$~" , "" , $ args ) ; if ( $ args !== '' ) { $ this -> args = explode ( $ input_args_delimiter , $ args ) ; foreach ( $ this -> args as & $ arg ) { $ arg = urldecode ( $ arg ) ; } if ( method_exists ( '\App' , 'filterAllInput' ) ) { \ App :: filterAllInput ( $ this -> args ) ; } } }
|
Sets the input argument delimeter and parses it
|
9,238
|
public function getFile ( $ key ) { if ( isset ( $ this -> files [ $ key ] ) ) { return $ this -> files [ $ key ] ; } return null ; }
|
Gets a uploaded file reference otherwise returns null
|
9,239
|
public function gmdate ( $ attribute , $ params , $ validator ) { if ( isset ( $ this -> $ attribute ) ) { $ timestamp = strtotime ( $ this -> $ attribute ) ; $ this -> { $ attribute . 'InUtc' } = gmdate ( 'Y-m-d H:i:s' , $ timestamp ) ; } }
|
Convert time attribute to UTC time .
|
9,240
|
public function attributeLabels ( ) { $ attributeLabels = parent :: attributeLabels ( ) ; $ attributeLabels [ 'id' ] = Yii :: t ( 'user' , 'User ID' ) ; $ attributeLabels [ 'nickname' ] = Yii :: t ( 'user' , 'Nickname' ) ; $ attributeLabels [ 'first_name' ] = Yii :: t ( 'user' , 'First Name' ) ; $ attributeLabels [ 'last_name' ] = Yii :: t ( 'user' , 'Last Name' ) ; $ attributeLabels [ 'gf' ] = Yii :: t ( 'user' , 'Gender' ) ; $ attributeLabels [ 'createdFrom' ] = Yii :: t ( 'user' , 'From' ) ; $ attributeLabels [ 'createdTo' ] = Yii :: t ( 'user' , 'To' ) ; return $ attributeLabels ; }
|
Add createdFrom & createdTo attributes .
|
9,241
|
public function shouldResponseBeCached ( \ Amp \ Artax \ Response $ response ) { $ status = $ response -> getStatus ( ) ; if ( $ status == 200 ) { return true ; } return false ; }
|
Determine whether the response should be cached .
|
9,242
|
public function fromXml ( string $ xml ) : array { if ( ! $ this -> isEmptyValue ( $ xml ) ) { libxml_use_internal_errors ( true ) ; $ result = simplexml_load_string ( "$xml" , 'SimpleXMLElement' , LIBXML_NOCDATA ) ; if ( $ result ) { return $ this -> fromClass ( $ result ) ; } else { foreach ( libxml_get_errors ( ) as $ error ) { if ( $ error -> code == 5 ) { $ this -> errors = [ ] ; return $ this -> fromXml ( "<DATA>$xml</DATA>" ) ; } else $ this -> setError ( $ error -> code , $ error -> message ) ; } } } return $ this -> result ; }
|
Convert xml to array
|
9,243
|
public function fromXSD ( $ xsd ) : array { if ( ! $ this -> isEmptyValue ( $ xsd ) ) { return $ this -> fromXml ( $ xsd -> output ) ; } return $ this -> result ; }
|
Convert class to array
|
9,244
|
public function fromJson ( string $ json ) : array { if ( ! $ this -> isEmptyValue ( $ json ) ) { if ( $ decode = json_decode ( trim ( $ json ) , true ) and json_last_error ( ) == JSON_ERROR_NONE ) $ this -> result = $ decode ; else $ this -> setError ( json_last_error ( ) , json_last_error_msg ( ) ) ; } return $ this -> result ; }
|
Convert json to array
|
9,245
|
protected function setSourceList ( array $ sourceParameters , array $ globalParameters = array ( ) ) { foreach ( $ sourceParameters as $ key => $ parameters ) { if ( ! isset ( $ parameters [ 'type' ] ) ) { throw new Exception \ BadProxyConfigurationException ( sprintf ( "Missing parameters 'type' for remote source configuration '%s'" , $ key ) ) ; } else { $ type = $ parameters [ 'type' ] ; try { $ source = $ this -> sourceFactory -> getSourceInstance ( $ type , $ key , $ parameters , $ globalParameters ) ; if ( $ source instanceof SourceInterface ) { $ this -> addSource ( $ source ) ; $ this -> sources [ $ key ] = $ source ; } else { throw new Exception \ BadProxyConfigurationException ( sprintf ( "Expected instance of 'Msl\ResourceProxy\Source\SourceInterface' but got '%s'" , get_class ( $ source ) ) ) ; } } catch ( Exception \ BadSourceConfigConfigurationException $ bscce ) { throw new Exception \ BadProxyConfigurationException ( sprintf ( "The following exception has been caught while generating a source object for the source '%s': %s" , $ key , $ bscce -> getMessage ( ) ) ) ; } } } }
|
Creates and adds to the Source object list all the configured Source instances
|
9,246
|
public function processResources ( ) { $ errors = array ( ) ; foreach ( $ this -> sourcesIterator as $ source ) { if ( $ source instanceof SourceInterface ) { try { $ this -> processResourcesBySource ( $ source ) ; } catch ( Exception \ PostParseException $ e ) { array_push ( $ errors , $ e ) ; } catch ( Exception \ ResourceProxyExceptionInterface $ e ) { $ msg = sprintf ( 'General proxy error caught for the following source: \'%s\'. Error is: \'%s\'.' , $ source -> getName ( ) , $ e -> getMessage ( ) ) ; array_push ( $ errors , $ msg ) ; } catch ( \ Exception $ e ) { $ msg = sprintf ( 'General error caught for the following source: \'%s\'. Error is: \'%s\'.' , $ source -> getName ( ) , $ e -> getMessage ( ) ) ; array_push ( $ errors , $ msg ) ; } } } if ( count ( $ errors ) > 0 ) { throw new Exception \ GlobalProcessException ( $ errors , sprintf ( 'Errors while processing the sources for the following proxy: \'%s\'.' , $ this -> getProxyName ( ) ) ) ; } }
|
Processes all resources associated to the configured source objects for a proxy implementation
|
9,247
|
public function processResourcesBySource ( SourceInterface $ source ) { $ resources = $ this -> getResources ( $ source ) ; $ globalSuccess = true ; $ postParseErrors = array ( ) ; foreach ( $ resources as $ resourceKey => $ resource ) { if ( $ resource instanceof ResourceInterface ) { $ success = $ resource -> moveToOutputFolder ( $ this -> outputFolder ) ; if ( ! $ success ) { $ globalSuccess = false ; } try { $ result = $ source -> postParseUnitAction ( $ resourceKey , $ success ) ; if ( $ result instanceof ParseResult && $ result -> getResult ( ) === false ) { $ sourcePostParseError = sprintf ( 'Post parse error for source \'%s\'. Error message is: \'%s\'.' , $ source -> toString ( ) , $ result -> getMessage ( ) ) ; array_push ( $ postParseErrors , $ sourcePostParseError ) ; } } catch ( \ Exception $ e ) { $ sourcePostParseError = sprintf ( 'Exception has been caught while parsing the resources for the source object \'%s\'. Error is: \'%s\'' , $ source -> toString ( ) , $ e -> getMessage ( ) ) ; array_push ( $ postParseErrors , $ sourcePostParseError ) ; } } } try { $ result = $ source -> postParseGlobalAction ( $ globalSuccess ) ; if ( $ result instanceof ParseResult && $ result -> getResult ( ) === false ) { $ globalSourcePostParseError = sprintf ( 'Post global parse error for source \'%s\'. Error message is: \'%s\'.' , $ source -> toString ( ) , $ result -> getMessage ( ) ) ; array_push ( $ postParseErrors , $ globalSourcePostParseError ) ; } } catch ( \ Exception $ e ) { $ globalSourcePostParseError = sprintf ( 'Exception has been caught while running the post global action for the source object \'%s\'. Error is: \'%s\'' , $ source -> toString ( ) , $ e -> getMessage ( ) ) ; array_push ( $ postParseErrors , $ globalSourcePostParseError ) ; } if ( count ( $ postParseErrors ) > 0 ) { throw new Exception \ PostParseException ( $ postParseErrors , sprintf ( 'Errors while running post unit and global actions for the following source: \'%s\'.' , $ source -> toString ( ) ) ) ; } return true ; }
|
Processes all resources associated to the given Source object
|
9,248
|
public function processResourcesBySourceName ( $ sourceName ) { $ source = $ this -> getSourceByName ( $ sourceName ) ; if ( ! $ source instanceof SourceInterface ) { throw new Exception \ SourceNotFoundException ( $ sourceName , sprintf ( 'Impossible to find a source object with the following name: \'%s\'.' , $ sourceName ) ) ; } return $ this -> processResourcesBySource ( $ source ) ; }
|
Processes all resources associated to a Source object for the given source name
|
9,249
|
public function getSourceByName ( $ sourceName ) { if ( isset ( $ this -> sources [ $ sourceName ] ) ) { return $ this -> sources [ $ sourceName ] ; } return null ; }
|
Returns the Source object for the given source name
|
9,250
|
public function getResources ( SourceInterface $ source ) { try { return $ source -> getContentIterator ( ) ; } catch ( \ Exception $ e ) { throw new Exception \ SourceGetDataException ( sprintf ( 'Exception caught while getting the resources for the following source object: %s' , $ source -> toString ( ) ) ) ; } }
|
Returns an Iterator containing all the resources for the given source object
|
9,251
|
public function getResourcesBySourceName ( $ sourceName ) { $ source = $ this -> getSourceByName ( $ sourceName ) ; if ( $ source instanceof SourceInterface ) { try { return $ source -> getContentIterator ( ) ; } catch ( \ Exception $ e ) { throw new Exception \ SourceGetDataException ( sprintf ( 'Exception caught while getting the content for the following source object: %s' , $ source -> toString ( ) ) ) ; } } return null ; }
|
Returns an Iterator containing all the resources for the given source name
|
9,252
|
public function init ( ) { $ this -> container = $ this -> initContainer ( ) ; if ( $ this -> container -> has ( ServerRequestInterface :: class ) ) { $ this -> baseRequest = $ this -> container -> get ( ServerRequestInterface :: class ) ; } if ( $ this -> container -> has ( ResponseInterface :: class ) ) { $ this -> baseResponse = $ this -> container -> get ( ResponseInterface :: class ) ; } }
|
Initialize the module
|
9,253
|
public function _before ( TestInterface $ test ) { $ this -> init ( ) ; $ this -> client = new Connector ( ) ; $ this -> client -> setRouter ( $ this -> container -> get ( RouterInterface :: class ) ) ; if ( isset ( $ this -> baseRequest ) ) { $ this -> client -> setBaseRequest ( $ this -> baseRequest ) ; } if ( isset ( $ this -> baseResponse ) ) { $ this -> client -> setBaseResponse ( $ this -> baseResponse ) ; } parent :: _before ( $ test ) ; }
|
Before each test
|
9,254
|
public function _after ( TestInterface $ test ) { if ( $ this -> sessionStatus ( ) === PHP_SESSION_ACTIVE ) { $ this -> sessionDestroy ( ) ; } if ( isset ( $ this -> client ) && $ this -> client instanceof Connector ) { $ this -> client -> reset ( ) ; if ( isset ( $ this -> baseRequest ) ) { $ this -> baseRequest = $ this -> client -> getBaseRequest ( ) ; } if ( isset ( $ this -> baseResponse ) ) { $ this -> baseResponse = $ this -> client -> getBaseResponse ( ) ; } } parent :: _after ( $ test ) ; }
|
After each test
|
9,255
|
public function _failed ( TestInterface $ test , $ fail ) { if ( isset ( $ this -> container ) && $ this -> container -> has ( ErrorHandlerInterface :: class ) ) { $ error = $ this -> container -> get ( ErrorHandlerInterface :: class ) -> getError ( ) ; if ( $ error ) { $ this -> debug ( ( string ) $ error ) ; } } parent :: _failed ( $ test , $ fail ) ; }
|
Called when test fails
|
9,256
|
public static function getValue ( $ key ) { $ className = get_called_class ( ) ; $ reflectionClass = new ReflectionClass ( $ className ) ; if ( ! $ reflectionClass -> hasConstant ( $ key ) ) { return static :: DEFAULT_VALUE ; } return $ reflectionClass -> getConstant ( $ key ) ; }
|
Returns an enum value by its key .
|
9,257
|
public static function toDictionary ( ) { $ className = get_called_class ( ) ; $ reflectionClass = new ReflectionClass ( $ className ) ; $ dictionary = $ reflectionClass -> getConstants ( ) ; unset ( $ dictionary [ 'DEFAULT_VALUE' ] ) ; return $ dictionary ; }
|
Returns the enum as dictionary .
|
9,258
|
protected function connect ( ) { $ errno = null ; $ errstr = null ; if ( $ this -> options -> connectionType !== self :: CONNECTION_PLAIN && ! ezcBaseFeatures :: hasExtensionSupport ( 'openssl' ) ) { throw new ezcBaseExtensionNotFoundException ( 'openssl' , null , "PHP not configured --with-openssl." ) ; } if ( count ( $ this -> options -> connectionOptions ) > 0 ) { $ context = stream_context_create ( $ this -> options -> connectionOptions ) ; $ this -> connection = @ stream_socket_client ( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}" , $ errno , $ errstr , $ this -> options -> timeout , STREAM_CLIENT_CONNECT , $ context ) ; } else { $ this -> connection = @ stream_socket_client ( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}" , $ errno , $ errstr , $ this -> options -> timeout ) ; } if ( is_resource ( $ this -> connection ) ) { stream_set_timeout ( $ this -> connection , $ this -> options -> timeout ) ; $ this -> status = self :: STATUS_CONNECTED ; $ greeting = $ this -> getData ( ) ; $ this -> login ( ) ; } else { throw new ezcMailTransportSmtpException ( "Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}." ) ; } }
|
Creates a connection to the SMTP server and initiates the login procedure .
|
9,259
|
protected function login ( ) { if ( $ this -> doAuthenticate ) { $ this -> sendData ( 'EHLO ' . $ this -> senderHost ) ; } else { $ this -> sendData ( 'HELO ' . $ this -> senderHost ) ; } if ( $ this -> getReplyCode ( $ response ) !== '250' ) { throw new ezcMailTransportSmtpException ( "HELO/EHLO failed with error: {$response}." ) ; } if ( $ this -> doAuthenticate ) { if ( $ this -> options -> preferredAuthMethod !== self :: AUTH_AUTO ) { $ this -> auth ( $ this -> options -> preferredAuthMethod ) ; } else { preg_match ( "/250-AUTH[= ](.*)/" , $ response , $ matches ) ; if ( count ( $ matches ) > 0 ) { $ methods = explode ( ' ' , trim ( $ matches [ 1 ] ) ) ; } if ( count ( $ matches ) === 0 || count ( $ methods ) === 0 ) { throw new ezcMailTransportSmtpException ( 'SMTP server does not accept the AUTH command.' ) ; } $ authenticated = false ; $ methods = $ this -> sortAuthMethods ( $ methods ) ; foreach ( $ methods as $ method ) { if ( $ this -> auth ( $ method ) === true ) { $ authenticated = true ; break ; } } if ( $ authenticated === false ) { throw new ezcMailTransportSmtpException ( 'SMTP server did not respond correctly to any of the authentication methods ' . implode ( ', ' , $ methods ) . '.' ) ; } } } $ this -> status = self :: STATUS_AUTHENTICATED ; }
|
Performs the initial handshake with the SMTP server and authenticates the user if login data is provided to the constructor .
|
9,260
|
protected function authCramMd5 ( ) { $ this -> sendData ( 'AUTH CRAM-MD5' ) ; if ( $ this -> getReplyCode ( $ response ) !== '334' ) { throw new ezcMailTransportSmtpException ( 'SMTP server does not accept AUTH CRAM-MD5.' ) ; } $ serverDigest = trim ( substr ( $ response , 4 ) ) ; $ clientDigest = hash_hmac ( 'md5' , base64_decode ( $ serverDigest ) , $ this -> password ) ; $ login = base64_encode ( "{$this->user} {$clientDigest}" ) ; $ this -> sendData ( $ login ) ; if ( $ this -> getReplyCode ( $ error ) !== '235' ) { throw new ezcMailTransportSmtpException ( 'SMTP server did not accept the provided username and password.' ) ; } return true ; }
|
Tries to login to the SMTP server with AUTH CRAM - MD5 and returns true if successful .
|
9,261
|
protected function authNtlm ( ) { if ( ! ezcBaseFeatures :: hasExtensionSupport ( 'mcrypt' ) ) { throw new ezcBaseExtensionNotFoundException ( 'mcrypt' , null , "PHP not compiled with --with-mcrypt." ) ; } $ msg1 = base64_encode ( $ this -> authNtlmMessageType1 ( $ this -> senderHost , $ this -> serverHost ) ) ; $ this -> sendData ( "AUTH NTLM {$msg1}" ) ; if ( $ this -> getReplyCode ( $ serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException ( 'SMTP server does not accept AUTH NTLM.' ) ; } $ msg2 = base64_decode ( trim ( substr ( $ serverResponse , 4 ) ) ) ; $ parts = array ( substr ( $ msg2 , 0 , 8 ) , substr ( $ msg2 , 8 , 4 ) , substr ( $ msg2 , 12 , 8 ) , substr ( $ msg2 , 20 , 4 ) , substr ( $ msg2 , 24 , 8 ) , substr ( $ msg2 , 32 ) ) ; $ challenge = $ parts [ 4 ] ; $ msg3 = base64_encode ( $ this -> authNtlmMessageType3 ( $ challenge , $ this -> user , $ this -> password , $ this -> senderHost , $ this -> serverHost ) ) ; $ this -> sendData ( $ msg3 ) ; if ( $ this -> getReplyCode ( $ serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException ( 'SMTP server did not allow NTLM authentication.' ) ; } }
|
Tries to login to the SMTP server with AUTH NTLM and returns true if successful .
|
9,262
|
protected function authLogin ( ) { $ this -> sendData ( 'AUTH LOGIN' ) ; if ( $ this -> getReplyCode ( $ error ) !== '334' ) { throw new ezcMailTransportSmtpException ( 'SMTP server does not accept AUTH LOGIN.' ) ; } $ this -> sendData ( base64_encode ( $ this -> user ) ) ; if ( $ this -> getReplyCode ( $ error ) !== '334' ) { throw new ezcMailTransportSmtpException ( "SMTP server did not accept login: {$this->user}." ) ; } $ this -> sendData ( base64_encode ( $ this -> password ) ) ; if ( $ this -> getReplyCode ( $ error ) !== '235' ) { throw new ezcMailTransportSmtpException ( 'SMTP server did not accept the provided username and password.' ) ; } return true ; }
|
Tries to login to the SMTP server with AUTH LOGIN and returns true if successful .
|
9,263
|
protected function authPlain ( ) { $ digest = base64_encode ( "\0{$this->user}\0{$this->password}" ) ; $ this -> sendData ( "AUTH PLAIN {$digest}" ) ; if ( $ this -> getReplyCode ( $ error ) !== '235' ) { throw new ezcMailTransportSmtpException ( 'SMTP server did not accept the provided username and password.' ) ; } return true ; }
|
Tries to login to the SMTP server with AUTH PLAIN and returns true if successful .
|
9,264
|
public function disconnect ( ) { if ( $ this -> status != self :: STATUS_NOT_CONNECTED ) { $ this -> sendData ( 'QUIT' ) ; $ replyCode = $ this -> getReplyCode ( $ error ) !== '221' ; fclose ( $ this -> connection ) ; $ this -> status = self :: STATUS_NOT_CONNECTED ; if ( $ replyCode ) { throw new ezcMailTransportSmtpException ( "QUIT failed with error: $error." ) ; } } }
|
Sends the QUIT command to the server and breaks the connection .
|
9,265
|
protected function cmdData ( ) { if ( $ this -> status === self :: STATUS_AUTHENTICATED ) { $ this -> sendData ( 'DATA' ) ; if ( $ this -> getReplyCode ( $ error ) !== '354' ) { throw new ezcMailTransportSmtpException ( "DATA failed with error: $error." ) ; } } }
|
Sends the DATA command to the SMTP server .
|
9,266
|
protected function getData ( ) { $ data = '' ; $ line = '' ; $ loops = 0 ; if ( is_resource ( $ this -> connection ) ) { while ( ( strpos ( $ data , self :: CRLF ) === false || ( string ) substr ( $ line , 3 , 1 ) !== ' ' ) && $ loops < 100 ) { $ line = fgets ( $ this -> connection , 512 ) ; $ data .= $ line ; $ loops ++ ; } return $ data ; } throw new ezcMailTransportSmtpException ( 'Could not read from SMTP stream. It was probably terminated by the host.' ) ; }
|
Returns data received from the connection stream .
|
9,267
|
protected function authNtlmMessageType1 ( $ workstation , $ domain ) { $ parts = array ( "NTLMSSP\x00" , "\x01\x00\x00\x00" , "\x07\x32\x00\x00" , $ this -> authNtlmSecurityBuffer ( $ domain , 32 + strlen ( $ workstation ) ) , $ this -> authNtlmSecurityBuffer ( $ workstation , 32 ) , $ workstation , $ domain ) ; return implode ( "" , $ parts ) ; }
|
Generates an NTLM type 1 message .
|
9,268
|
protected function authNtlmResponse ( $ challenge , $ password ) { $ password = chunk_split ( $ password , 1 , "\x00" ) ; $ password = hash ( 'md4' , $ password , true ) ; $ password .= str_repeat ( "\x00" , 21 - strlen ( $ password ) ) ; $ td = mcrypt_module_open ( 'des' , '' , 'ecb' , '' ) ; $ iv = mcrypt_create_iv ( mcrypt_enc_get_iv_size ( $ td ) , MCRYPT_RAND ) ; $ response = '' ; for ( $ i = 0 ; $ i < 21 ; $ i += 7 ) { $ packed = '' ; for ( $ p = $ i ; $ p < $ i + 7 ; $ p ++ ) { $ packed .= str_pad ( decbin ( ord ( substr ( $ password , $ p , 1 ) ) ) , 8 , '0' , STR_PAD_LEFT ) ; } $ key = '' ; for ( $ p = 0 ; $ p < strlen ( $ packed ) ; $ p += 7 ) { $ s = substr ( $ packed , $ p , 7 ) ; $ b = $ s . ( ( substr_count ( $ s , '1' ) % 2 ) ? '0' : '1' ) ; $ key .= chr ( bindec ( $ b ) ) ; } mcrypt_generic_init ( $ td , $ key , $ iv ) ; $ response .= mcrypt_generic ( $ td , $ challenge ) ; mcrypt_generic_deinit ( $ td ) ; } mcrypt_module_close ( $ td ) ; return $ response ; }
|
Calculates an NTLM response to be used in the creation of the NTLM type 3 message .
|
9,269
|
protected function authNtlmSecurityBuffer ( $ text , $ offset ) { return pack ( 'v' , strlen ( $ text ) ) . pack ( 'v' , strlen ( $ text ) ) . pack ( 'V' , $ offset ) ; }
|
Creates an NTLM security buffer information string .
|
9,270
|
public function hyperlink ( $ row , $ col , $ sheet = 0 ) { $ link = isset ( $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] [ $ row ] [ $ col ] [ 'hyperlink' ] ) ? $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] [ $ row ] [ $ col ] [ 'hyperlink' ] : false ; if ( $ link ) { return $ link [ 'link' ] ; } return '' ; }
|
get hyperlink if cell is hyperlinked
|
9,271
|
public function remove ( $ name ) { $ names = ( array ) $ name ; foreach ( $ names as $ name ) { if ( Arr :: key ( $ name , $ this -> _assets ) ) { unset ( $ this -> _assets [ $ name ] ) ; } } }
|
Removes assets from collection .
|
9,272
|
function resetChangeHistory ( $ attribute ) { if ( $ this -> propertyExists ( $ attribute , 'changes' ) ) { $ this -> setPropertyFor ( $ attribute , 'changes' , [ ] , null , false ) ; } return $ this ; }
|
resetChangeHistory clears the change history for an attribute
|
9,273
|
function propertyExists ( $ attribute , $ property ) { return array_key_exists ( $ attribute , $ this -> __attributes ) && array_key_exists ( $ property , $ this -> __attributes [ $ attribute ] ) ; }
|
propertyExists determines if an attribute property has been set .
|
9,274
|
function get ( $ name , $ default = null ) { $ map = array_map ( function ( $ name ) use ( $ default ) { if ( $ this -> __isset ( $ name ) ) { return $ this -> __attributes [ $ name ] [ 'value' ] ; } elseif ( $ this -> propertyExists ( $ name , 'default' ) ) { return $ this -> __attributes [ $ name ] [ 'default' ] ; } return ( null === $ default ) ? null : $ default ; } , ( array ) $ name ) ; return count ( $ map ) > 1 ? $ map : $ map [ 0 ] ; }
|
get returns attributes value or if attribute value is null returns default value if given
|
9,275
|
function set ( $ attribute , $ value = null ) { $ attributes = is_array ( $ attribute ) ? $ attribute : [ $ attribute => $ value ] ; foreach ( $ attributes as $ attr => $ val ) { if ( $ this -> getPropertyFor ( $ attr , 'accepts' ) ) { $ acceptsConstraint = new Attributes \ Constraint \ Accepts ( $ this -> getPropertyFor ( $ attr , 'accepts' ) ) ; if ( ! $ acceptsConstraint -> isValid ( $ val ) ) { throw new InvalidArgumentException ( __CLASS__ . " does not accept {$val} as value for the property {$attr}" ) ; } } if ( $ this -> getPropertyFor ( $ attr , 'minimum' ) ) { $ minimumConstraint = new Attributes \ Constraint \ Minimum ( $ this -> getPropertyFor ( $ attr , 'minimum' ) ) ; if ( ! $ minimumConstraint -> isValid ( $ val ) ) { throw new InvalidArgumentException ( __CLASS__ . " does not accept {$val} as value for the property {$attr}" ) ; } } if ( $ this -> getPropertyFor ( $ attr , 'maximum' ) ) { $ maximumConstraint = new Attributes \ Constraint \ Maximum ( $ this -> getPropertyFor ( $ attr , 'maximum' ) ) ; if ( ! $ maximumConstraint -> isValid ( $ val ) ) { throw new InvalidArgumentException ( __CLASS__ . " does not accept {$val} as value for the property {$attr}" ) ; } } $ this -> setPropertyFor ( $ attr , 'value' , $ val , 'set' ) ; } return $ this ; }
|
set attributes value
|
9,276
|
function push ( $ attribute , $ value ) { if ( ! $ this -> has ( $ attribute ) ) { return $ this ; } $ new = $ this -> get ( $ attribute ) ; if ( ! is_array ( $ new ) && ! $ new instanceof Traversable ) { return $ this ; } $ new [ ] = $ value ; $ this -> setPropertyFor ( $ attribute , 'value' , $ new , 'push' ) ; return $ this ; }
|
push a new value onto end of array
|
9,277
|
private function getPropertyFor ( $ attribute , $ property ) { return $ this -> propertyExists ( $ attribute , $ property ) ? $ this -> __attributes [ $ attribute ] [ $ property ] : null ; }
|
getPropertyFor returns an attribute property by name
|
9,278
|
private function setPropertyFor ( $ attribute , $ property , $ value , $ action , $ changeTracking = true ) { if ( ! $ this -> has ( $ attribute ) ) { return ; } if ( $ changeTracking ) { $ this -> __attributes [ $ attribute ] [ 'changes' ] [ ] = [ 'action' => $ action , 'from' => $ this -> get ( $ attribute ) , 'to' => $ value , 'when' => new DateTime ( 'now' , new DateTimezone ( 'UTC' ) ) ] ; } $ this -> __attributes [ $ attribute ] [ $ property ] = $ value ; }
|
setPropertyFor sets an attribute property value
|
9,279
|
public function get ( array $ options = [ ] ) { $ pagination = '' ; if ( isset ( $ options [ 'page' ] ) && is_int ( $ options [ 'page' ] ) ) { $ pagination = '?page=' . $ options [ 'page' ] ; } if ( isset ( $ options [ 'key' ] ) ) { return $ this -> client -> get ( 'plugin-licenses/' . $ options [ 'key' ] . $ pagination ) ; } return $ this -> client -> get ( 'plugin-licenses' . $ pagination ) ; }
|
Gets one or more licenses for the given Craft ID account
|
9,280
|
protected static function pem2Der ( $ pemData ) { $ begin = 'CERTIFICATE-----' ; $ end = '-----END' ; $ pemData1 = substr ( $ pemData , strpos ( $ pemData , $ begin ) + strlen ( $ begin ) ) ; $ pemData2 = substr ( $ pemData1 , 0 , strpos ( $ pemData1 , $ end ) ) ; $ derData = base64_decode ( ( string ) $ pemData2 ) ; return $ derData ; }
|
pem2Der Transforma o certificado do formato PEM para o formato DER .
|
9,281
|
protected static function xBase128 ( $ abIn , $ qIn , $ flag ) { $ abc = $ abIn ; if ( $ qIn > 127 ) { $ abc = self :: xBase128 ( $ abc , floor ( $ qIn / 128 ) , false ) ; } $ qIn2 = $ qIn % 128 ; if ( $ flag ) { $ abc [ ] = $ qIn2 ; } else { $ abc [ ] = 0x80 | $ qIn2 ; } return $ abc ; }
|
xBase128 Retorna o dado convertido em asc .
|
9,282
|
protected static function printHex ( $ value ) { $ tabVal = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' ] ; $ hex = '' ; for ( $ i = 0 ; $ i < strlen ( $ value ) ; $ i ++ ) { $ lsig = ord ( substr ( $ value , $ i , 1 ) ) % 16 ; $ msig = ( ord ( substr ( $ value , $ i , 1 ) ) - $ lsig ) / 16 ; $ lessSig = $ tabVal [ $ lsig ] ; $ moreSig = $ tabVal [ $ msig ] ; $ hex .= $ moreSig . $ lessSig ; } return $ hex ; }
|
Retorna o valor em caracteres hexadecimais .
|
9,283
|
public function editAction ( ) { $ model = $ this -> loadModel ( ) ; if ( $ model -> isObjectNew ( ) ) { $ this -> _forward ( 'noroute' ) ; return ; } if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ postData = $ this -> getRequest ( ) -> getPost ( ) ; try { foreach ( $ this -> preprocessPostData ( $ postData ) as $ key => $ value ) { $ model -> setDataUsingMethod ( $ key , $ value ) ; } $ model -> save ( ) ; $ this -> _redirectUrl ( $ this -> getHelper ( ) -> getGridUrl ( ) ) ; $ this -> _getSession ( ) -> addSuccess ( 'Saved Successfully' ) ; return ; } catch ( Exception $ e ) { if ( $ e instanceof Zend_Db_Statement_Exception && $ e -> getChainedException ( ) instanceof PDOException ) { $ e = $ e -> getChainedException ( ) ; } Mage :: logException ( $ e ) ; $ this -> _getSession ( ) -> addError ( $ e -> getMessage ( ) ) ; } } $ this -> loadLayout ( ) ; $ this -> renderLayout ( ) ; }
|
Edit an existing record
|
9,284
|
public function deleteAction ( ) { $ model = $ this -> loadModel ( ) ; if ( $ model -> isObjectNew ( ) ) { $ this -> _forward ( 'noroute' ) ; return ; } try { $ model -> delete ( ) ; $ this -> _redirectUrl ( $ this -> getHelper ( ) -> getGridUrl ( ) ) ; $ this -> _getSession ( ) -> addSuccess ( 'Deleted Successfully' ) ; } catch ( Exception $ e ) { if ( $ e instanceof Zend_Db_Statement_Exception && $ e -> getChainedException ( ) instanceof PDOException ) { $ e = $ e -> getChainedException ( ) ; } Mage :: logException ( $ e ) ; $ this -> _getSession ( ) -> addError ( $ e -> getMessage ( ) ) ; $ this -> _redirectUrl ( $ this -> getHelper ( ) -> getEditUrl ( $ model ) ) ; } }
|
Delete an existing record
|
9,285
|
public function invoke ( Callable $ callable ) { $ reflection = $ this -> reflectCallable ( $ callable ) ; $ args = [ ] ; foreach ( $ reflection -> getParameters ( ) as $ param ) { $ type = $ param -> getClass ( ) -> getName ( ) ; if ( in_array ( $ type , $ this -> resolving ) ) { throw new \ LogicException ( "Recursive dependency: $type is currently instatiating." ) ; } $ args [ ] = ( $ param -> allowsNull ( ) && ! isset ( $ this [ $ type ] ) ) ? null : $ this [ $ type ] ; } return call_user_func_array ( $ callable , $ args ) ; }
|
Invoke a callable and injects dependencies
|
9,286
|
public function offsetGet ( $ class ) { if ( ! isset ( $ this -> factories [ $ class ] ) && ! isset ( $ this -> instances [ $ class ] ) ) { throw new \ InvalidArgumentException ( "$class has not been defined" ) ; } if ( isset ( $ this -> instances [ $ class ] ) ) { return $ this -> instances [ $ class ] ; } array_push ( $ this -> resolving , $ class ) ; $ object = $ this -> invoke ( $ this -> factories [ $ class ] ) ; array_pop ( $ this -> resolving ) ; return $ object ; }
|
get a dependency for the supplied class
|
9,287
|
public function offsetSet ( $ class , $ factory ) { if ( is_callable ( $ factory ) ) { $ this -> factories [ $ class ] = $ factory ; } else if ( is_object ( $ factory ) ) { $ this -> instances [ $ class ] = $ factory ; } else { throw new \ InvalidArgumentException ( "Dependency supplied is neither a callable or an object" ) ; } }
|
Registers a dependency for injection
|
9,288
|
protected function reflectCallable ( $ callable ) { if ( is_string ( $ callable ) && strpos ( $ callable , '::' ) ) { $ callable = explode ( '::' , $ callable , 2 ) ; } if ( is_a ( $ callable , 'Closure' ) ) { $ reflection = new \ ReflectionFunction ( $ callable ) ; } else if ( is_object ( $ callable ) ) { $ reflection = new \ ReflectionMethod ( get_class ( $ callable ) , '__invoke' ) ; } else if ( is_array ( $ callable ) && count ( $ callable ) == 2 ) { $ reflection = new \ ReflectionMethod ( ( is_object ( $ callable [ 0 ] ) ? get_class ( $ callable [ 0 ] ) : $ callable [ 0 ] ) , $ callable [ 1 ] ) ; } else if ( is_string ( $ callable ) && function_exists ( $ callable ) ) { $ reflection = new \ ReflectionFunction ( $ callable ) ; } return $ reflection ; }
|
Reflect a callable
|
9,289
|
public function run ( ) { Model :: unguard ( ) ; try { foreach ( $ this -> seederClasses as $ seederClass ) { $ this -> parentSeeder -> call ( $ seederClass ) ; } } finally { Model :: reguard ( ) ; } }
|
Run seeders .
|
9,290
|
protected function checkForDeleted ( Builder $ query ) { if ( request ( ) -> has ( 'deleted' ) && request ( ) -> input ( 'deleted' ) === '1' ) $ query = $ query -> onlyTrashed ( ) ; return $ query ; }
|
Check for deleted records option
|
9,291
|
public function turn ( $ toggle ) { if ( preg_match_all ( '/^(on|off) (all)?\s?(debug|info|notice|warn|error|critical|alert|emergency)$/' , $ toggle , $ matches ) ) { $ flag = $ matches [ 1 ] [ 0 ] ; $ all = $ matches [ 2 ] [ 0 ] ; $ name = $ matches [ 3 ] [ 0 ] ; $ this -> sieve -> toggle ( $ flag , $ name ) ; if ( $ all === 'all' ) { self :: $ SIEVE -> toggle ( $ flag , $ name ) ; } } else { throw new \ InvalidArgumentException ( "Invalid format: $toggle" ) ; } }
|
Sets logging state of the given severity level in a readable format
|
9,292
|
public function every ( $ key , $ operator = null , $ value = null ) { if ( func_num_args ( ) === 1 ) { $ callback = $ this -> valueRetriever ( $ key ) ; foreach ( $ this -> items as $ k => $ v ) { if ( ! $ callback ( $ v , $ k ) ) { return false ; } } return true ; } if ( func_num_args ( ) === 2 ) { $ value = $ operator ; $ operator = '=' ; } return $ this -> every ( $ this -> operatorForWhere ( $ key , $ operator , $ value ) ) ; }
|
Determine if all items in the collection pass the given test .
|
9,293
|
public function mapToGroups ( callable $ callback ) { $ groups = $ this -> map ( $ callback ) -> reduce ( function ( $ groups , $ pair ) { $ groups [ key ( $ pair ) ] [ ] = reset ( $ pair ) ; return $ groups ; } , [ ] ) ; return ( new static ( $ groups ) ) -> map ( [ $ this , 'make' ] ) ; }
|
Run a grouping map over the items .
|
9,294
|
private function register_commands ( ) { foreach ( $ this -> commands as $ class_name ) { \ WP_CLI :: add_command ( $ class_name :: COMMAND_NAME , $ class_name ) ; } }
|
Register All commands
|
9,295
|
public function ajax_register ( ) { if ( AjaxBase :: is_ajax ( ) ) { foreach ( $ this -> ajax_controllers as $ class_name ) { $ instance = $ class_name :: get_instance ( ) ; $ instance -> register ( ) ; } } }
|
Register ajax actions
|
9,296
|
public function scan_post_type ( ) { $ flg = false ; foreach ( $ this -> namespaces as $ ns => $ dir ) { $ dir = $ dir . '/' . $ ns . '/ThePost' ; if ( is_dir ( $ dir ) ) { foreach ( scandir ( $ dir ) as $ file ) { if ( ! preg_match ( '/^\./u' , $ file ) ) { $ base_class = str_replace ( '.php' , '' , $ file ) ; $ class_name = $ ns . '\\ThePost\\' . $ base_class ; if ( class_exists ( $ class_name ) && $ this -> is_sub_class_of ( $ class_name , PostHelper :: class ) ) { $ this -> post_type_to_override [ $ this -> str -> camel_to_hyphen ( $ base_class ) ] = $ class_name ; $ flg = true ; } } } } } if ( $ flg ) { add_action ( 'the_post' , [ $ this , 'the_post' ] ) ; } }
|
Scan original post type to override
|
9,297
|
public function run ( ) { foreach ( $ this -> jobs as $ job ) { $ this -> worker -> run ( $ job ) ; } while ( $ this -> worker -> isRunning ( ) ) { } return $ this ; }
|
run all jobs using the worker
|
9,298
|
public function put ( $ key , $ data ) { $ key = $ this -> getKeyCode ( $ key ) ; $ data = json_encode ( $ data ) ; $ this -> memcacheObj -> set ( $ key , $ data ) ; }
|
Put data into cache
|
9,299
|
public function has ( $ key ) { $ key = $ this -> getKeyCode ( $ key ) ; $ value = $ this -> memcacheObj -> get ( $ key ) ; if ( ! $ value ) { return false ; } else { return true ; } }
|
Check if the key exists in cache
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.