idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
50,400
public static function maybe_split_parameters ( $ params ) { if ( ! \ is_array ( $ params ) ) { $ params = ( array ) \ preg_split ( self :: RE_PARAMETER_SPLITTING , $ params , - 1 , PREG_SPLIT_NO_EMPTY ) ; } return $ params ; }
If necessary split the passed parameters string into an array .
50,401
protected static function tokenize ( array $ parts ) { $ tokens = [ ] ; $ index = 0 ; foreach ( $ parts as $ part ) { if ( \ preg_match ( self :: _RE_SPACE , $ part ) ) { $ tokens [ $ index ] = new Token ( $ part , Token :: SPACE ) ; } elseif ( \ preg_match ( self :: _RE_PUNCTUATION , $ part ) ) { $ tokens [ $ index ] ...
Turns the array of strings into an array of tokens .
50,402
protected static function is_preceeded_by ( $ type , array $ tokens , $ index , $ steps = 1 ) { return $ index - $ steps >= 0 && $ type === $ tokens [ $ index - $ steps ] -> type ; }
Checks if the predecessor of the current token is of a certain type .
50,403
protected static function is_not_preceeded_by ( $ type , array $ tokens , $ index , $ steps = 1 ) { return $ index - $ steps >= 0 && $ type !== $ tokens [ $ index - $ steps ] -> type ; }
Checks if the predecessor of the current token is not of a certain type .
50,404
public function unload ( ) { $ reassembled_text = '' ; foreach ( $ this -> text as $ token ) { $ reassembled_text .= $ token -> value ; } $ this -> clear ( ) ; return $ reassembled_text ; }
Returns the complete text as a string and clears the parser .
50,405
public function update ( $ tokens ) { foreach ( $ tokens as $ index => $ token ) { $ this -> text [ $ index ] = $ this -> text [ $ index ] -> with_value ( $ token -> value ) ; } }
Updates the value field for all matching tokens .
50,406
public function get_words ( $ abc = self :: ALLOW_ALL_LETTERS , $ caps = self :: ALLOW_ALL_CAPS , $ comps = self :: ALLOW_COMPOUNDS ) { if ( empty ( $ this -> text ) ) { return [ ] ; } $ tokens = [ ] ; foreach ( $ this -> get_type ( Token :: WORD ) as $ index => $ token ) { if ( $ this -> conforms_to_letters_policy ( $...
Retrieves all tokens of the type word .
50,407
protected function conforms_to_letters_policy ( Token $ token , $ policy ) { return $ this -> check_policy ( $ token , $ policy , self :: ALLOW_ALL_LETTERS , self :: REQUIRE_ALL_LETTERS , self :: NO_ALL_LETTERS , function ( $ value ) { return \ preg_replace ( self :: _RE_HTML_LETTER_CONNECTORS , '' , $ value ) ; } ) ; ...
Check if the value of the token conforms to the given policy for letters .
50,408
protected function conforms_to_caps_policy ( Token $ token , $ policy ) { return $ this -> check_policy ( $ token , $ policy , self :: ALLOW_ALL_CAPS , self :: REQUIRE_ALL_CAPS , self :: NO_ALL_CAPS , $ this -> current_strtoupper ) ; }
Check if the value of the token conforms to the given policy for all - caps words .
50,409
protected function conforms_to_compounds_policy ( Token $ token , $ policy ) { return $ this -> check_policy ( $ token , $ policy , self :: ALLOW_COMPOUNDS , self :: NO_COMPOUNDS , self :: REQUIRE_COMPOUNDS , function ( $ value ) { return \ preg_replace ( '/-/S' , '' , $ value ) ; } ) ; }
Check if the value of the token conforms to the given policy for compound words .
50,410
protected function check_policy ( Token $ token , $ policy , $ permissive_policy , $ equal_policy , $ non_equal_policy , callable $ transform_token ) { if ( $ permissive_policy === $ policy ) { return true ; } $ transformed = $ transform_token ( $ token -> value ) ; return ( $ equal_policy === $ policy && $ transformed...
Check if the value of the token conforms to the given policy .
50,411
public function get_type ( $ type ) { $ tokens = [ ] ; foreach ( $ this -> text as $ index => $ token ) { if ( $ token -> type === $ type ) { $ tokens [ $ index ] = $ token ; } } return $ tokens ; }
Retrieves all tokens of the given type .
50,412
private static function get_top_level_domains_from_file ( $ path ) { $ domains = [ ] ; if ( \ file_exists ( $ path ) ) { $ file = new \ SplFileObject ( $ path ) ; while ( ! $ file -> eof ( ) ) { $ line = $ file -> fgets ( ) ; if ( \ preg_match ( '#^[a-zA-Z0-9][a-zA-Z0-9-]*$#' , $ line , $ matches ) ) { $ domains [ ] = ...
Load a list of top - level domains from a file .
50,413
public static function top_level_domains ( ) { if ( empty ( self :: $ top_level_domains_pattern ) ) { self :: $ top_level_domains_pattern = self :: get_top_level_domains_from_file ( __DIR__ . '/IANA/tlds-alpha-by-domain.txt' ) ; } return self :: $ top_level_domains_pattern ; }
Retrieves a pattern matching all valid top - level domains .
50,414
private function update_dash_spacing_regex ( $ parenthetical , $ parenthetical_space , $ interval , $ interval_space ) { $ this -> parenthetical_dash_spacing = "/ (?: \s ({$parenthetical}) \s ) /xu" ; $ this -> interval_dash_spacing = "/ (?: (?<=\S) # lookbehind assertion ({$interval})...
Update the dash spacing regular expression .
50,415
public function process_textnodes ( $ html , callable $ fixer , Settings $ settings , $ is_title = false , array $ body_classes = [ ] ) { if ( isset ( $ settings [ 'ignoreTags' ] ) && $ is_title && ( \ in_array ( 'h1' , $ settings [ 'ignoreTags' ] , true ) || \ in_array ( 'h2' , $ settings [ 'ignoreTags' ] , true ) ) )...
Applies specific fixes to all textnodes of the HTML fragment .
50,416
protected static function arrays_intersect ( array $ array1 , array $ array2 ) { foreach ( $ array1 as $ value ) { if ( isset ( $ array2 [ \ spl_object_hash ( $ value ) ] ) ) { return true ; } } return false ; }
Determines whether two object arrays intersect . The second array is expected to use the spl_object_hash for its keys .
50,417
public function handle_parsing_errors ( $ errno , $ errstr , $ errfile ) { if ( ! ( \ error_reporting ( ) & $ errno ) ) { return true ; } return $ errno & E_USER_WARNING && 0 === \ substr_compare ( $ errfile , 'DOMTreeBuilder.php' , - 18 ) ; }
Silently handle certain HTML parsing errors .
50,418
public function query_tags_to_ignore ( \ DOMXPath $ xpath , \ DOMNode $ initial_node , Settings $ settings ) { $ elements = [ ] ; $ query_parts = [ ] ; if ( ! empty ( $ settings [ 'ignoreTags' ] ) ) { $ query_parts [ ] = '//' . \ implode ( ' | //' , $ settings [ 'ignoreTags' ] ) ; } if ( ! empty ( $ settings [ 'ignoreC...
Retrieves an array of nodes that should be skipped during processing .
50,419
public function replace_node_with_html ( \ DOMNode $ node , $ content ) { $ result = $ node ; $ parent = $ node -> parentNode ; if ( empty ( $ parent ) ) { return $ node ; } $ content = RE :: unescape_tags ( \ htmlspecialchars ( $ content , ENT_NOQUOTES | ENT_HTML5 | ENT_SUBSTITUTE , 'UTF-8' , true ) ) ; \ set_error_ha...
Replaces the given node with HTML content . Uses the HTML5 parser .
50,420
public function get_registry ( ) { if ( ! isset ( $ this -> registry ) ) { $ this -> registry = new Default_Registry ( $ this -> get_hyphenator_cache ( ) ) ; } elseif ( $ this -> update_registry_cache ) { $ this -> registry -> update_hyphenator_cache ( $ this -> get_hyphenator_cache ( ) ) ; $ this -> update_registry_ca...
Retrieves the fix registry .
50,421
public function get_html5_parser ( ) { if ( ! isset ( $ this -> html5_parser ) ) { $ this -> html5_parser = new \ Masterminds \ HTML5 ( [ 'disable_html_ns' => true ] ) ; } return $ this -> html5_parser ; }
Retrieves the HTML5 parser instance .
50,422
public function get_hyphenator_cache ( ) { if ( ! isset ( $ this -> hyphenator_cache ) ) { $ this -> hyphenator_cache = new Hyphenator \ Cache ( ) ; } return $ this -> hyphenator_cache ; }
Retrieves the hyphenator cache .
50,423
private static function get_language_plugin_list ( $ path ) { $ languages = [ ] ; $ handle = \ opendir ( $ path ) ; if ( false === $ handle ) { return $ languages ; } $ file = \ readdir ( $ handle ) ; while ( $ file ) { if ( '.json' === \ substr ( $ file , - 5 ) ) { $ file_content = \ file_get_contents ( $ path . $ fil...
Retrieves the list of valid language plugins in the given directory .
50,424
public function set_hyphenator ( $ lang , Hyphenator $ hyphenator ) { $ this -> cache [ $ lang ] = $ hyphenator ; $ this -> changed = true ; }
Caches a Hyphenator instance .
50,425
public function get_hyphenator ( $ lang ) { if ( isset ( $ this -> cache [ $ lang ] ) ) { return $ this -> cache [ $ lang ] ; } return null ; }
Retrieves a cached Hyphenator .
50,426
protected function get_sequence ( $ pattern ) { $ characters = Strings :: mb_str_split ( str_replace ( '.' , '_' , $ pattern ) ) ; $ result = [ ] ; foreach ( $ characters as $ index => $ chr ) { if ( ctype_digit ( $ chr ) ) { $ result [ ] = $ chr ; } else { if ( ! isset ( $ characters [ $ index - 1 ] ) || ! ctype_digit...
Calculate patgen sequence from TeX hyphenation pattern .
50,427
protected function format_results ( array $ patterns , array $ exceptions , array $ comments ) { $ pattern_mapping = [ ] ; foreach ( $ patterns as $ pattern ) { $ segment = $ this -> get_segment ( $ pattern ) ; if ( ! isset ( $ pattern_mapping [ $ segment ] ) ) { $ pattern_mapping [ $ segment ] = $ this -> get_sequence...
Format hyphenation pattern file for wp - Typography .
50,428
protected function match_exceptions ( $ line , array & $ exceptions , $ line_no = 0 ) { if ( preg_match ( '/^\s*([' . $ this -> word_characters . '-]+)\s*}\s*(?:%.*)?$/u' , $ line , $ matches ) ) { $ exceptions [ ] = $ matches [ 1 ] ; return false ; } if ( preg_match ( '/^\s*((?:[' . $ this -> word_characters . '-]+\s*...
Try to match squences of TeX hyphenation exceptions .
50,429
protected function match_patterns ( $ line , array & $ patterns , $ line_no = 0 ) { if ( preg_match ( '/^\s*([' . $ this -> word_characters . ']+)\s*}\s*(?:%.*)?$/u' , $ line , $ matches ) ) { $ patterns [ ] = $ matches [ 1 ] ; return false ; } elseif ( preg_match ( '/^\s*}\s*(?:%.*)?$/u' , $ line , $ matches ) ) { ret...
Try to match a pattern .
50,430
protected function expand_macros ( $ line , array $ macros ) { if ( 0 < preg_match_all ( '/\\\(?<name>\w+)\{(?<arg>[^\}]+)\}/u' , $ line , $ matches , PREG_SET_ORDER ) ) { foreach ( $ matches as $ m ) { if ( ! empty ( $ macros [ $ m [ 'name' ] ] ) ) { $ expanded = preg_replace ( '/#1/' , $ m [ 'arg' ] , $ macros [ $ m ...
Replace macros in the given line .
50,431
public function convert ( ) { $ comments = [ ] ; $ patterns = [ ] ; $ exceptions = [ ] ; foreach ( $ this -> urls as $ url ) { $ this -> convert_single_file ( $ url , $ patterns , $ exceptions , $ comments ) ; } return $ this -> format_results ( $ patterns , $ exceptions , $ comments ) ; }
Convert the given TeX files .
50,432
protected function convert_single_file ( $ url , & $ patterns , & $ exceptions , & $ comments ) { if ( ! file_exists ( $ url ) && 404 === File_Operations :: get_http_response_code ( $ url ) ) { throw new \ RuntimeException ( "Error: unknown pattern file '{$url}'\n" ) ; } $ reading_patterns = false ; $ reading_exception...
Convert the given TeX file .
50,433
public function register_node_fix ( Node_Fix $ fix , $ group ) { if ( isset ( $ this -> node_fixes [ $ group ] ) ) { $ this -> node_fixes [ $ group ] [ ] = $ fix ; } else { throw new \ InvalidArgumentException ( "Invalid fixer group $group." ) ; } }
Registers a node fix .
50,434
public function apply_fixes ( \ DOMText $ textnode , Settings $ settings , $ is_title , $ is_feed ) { foreach ( $ this -> node_fixes as $ group => $ fixes ) { foreach ( $ fixes as $ fix ) { if ( ! $ is_feed || $ fix -> feed_compatible ( ) ) { $ fix -> apply ( $ textnode , $ settings , $ is_title ) ; } } } }
Applies typography fixes to a textnode .
50,435
public function set_tags_to_ignore ( $ tags = [ 'code' , 'head' , 'kbd' , 'object' , 'option' , 'pre' , 'samp' , 'script' , 'noscript' , 'noembed' , 'select' , 'style' , 'textarea' , 'title' , 'var' , 'math' ] ) { $ tags = array_filter ( array_map ( 'strtolower' , Strings :: maybe_split_parameters ( $ tags ) ) , 'ctype...
Sets tags for which the typography of their children will be left untouched .
50,436
public function set_smart_quotes_exceptions ( $ exceptions = [ "'tain't" => U :: APOSTROPHE . 'tain' . U :: APOSTROPHE . 't' , "'twere" => U :: APOSTROPHE . 'twere' , "'twas" => U :: APOSTROPHE . 'twas' , "'tis" => U :: APOSTROPHE . 'tis' , "'til" => U :: APOSTROPHE . 'til' , "'bout" => U :: APOSTROPHE . 'bout' , "'nuf...
Sets the list of exceptional words for smart quotes replacement . Mainly this is used for contractions beginning with an apostrophe .
50,437
protected function get_style ( $ style , $ expected_class , callable $ get_style , $ description ) { if ( $ style instanceof $ expected_class ) { $ object = $ style ; } else { $ object = $ get_style ( $ style , $ this ) ; } if ( ! \ is_object ( $ object ) || ! $ object instanceof $ expected_class ) { throw new \ Domain...
Retrieves an object from a given style .
50,438
public function set_smart_dashes_style ( $ style = Dash_Style :: TRADITIONAL_US ) { $ this -> dash_style = $ this -> get_style ( $ style , Settings \ Dashes :: class , [ Dash_Style :: class , 'get_styled_dashes' ] , 'dash' ) ; }
Sets the typographical conventions used by smart_dashes .
50,439
public function set_diacritic_language ( $ lang = 'en-US' ) { if ( isset ( $ this -> data [ 'diacriticLanguage' ] ) && $ this -> data [ 'diacriticLanguage' ] === $ lang ) { return ; } $ this -> data [ 'diacriticLanguage' ] = $ lang ; $ language_file_name = \ dirname ( __FILE__ ) . '/diacritics/' . $ lang . '.json' ; if...
Sets the language used for diacritics replacements .
50,440
public function set_diacritic_custom_replacements ( $ custom_replacements = [ ] ) { if ( ! \ is_array ( $ custom_replacements ) ) { $ custom_replacements = $ this -> parse_diacritics_replacement_string ( $ custom_replacements ) ; } $ this -> data [ 'diacriticCustomReplacements' ] = self :: array_map_assoc ( function ( ...
Sets up custom diacritics replacements .
50,441
private function parse_diacritics_replacement_string ( $ custom_replacements ) { return self :: array_map_assoc ( function ( $ key , $ replacement ) { if ( \ preg_match ( '/(?<kquo>"|\')(?<key>(?:(?!\k<kquo>).)+)\k<kquo>\s*=>\s*(?<rquo>"|\')(?<replacement>(?:(?!\k<rquo>).)+)\k<rquo>/' , $ replacement , $ match ) ) { $ ...
Parses a custom diacritics replacement string into an array .
50,442
protected static function array_map_assoc ( callable $ callback , array $ array ) { $ new = [ ] ; foreach ( $ array as $ k => $ v ) { $ u = $ callback ( $ k , $ v ) ; if ( ! empty ( $ u ) ) { $ new [ \ key ( $ u ) ] = \ current ( $ u ) ; } } return $ new ; }
Provides an array_map implementation with control over resulting array s keys .
50,443
private function parse_diacritics_rules ( array $ diacritics_rules , array & $ patterns , array & $ replacements ) { foreach ( $ diacritics_rules as $ needle => $ replacement ) { $ patterns [ ] = '/\b(?<!\w[' . U :: NO_BREAK_SPACE . U :: SOFT_HYPHEN . '])' . $ needle . '\b(?![' . U :: NO_BREAK_SPACE . U :: SOFT_HYPHEN ...
Parse an array of diacritics rules .
50,444
public function set_units ( $ units = [ ] ) { $ this -> data [ 'units' ] = Strings :: maybe_split_parameters ( $ units ) ; $ this -> custom_units = $ this -> update_unit_pattern ( $ this -> data [ 'units' ] ) ; }
Sets the list of units to keep together with their values .
50,445
protected function update_unit_pattern ( array $ units ) { foreach ( $ units as $ index => $ unit ) { $ units [ $ index ] = \ preg_quote ( $ unit , '/' ) ; } $ custom_units = \ implode ( '|' , $ units ) ; $ custom_units .= ! empty ( $ custom_units ) ? '|' : '' ; return $ custom_units ; }
Update pattern for matching custom units .
50,446
public function set_initial_quote_tags ( $ tags = [ 'p' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' , 'blockquote' , 'li' , 'dd' , 'dt' ] ) { if ( ! \ is_array ( $ tags ) ) { $ tags = \ preg_split ( '/[^a-z0-9]+/' , $ tags , - 1 , PREG_SPLIT_NO_EMPTY ) ; } $ this -> data [ 'initialQuoteTags' ] = \ array_change_key_case (...
Sets the list of tags where initial quotes and guillemets should be styled .
50,447
public function get_hash ( $ max_length = 16 , $ raw_output = true ) { $ hash = \ md5 ( \ json_encode ( $ this ) , $ raw_output ) ; if ( $ max_length < \ strlen ( $ hash ) && $ max_length > 0 ) { $ hash = \ substr ( $ hash , 0 , $ max_length ) ; } return $ hash ; }
Retrieves a unique hash value for the current settings .
50,448
public static function get_styled_dashes ( $ style , Settings $ settings ) { if ( isset ( self :: $ styles [ $ style ] ) ) { return new Simple_Dashes ( self :: $ styles [ $ style ] [ self :: _PARENTHETICAL ] , self :: $ styles [ $ style ] [ self :: _PARENTHETICAL_SPACE ] , self :: $ styles [ $ style ] [ self :: _INTERV...
Creates a new Dashes object in the given style .
50,449
public function forceMimeType ( $ link , $ mimeType ) { $ resource = new \ core_kernel_classes_Resource ( \ tao_helpers_Uri :: decode ( $ link ) ) ; return $ resource -> editPropertyValues ( new \ core_kernel_classes_Property ( MediaService :: PROPERTY_MIME_TYPE ) , $ mimeType ) ; }
Force the mime - type of a resource
50,450
protected function getZipImporter ( ) { if ( ! $ this -> zipImporter ) { $ this -> zipImporter = new SharedStimulusPackageImporter ( ) ; $ this -> zipImporter -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } return $ this -> zipImporter ; }
Get the zip importer for shared stimulus
50,451
public function createMediaInstance ( $ fileSource , $ classUri , $ language , $ label = null , $ mimeType = null , $ userId = null ) { $ clazz = $ this -> getClass ( $ classUri ) ; if ( is_null ( $ label ) ) { $ label = $ fileSource instanceof File ? $ fileSource -> getBasename ( ) : basename ( $ fileSource ) ; } $ md...
Create a media instance from a file and define its class and language
50,452
protected function getLink ( \ core_kernel_classes_Resource $ resource ) { $ instance = $ resource -> getUniquePropertyValue ( $ this -> getProperty ( self :: PROPERTY_LINK ) ) ; return $ instance instanceof \ core_kernel_classes_Resource ? $ instance -> getUri ( ) : ( string ) $ instance ; }
Returns the link of a media resource
50,453
public function editInstance ( ) { $ this -> defaultData ( ) ; $ clazz = $ this -> getCurrentClass ( ) ; $ instance = $ this -> getCurrentInstance ( ) ; $ myFormContainer = new editInstanceForm ( $ clazz , $ instance ) ; $ myForm = $ myFormContainer -> getForm ( ) ; if ( $ myForm -> isSubmited ( ) ) { if ( $ myForm -> ...
Show the form to edit an instance show also a preview of the media
50,454
public function getFile ( ) { if ( ! $ this -> hasGetParameter ( 'uri' ) ) { throw new \ common_exception_Error ( 'invalid media identifier' ) ; } $ uri = urldecode ( $ this -> getGetParameter ( 'uri' ) ) ; $ mediaSource = new MediaSource ( array ( ) ) ; $ fileInfo = $ mediaSource -> getFileInfo ( $ uri ) ; $ fileManag...
Get the file stream associated to given uri GET parameter
50,455
public function edit ( Resource $ instance , $ form , $ userId = null ) { try { $ uploadedFile = $ this -> fetchUploadedFile ( $ form ) ; $ xmlFile = $ this -> getSharedStimulusFile ( $ uploadedFile ) ; $ this -> getUploadService ( ) -> remove ( $ uploadedFile ) ; SharedStimulusImporter :: isValidSharedStimulus ( $ xml...
Edit a shared stimulus package
50,456
public static function embedAssets ( $ originalXml ) { $ basedir = dirname ( $ originalXml ) . DIRECTORY_SEPARATOR ; $ xmlDocument = new XmlDocument ( ) ; $ xmlDocument -> load ( $ originalXml , true ) ; $ images = $ xmlDocument -> getDocumentComponent ( ) -> getComponentsByClassName ( 'img' ) ; $ objects = $ xmlDocume...
Embed external resources into the XML
50,457
private function getSharedStimulusFile ( $ filePath ) { \ helpers_TimeOutHelper :: setTimeOutLimit ( \ helpers_TimeOutHelper :: LONG ) ; $ extractPath = $ this -> extractArchive ( $ filePath ) ; \ helpers_TimeOutHelper :: reset ( ) ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ ex...
Get the shared stimulus file with assets from the zip
50,458
protected static function secureEncode ( $ basedir , $ source ) { $ components = parse_url ( $ source ) ; if ( ! isset ( $ components [ 'scheme' ] ) ) { if ( \ tao_helpers_File :: securityCheck ( $ source , false ) ) { if ( file_exists ( $ basedir . $ source ) ) { return 'data:' . \ tao_helpers_File :: getMimeType ( $ ...
Verify paths and encode the file
50,459
public function import ( $ class , $ form , $ userId = null ) { try { $ uploadedFile = $ this -> fetchUploadedFile ( $ form ) ; $ resource = new core_kernel_classes_Class ( $ form instanceof Form ? $ form -> getValue ( 'classUri' ) : $ form [ 'classUri' ] ) ; try { \ helpers_TimeOutHelper :: setTimeOutLimit ( \ helpers...
Starts the import based on the form values
50,460
protected function extractArchive ( $ archiveFile ) { if ( $ archiveFile instanceof File ) { if ( ! $ archiveFile -> exists ( ) ) { throw new \ common_Exception ( 'Unable to open archive ' . '/' . $ archiveFile -> getPrefix ( ) ) ; } $ tmpDir = \ tao_helpers_File :: createTempDir ( ) ; $ tmpFilePath = $ tmpDir . uniqid...
Unzip archive from the upload form
50,461
protected function init ( ) { $ structure = $ this -> imapFetchstructure ( ) ; $ this -> structure = $ structure ; if ( isset ( $ structure -> parts ) ) { $ countSection = count ( $ structure -> parts ) ; $ this -> countAttachment = $ countSection - 1 ; } $ this -> getCountSection ( ) ; $ this -> getHeader ( ) ; $ this...
Main process .
50,462
protected function getHeader ( ) { $ header = $ this -> imapFetchOverview ( ) ; $ this -> header = $ header [ 0 ] ; $ this -> header -> details = $ this -> imapHeaderInfo ( ) ; }
Get headers in the current message .
50,463
protected function getCountSection ( ) { $ this -> getRecursiveSections ( $ this -> structure ) ; $ sections = array ( ) ; if ( ! isset ( $ this -> section ) ) { $ this -> section [ 0 ] = array ( 0 ) ; } foreach ( $ this -> section as $ array ) { foreach ( $ array as $ section ) { $ sections [ ] = $ section ; } } $ sec...
Get count section .
50,464
protected function getRecursiveSections ( $ obj , $ before = null ) { if ( ! isset ( $ obj -> parts ) ) { return ; } $ countParts = count ( $ obj -> parts ) ; $ out = array ( ) ; $ beforeSave = $ before ; foreach ( $ obj -> parts as $ key => $ subObj ) { if ( ! isset ( $ beforeSave ) ) { $ before = ( $ key + 1 ) ; } el...
Bypasses the recursive parts current message .
50,465
protected function getSections ( $ type = null ) { if ( ! $ type ) { return $ this -> section ; } $ types = null ; switch ( $ type ) { case self :: SECTION_ATTACHMENTS : $ types = TypeAttachments :: get ( ) ; break ; case self :: SECTION_BODY : $ types = TypeBody :: get ( ) ; break ; default : throw new ImapClientExcep...
Gets all sections or if parameter is specified sections by type .
50,466
protected function getAttachments ( ) { $ attachments = array ( ) ; foreach ( $ this -> getSections ( self :: SECTION_ATTACHMENTS ) as $ section ) { $ obj = $ this -> getSection ( $ section ) ; $ attachment = new IncomingMessageAttachment ( $ obj ) ; $ objNew = new \ stdClass ( ) ; $ objNew -> name = $ attachment -> na...
Get attachments in the current message .
50,467
protected function getBody ( ) { $ objNew = new \ stdClass ( ) ; $ i = 1 ; $ subType = new SubtypeBody ( ) ; foreach ( $ this -> getSections ( self :: SECTION_BODY ) as $ section ) { $ obj = $ this -> getSection ( $ section , array ( 'class' => $ subType ) ) ; $ subtype = strtolower ( $ obj -> __get ( 'structure' ) -> ...
Get body current message .
50,468
public function getSection ( $ section , $ options = null ) { if ( isset ( $ options [ 'class' ] ) ) { $ sectionObj = new $ options [ 'class' ] ( ) ; if ( $ sectionObj instanceof Section ) { } else { throw new ImapClientException ( 'Incoming class not instance \SSilence\ImapClient\Section' ) ; } } else { $ sectionObj =...
Get a section message .
50,469
protected function getSectionStructureFromIncomingStructure ( $ section ) { $ pos = strpos ( $ section , '.' ) ; if ( $ pos === false ) { $ section = ( int ) $ section ; if ( $ section === 0 ) { return $ this -> structure ; } return $ this -> structure -> parts [ ( $ section - 1 ) ] ; } $ sections = explode ( '.' , $ s...
Get section structure from incoming structure .
50,470
protected function imapFetchOverview ( ) { if ( isset ( $ this -> id ) && isset ( $ this -> uid ) ) { throw new ImapClientException ( 'What to use id or uid?' ) ; } $ sequence = null ; $ options = null ; if ( isset ( $ this -> id ) && ! isset ( $ this -> uid ) ) { $ sequence = $ this -> id ; $ options = null ; } if ( !...
Fetch a quick Overview on a message .
50,471
protected function decodeHeader ( ) { if ( isset ( $ this -> header -> subject ) ) { $ this -> header -> subject = $ this -> mimeHeaderDecode ( $ this -> header -> subject ) ; } if ( isset ( $ this -> header -> details -> subject ) ) { $ this -> header -> details -> subject = $ this -> mimeHeaderDecode ( $ this -> head...
Decode header .
50,472
protected function decodeAttachments ( ) { foreach ( $ this -> attachments as $ key => $ attachment ) { switch ( $ attachment -> info -> structure -> encoding ) { case 3 : $ this -> attachments [ $ key ] -> body = imap_base64 ( $ attachment -> body ) ; break ; case 4 : $ this -> attachments [ $ key ] -> body = quoted_p...
Decode attachments .
50,473
protected function decodeBody ( ) { if ( is_object ( $ this -> message ) ) { foreach ( $ this -> message -> types as $ typeMessage ) { if ( is_object ( $ this -> message -> $ typeMessage ) ) { switch ( $ this -> message -> $ typeMessage -> structure -> encoding ) { case 3 : $ this -> message -> $ typeMessage -> body = ...
Decode body .
50,474
public function prepareMailbox ( $ remote_system_name = null , $ port = null , $ flags = null , $ mailbox_name = null ) { if ( isset ( $ remote_system_name ) && is_array ( $ remote_system_name ) ) { $ config = $ remote_system_name ; if ( isset ( $ config [ 'remote_system_name' ] ) ) { $ remote_system_name = $ config [ ...
Prepare Mailbox string
50,475
public function send ( ) { $ mimeMessage = $ this -> createMimeMessage ( ) ; $ this -> message = $ mimeMessage ; $ this -> preparingSend ( ) ; imap_mail ( $ this -> properties -> to , $ this -> properties -> subject , $ this -> properties -> message , $ this -> properties -> additional_headers , $ this -> properties ->...
Send message via imap_mail .
50,476
public function createMimeMessage ( ) { $ this -> createBody ( ) ; $ envelopeAllowedType = array ( 'remail' , 'return_path' , 'date' , 'from' , 'reply_to' , 'in_reply_to' , 'subject' , 'to' , 'cc' , 'bcc' , 'message_id' , 'custom_headers' , ) ; $ envelope = Helper :: preparingProperties ( $ this -> envelope , $ envelop...
Create Mime Message .
50,477
public function createBody ( ) { $ this -> envelope [ 'date' ] = '29.03.2017' ; $ this -> envelope [ 'message_id' ] = '81' ; $ part1 [ 'type' ] = TYPEMULTIPART ; $ part1 [ 'subtype' ] = 'mixed' ; $ part3 [ 'type' ] = TYPETEXT ; $ part3 [ 'subtype' ] = 'plain' ; $ part3 [ 'description' ] = 'description3' ; $ part3 [ 'co...
Create body .
50,478
protected function getName ( ) { if ( $ this -> _incomingObject -> structure -> ifdparameters ) { foreach ( $ this -> _incomingObject -> structure -> dparameters as $ param ) { if ( strtolower ( $ param -> attribute ) === 'filename' ) { $ this -> name = $ param -> value ; break ; } } } elseif ( $ this -> _incomingObjec...
Returns the name of the attachment along with file extension .
50,479
public function connectDefault ( $ mailbox , $ username , $ password , $ encryption = null ) { $ connect = new ImapConnect ( ) ; if ( $ encryption === ImapClient :: ENCRYPT_SSL ) { $ connect -> prepareFlags ( ImapConnect :: SERVICE_IMAP , ImapConnect :: ENCRYPT_SSL , ImapConnect :: NOVALIDATE_CERT ) ; } ; if ( $ encryp...
The default connection . Not used a lot of imap connection options . Use only ENCRYPT_SSL and VALIDATE_CERT .
50,480
public function getFolders ( $ separator = null , $ type = 0 ) { if ( preg_match ( '/^{.+}/' , $ this -> mailbox , $ matches ) ) { $ mailbox = $ matches [ 0 ] ; } else { $ mailbox = $ this -> mailbox ; } ; $ folders = imap_list ( $ this -> imap , $ mailbox , "*" ) ; if ( $ type == 2 ) { return $ folders ; } ; if ( $ ty...
Returns all available folders
50,481
public function getBriefInfoMessages ( ) { $ array = imap_headers ( $ this -> imap ) ; $ newArray = [ ] ; foreach ( $ array as $ key => $ string ) { $ newArray [ ] = [ 'id' => $ key + 1 , 'info' => $ string ] ; } ; return $ newArray ; }
Returns an array of brief information about each message in the current mailbox .
50,482
public function getMessagesByCriteria ( $ criteria = '' , $ number = 0 , $ start = 0 , $ order = 'DESC' ) { $ emails = array ( ) ; $ result = imap_search ( $ this -> imap , $ criteria ) ; if ( ! $ result ) { throw new ImapClientException ( 'Messages not found. Or this criteria not supported on your email server.' ) ; }...
Get Messages by Criteria
50,483
public function saveAttachmentsMessagesBySubject ( $ subject , $ dir = null , $ charset = null ) { $ criteria = 'SUBJECT "' . $ subject . '"' ; $ ids = imap_search ( $ this -> imap , $ criteria , null , $ charset ) ; if ( ! $ ids ) { throw new ImapClientException ( 'Messages not found. Or this criteria not supported on...
Save Attachments Messages By Subject
50,484
public function getMessage ( $ id , $ decode = IncomingMessage :: DECODE ) { $ this -> checkMessageId ( $ id ) ; $ this -> incomingMessage = new IncomingMessage ( $ this -> imap , $ id , $ decode ) ; return $ this -> incomingMessage ; }
Returns one email by given id
50,485
public function getSection ( $ id , $ section ) { $ incomingMessage = new IncomingMessage ( $ this -> imap , $ id ) ; return $ incomingMessage -> getSection ( $ section ) ; }
Get a section of the message
50,486
public function saveAttachments ( $ options = null ) { if ( ! isset ( $ options [ 'dir' ] ) ) { $ dir = __DIR__ . DIRECTORY_SEPARATOR ; } else { $ dir = $ options [ 'dir' ] ; } ; if ( ! isset ( $ options [ 'incomingMessage' ] ) ) { $ incomingMessage = $ this -> incomingMessage ; } else { $ incomingMessage = $ options [...
Save attachments one incoming message
50,487
public function moveMessages ( $ ids , $ target ) { if ( imap_mail_move ( $ this -> imap , implode ( "," , $ ids ) , $ target , CP_UID ) === false ) return false ; return imap_expunge ( $ this -> imap ) ; }
Move given message in new folder
50,488
public function addFolder ( $ name , $ subscribe = false ) { $ success = imap_createmailbox ( $ this -> imap , $ this -> mailbox . $ name ) ; if ( $ success && $ subscribe ) { $ success = imap_subscribe ( $ this -> imap , $ this -> mailbox . $ name ) ; } return $ success ; }
Add a new folder
50,489
public function renameFolder ( $ name , $ newname ) { return imap_renamemailbox ( $ this -> imap , $ this -> mailbox . $ name , $ this -> mailbox . $ newname ) ; }
Rename a folder
50,490
public function purge ( ) { if ( $ this -> folder == $ this -> getTrash ( ) || strtolower ( $ this -> folder ) == "spam" ) { if ( imap_delete ( $ this -> imap , '1:*' ) === false ) { return false ; } return imap_expunge ( $ this -> imap ) ; } else { if ( imap_mail_move ( $ this -> imap , '1:*' , $ this -> getTrash ( ) ...
Clean up trash and spam folder
50,491
public function getAllEmailAddresses ( ) { $ saveCurrentFolder = $ this -> folder ; $ emails = array ( ) ; foreach ( $ this -> getFolders ( ) as $ folder ) { $ this -> selectFolder ( $ folder ) ; foreach ( $ this -> getMessages ( false ) as $ message ) { $ emails [ ] = $ message [ 'from' ] ; $ emails = array_merge ( $ ...
Returns all email addresses
50,492
public function saveMessageInSent ( $ header , $ body ) { return imap_append ( $ this -> imap , $ this -> mailbox . $ this -> getSent ( ) , $ header . "\r\n" . $ body . "\r\n" , "\\Seen" ) ; }
Save email in sent
50,493
protected function getTrash ( ) { foreach ( $ this -> getFolders ( ) as $ folder ) { if ( in_array ( strtolower ( $ folder ) , array ( 'trash' , 'inbox.trash' , 'papierkorb' ) ) ) { return $ folder ; } } $ this -> addFolder ( 'Trash' ) ; return 'Trash' ; }
Get trash folder
50,494
protected function getMessageHeader ( $ id ) { $ count = $ this -> countMessages ( ) ; for ( $ i = 1 ; $ i <= $ count ; $ i ++ ) { $ uid = imap_uid ( $ this -> imap , $ i ) ; if ( $ uid == $ id ) { $ header = imap_headerinfo ( $ this -> imap , $ i ) ; return $ header ; } } return false ; }
Fetch message by id
50,495
protected function toAddress ( $ headerinfos ) { $ email = "" ; $ name = "" ; if ( isset ( $ headerinfos -> mailbox ) && isset ( $ headerinfos -> host ) ) { $ email = $ headerinfos -> mailbox . "@" . $ headerinfos -> host ; } if ( ! empty ( $ headerinfos -> personal ) ) { $ name = imap_mime_header_decode ( $ headerinfo...
Convert imap given address into string
50,496
protected function arrayToAddress ( $ addresses ) { $ addressesAsString = array ( ) ; foreach ( $ addresses as $ address ) { $ addressesAsString [ ] = $ this -> toAddress ( $ address ) ; } return $ addressesAsString ; }
Converts imap given array of addresses as strings
50,497
protected function embedImages ( $ email ) { $ html_embed = $ email [ 'body' ] ; foreach ( $ email [ 'attachments' ] as $ key => $ attachment ) { if ( strtolower ( $ attachment [ 'disposition' ] ) == 'inline' && ! empty ( $ attachment [ 'reference' ] ) ) { $ file = $ this -> getAttachment ( $ email [ 'id' ] , $ key ) ;...
HTML embed inline images
50,498
public function getUnreadMessages ( $ read = true ) { $ emails = [ ] ; $ result = imap_search ( $ this -> imap , 'UNSEEN' ) ; if ( ! $ result ) { throw new ImapClientException ( 'No read messages were found.' ) ; } ; $ ids = '' ; $ countId = count ( $ result ) ; foreach ( $ result as $ key => $ id ) { $ emails [ ] = $ ...
Returns unseen emails in the current folder
50,499
public function getAllEmailAddresses ( array $ options = null ) { if ( ! isset ( $ options [ 'getFolders' ] [ 'separator' ] ) ) { $ options [ 'getFolders' ] [ 'separator' ] = '.' ; } ; if ( ! isset ( $ options [ 'getFolders' ] [ 'type' ] ) ) { $ options [ 'getFolders' ] [ 'type' ] = 1 ; } ; if ( ! isset ( $ options [ '...
Returns all email addresses in all folders