idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
59,400
|
public function monthTitle ( Month $ month ) { $ weekendClass = 'bm-calendar-weekend' ; $ monthName = self :: $ monthNames [ $ month -> value ( ) ] ; $ output = '<thead>' ; $ output .= '<tr>' ; $ output .= '<th colspan="7" class="bm-calendar-month-title">' . $ monthName . '</th>' ; $ output .= '</tr><tr>' ; for ( $ column = 0 ; $ column < 7 ; $ column ++ ) { $ day = ( $ column + $ this -> startDay - 1 ) % 7 + 1 ; if ( DayInterface :: SATURDAY === $ day || DayInterface :: SUNDAY === $ day ) { $ output .= '<th class="' . $ weekendClass . '">' ; } else { $ output .= '<th>' ; } $ output .= self :: $ dayNames [ $ day ] ; $ output .= '</th>' ; } $ output .= '</tr>' ; $ output .= '</thead>' ; return $ output ; }
|
Returns the markup for the header of a month table .
|
59,401
|
public function renderDay ( DayInterface $ day ) { $ classes = array ( ) ; $ dayOfWeek = $ day -> dayOfWeek ( ) ; if ( DayInterface :: SATURDAY === $ dayOfWeek || DayInterface :: SUNDAY === $ dayOfWeek ) { $ classes [ ] = 'bm-calendar-weekend' ; } foreach ( $ day -> getStates ( ) as $ state ) { $ classes [ ] = 'bm-calendar-state-' . $ state -> type ( ) ; } $ output = '<td>' ; if ( sizeof ( $ classes ) ) { $ output = '<td class="' . implode ( ' ' , $ classes ) . '">' ; } if ( $ day -> getAction ( ) ) { $ output .= '<a href="' . htmlentities ( $ day -> getAction ( ) ) . '">' . $ day . '</a>' ; } else { $ output .= $ day ; } $ output .= '</td>' ; return $ output ; }
|
Returns the markup for a single table cell .
|
59,402
|
public function renderMonth ( $ year , $ month ) { $ monthClass = sprintf ( 'bm-calendar-month-%02d' , $ month ) ; $ yearClass = sprintf ( 'bm-calendar-year-%04d' , $ year ) ; $ month = $ this -> calendar -> getMonth ( $ year , $ month ) ; $ days = $ this -> calendar -> getDays ( $ month ) ; $ column = 0 ; $ output = '<table class="bm-calendar ' . $ monthClass . ' ' . $ yearClass . '">' ; $ output .= $ this -> monthTitle ( $ month ) ; $ output .= '<tbody>' ; $ output .= '<tr>' ; $ blankCells = ( $ month -> startDay ( ) - $ this -> startDay + 7 ) % 7 ; while ( $ column < $ blankCells ) { $ output .= '<td class="bm-calendar-empty"></td>' ; $ column ++ ; } foreach ( $ days as $ day ) { if ( 1 !== $ day -> value ( ) && 0 === $ column ) { $ output .= '</tr><tr>' ; } $ output .= $ this -> renderDay ( $ day , $ column ) ; $ column = ( $ column + 1 ) % 7 ; } while ( $ column < 7 ) { $ output .= '<td class="bm-calendar-empty"></td>' ; $ column ++ ; } $ output .= '</tr>' ; $ output .= '</tbody>' ; $ output .= '</table>' ; return $ output ; }
|
Render a month table internally .
|
59,403
|
protected function getCommandConfig ( $ commandKey ) { if ( isset ( $ this -> configsPerCommandKey [ $ commandKey ] ) ) { return $ this -> configsPerCommandKey [ $ commandKey ] ; } $ config = new Config ( $ this -> config -> get ( 'default' ) -> toArray ( ) , true ) ; if ( $ this -> config -> __isset ( $ commandKey ) ) { $ commandConfig = $ this -> config -> get ( $ commandKey ) ; $ config -> merge ( $ commandConfig ) ; } $ this -> configsPerCommandKey [ $ commandKey ] = $ config ; return $ config ; }
|
Gets the config for given command key
|
59,404
|
public function saveMessage ( $ mail ) { $ messageHtml = quoted_printable_decode ( $ mail -> getMessage ( ) -> getBodyHtml ( true ) ) ; $ this -> createFolder ( $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) ) ; $ this -> storeFile ( $ messageHtml , $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: MESSAGE_HTML_FILE_NAME ) ; $ messageJson = json_encode ( $ mail -> getMessage ( ) ) ; $ this -> storeFile ( $ messageJson , $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: MESSAGE_FILE_NAME ) ; return $ this ; }
|
Save file to spool path
|
59,405
|
protected function createFolder ( $ folderPath ) { if ( ! @ mkdir ( $ folderPath , 0777 , true ) && ! is_dir ( $ folderPath ) ) { throw new FileSystemException ( new Phrase ( 'Folder can not be created, but does not exist.' ) ) ; } return $ this ; }
|
Create a folder path if folder does not exist
|
59,406
|
protected function storeFile ( $ data , $ filePath ) { if ( ! is_dir ( dirname ( $ filePath ) ) ) { $ this -> createFolder ( dirname ( $ filePath ) ) ; } for ( $ i = 0 ; $ i < $ this -> _config -> getHostRetryLimit ( ) ; $ i ++ ) { $ fp = @ fopen ( $ filePath , 'x' ) ; if ( $ fp !== false ) { if ( false === fwrite ( $ fp , $ data ) ) { return false ; } fclose ( $ fp ) ; return $ filePath ; } } throw new FileSystemException ( new Phrase ( 'Unable to create a file for enqueuing Message' ) ) ; }
|
Stores string data at a given path
|
59,407
|
public function loadMessage ( $ mail ) { $ localFilePath = $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: MESSAGE_FILE_NAME ; $ messageJson = $ this -> restoreFile ( $ localFilePath ) ; if ( empty ( $ messageJson ) ) { $ messageJson = '{}' ; } $ messageData = json_decode ( $ messageJson ) ; $ message = $ this -> _objectManager -> create ( 'Shockwavemk\Mail\Base\Model\Mail\Message' ) ; if ( ! empty ( $ messageData -> type ) ) { $ message -> setType ( $ messageData -> type ) ; } if ( ! empty ( $ messageData -> txt ) ) { $ message -> setBodyText ( $ messageData -> txt ) ; } if ( ! empty ( $ messageData -> html ) ) { $ message -> setBodyHtml ( $ messageData -> html ) ; } if ( ! empty ( $ messageData -> from ) ) { $ message -> setFrom ( $ messageData -> from ) ; } if ( ! empty ( $ messageData -> subject ) ) { $ message -> setSubject ( $ messageData -> subject ) ; } if ( ! empty ( $ messageData -> recipients ) ) { foreach ( $ messageData -> recipients as $ recipient ) { $ message -> addTo ( $ recipient ) ; } } return $ message ; }
|
Restore a message from filesystem
|
59,408
|
private function restoreFile ( $ filePath ) { try { for ( $ i = 0 ; $ i < $ this -> _config -> getHostRetryLimit ( ) ; ++ $ i ) { @ fopen ( $ filePath , 'x' ) ; if ( false === $ fileData = file_get_contents ( $ filePath ) ) { return null ; } return $ fileData ; } } catch ( \ Exception $ e ) { return null ; } return null ; }
|
Load binary file data from a given file path
|
59,409
|
public function saveMail ( $ mail ) { $ mailJson = json_encode ( $ mail ) ; $ this -> createFolder ( $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) ) ; return $ this -> storeFile ( $ mailJson , $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: MAIL_FILE_NAME ) ; }
|
Convert a mail object to json and store it at mail folder path
|
59,410
|
public function loadAttachment ( $ mail , $ path ) { $ attachmentFolder = DIRECTORY_SEPARATOR . self :: ATTACHMENT_PATH ; $ localFilePath = $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . $ attachmentFolder . $ path ; return $ this -> restoreFile ( $ localFilePath ) ; }
|
Load binary data from storage provider
|
59,411
|
public function getAttachments ( $ mail ) { if ( empty ( $ mail -> getId ( ) ) ) { return [ ] ; } $ folderFileList = $ this -> getMailLocalFolderFileList ( $ mail ) ; $ attachments = [ ] ; foreach ( $ folderFileList as $ filePath => $ fileMetaData ) { $ filePath = $ fileMetaData [ 'path' ] ; $ attachment = $ this -> _objectManager -> create ( '\Shockwavemk\Mail\Base\Model\Mail\Attachment' ) ; $ attachment -> setFilePath ( $ filePath ) ; $ attachment -> setMail ( $ mail ) ; foreach ( $ fileMetaData as $ attributeKey => $ attributeValue ) { $ attachment -> setData ( $ attributeKey , $ attributeValue ) ; } $ attachments [ $ filePath ] = $ attachment ; } return $ attachments ; }
|
Returns attachments for a given mail
|
59,412
|
protected function getMailLocalFolderFileList ( $ mail ) { $ spoolFolder = $ this -> _config -> getHostSpoolerFolderPath ( ) . DIRECTORY_SEPARATOR . $ mail -> getId ( ) . DIRECTORY_SEPARATOR . self :: ATTACHMENT_PATH ; if ( ! is_dir ( $ spoolFolder ) ) { $ this -> createFolder ( $ spoolFolder ) ; } $ objects = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ spoolFolder ) , RecursiveIteratorIterator :: LEAVES_ONLY , FilesystemIterator :: SKIP_DOTS ) ; $ files = [ ] ; foreach ( $ objects as $ path => $ object ) { if ( $ object -> getFilename ( ) != '.' && $ object -> getFilename ( ) != '..' ) { $ filePath = str_replace ( $ spoolFolder , '' , $ path ) ; $ file = [ 'name' => $ object -> getFilename ( ) , 'path' => $ path ] ; $ files [ $ filePath ] = $ file ; } } return $ files ; }
|
Get file list for a given mail
|
59,413
|
public function saveAttachments ( $ mail ) { $ attachments = $ mail -> getAttachments ( ) ; foreach ( $ attachments as $ attachment ) { $ this -> saveAttachment ( $ attachment ) ; } return $ this ; }
|
Save all attachments of a given mail
|
59,414
|
public function saveAttachment ( $ attachment ) { $ binaryData = $ attachment -> getBinary ( ) ; $ mail = $ attachment -> getMail ( ) ; $ folderPath = $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: ATTACHMENT_PATH ; $ this -> createFolder ( $ folderPath ) ; $ filePath = $ this -> storeFile ( $ binaryData , $ this -> getMailFolderPathById ( $ mail -> getId ( ) ) . DIRECTORY_SEPARATOR . self :: ATTACHMENT_PATH . DIRECTORY_SEPARATOR . basename ( $ attachment -> getFilePath ( ) ) ) ; $ attachment -> setFilePath ( $ filePath ) ; }
|
Save an attachment binary to a file in host temp folder
|
59,415
|
public function getRootLocalFolderFileList ( ) { $ spoolFolder = $ this -> _config -> getHostSpoolerFolderPath ( ) ; $ objects = new IteratorIterator ( new DirectoryIterator ( $ spoolFolder ) ) ; $ files = [ ] ; foreach ( $ objects as $ path => $ object ) { if ( $ object -> getFilename ( ) != '.' && $ object -> getFilename ( ) != '..' ) { $ shortFilePath = str_replace ( $ spoolFolder , '' , $ object -> getPathName ( ) ) ; $ files [ ] = [ 'name' => $ object -> getFilename ( ) , 'localPath' => $ object -> getPathName ( ) , 'remotePath' => $ shortFilePath , 'modified' => $ object -> getMTime ( ) ] ; } } return $ files ; }
|
Get Folder list for host spooler folder path
|
59,416
|
public function getLocalFileListForPath ( $ localPath ) { $ files = [ ] ; $ objects = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ localPath ) , RecursiveIteratorIterator :: LEAVES_ONLY , FilesystemIterator :: SKIP_DOTS ) ; foreach ( $ objects as $ path => $ object ) { if ( $ object -> getFilename ( ) != '.' && $ object -> getFilename ( ) != '..' ) { $ hostTempFolderPath = $ this -> _config -> getHostSpoolerFolderPath ( ) ; $ remoteFilePath = str_replace ( $ hostTempFolderPath , '/' , $ object -> getPathName ( ) ) ; $ file = [ 'name' => $ object -> getFilename ( ) , 'localPath' => $ object -> getPathName ( ) , 'remotePath' => $ remoteFilePath , 'modified' => $ object -> getMTime ( ) ] ; $ files [ $ object -> getFilename ( ) ] = $ file ; } } return $ files ; }
|
Get list of files in a local file path
|
59,417
|
public function deleteLocalFiles ( $ localPath ) { $ it = new RecursiveDirectoryIterator ( $ localPath , RecursiveDirectoryIterator :: SKIP_DOTS ) ; $ files = new RecursiveIteratorIterator ( $ it , RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ file ) { if ( $ file -> isDir ( ) ) { rmdir ( $ file -> getRealPath ( ) ) ; } else { unlink ( $ file -> getRealPath ( ) ) ; } } rmdir ( $ localPath ) ; }
|
Deletes all local stored files
|
59,418
|
public function setAttribute ( $ userId , $ name , $ value ) { $ row = $ this -> connection -> fetchAssoc ( 'SELECT id FROM fusio_user_attribute WHERE name = :name' , [ 'name' => $ name ] ) ; if ( empty ( $ row ) ) { $ this -> connection -> insert ( 'fusio_user_attribute' , [ 'user_id' => $ userId , 'name' => $ name , 'value' => $ value , ] ) ; } else { $ this -> connection -> update ( 'fusio_user_attribute' , [ 'user_id' => $ userId , 'name' => $ name , 'value' => $ value , ] , [ 'id' => $ row [ 'id' ] ] ) ; } }
|
Sets a specific user attribute
|
59,419
|
private function getSubmittedVersionNumber ( RequestInterface $ request ) { $ accept = $ request -> getHeader ( 'Accept' ) ; $ matches = array ( ) ; preg_match ( '/^application\/vnd\.([a-z.-_]+)\.v([\d]+)\+([a-z]+)$/' , $ accept , $ matches ) ; return isset ( $ matches [ 2 ] ) ? $ matches [ 2 ] : null ; }
|
Returns the version number which was submitted by the client in the accept header field
|
59,420
|
private function parseTxt ( $ txt ) { $ result = [ ] ; $ lines = array_map ( 'trim' , mb_split ( '\r\n|\n|\r' , $ txt ) ) ; foreach ( $ lines as $ key => $ line ) { $ line = mb_substr ( $ line , 0 , self :: MAX_LENGTH_RULE ) ; $ line = explode ( '#' , $ line , 2 ) [ 0 ] ; $ result [ ] = $ this -> parseLine ( $ line ) ; unset ( $ lines [ $ key ] ) ; } return in_array ( true , $ result , true ) ; }
|
Client robots . txt
|
59,421
|
public function accessOverride ( ) { if ( strpos ( $ this -> scheme , 'http' ) === 0 ) { switch ( floor ( $ this -> code / 100 ) * 100 ) { case 300 : case 400 : return self :: DIRECTIVE_ALLOW ; case 500 : return self :: DIRECTIVE_DISALLOW ; } } return false ; }
|
Check if the code overrides the robots . txt file
|
59,422
|
protected function prepare_form_data ( ) { $ this -> data = [ ] ; foreach ( $ this -> fields as $ field ) { $ this -> data [ $ field -> get_id ( ) ] = $ field -> get_value ( ) ; } }
|
Prepare data from the storage .
|
59,423
|
protected function make_fields_validation ( ) { foreach ( $ this -> fields as $ key => $ field ) { if ( $ this -> maybe_skip_field ( $ field ) ) { continue ; } if ( $ rules = $ field -> get_option ( 'validate' ) ) { $ attributes = ( new Rules_Parser ( $ field ) ) -> parse ( $ rules ) ; $ field -> set_attribute ( $ attributes ) ; } } }
|
HTML5 validation attributes based on validate .
|
59,424
|
protected function resolve_flash_errors ( $ name ) { if ( ! $ this -> session ) { return ; } if ( ! $ this -> session -> get ( $ name ) instanceof WP_Error ) { return ; } $ this -> errors = new WP_Error ; $ errors = $ this -> session -> get ( $ name ) ; foreach ( $ errors -> errors as $ key => $ error ) { $ this -> add_error ( $ key , $ error ) ; } }
|
Resolve flash errors for the display .
|
59,425
|
protected function fill_old_values ( ) { if ( ! $ this -> session ) { return ; } if ( 0 === count ( ( array ) $ this -> session -> get_old_input ( ) ) ) { return ; } foreach ( $ this -> fields as $ key => $ field ) { if ( ! is_null ( $ old = $ this -> session -> get_old_input ( $ key ) ) ) { $ field -> set_value ( $ old ) ; } } }
|
Fill old input values .
|
59,426
|
protected function prepare_submitted_data ( $ fields , array $ data , $ clear_missing ) { $ submitted = [ ] ; foreach ( $ fields as $ field ) { if ( $ this -> maybe_skip_field ( $ field ) ) { continue ; } $ value = array_key_exists ( $ field -> get_id ( ) , $ data ) ? $ data [ $ field -> get_id ( ) ] : null ; if ( false === $ value ) { $ value = null ; } elseif ( is_scalar ( $ value ) ) { $ value = ( string ) $ value ; } $ sanitized = $ field -> get_sanitization_value ( $ value ) ; if ( $ field -> is_group ( ) ) { $ submitted [ $ field -> get_id ( ) ] = $ this -> get_group_values ( $ field , $ sanitized ) ; } else { $ submitted [ $ field -> get_id ( ) ] = $ sanitized ; } } if ( $ clear_missing ) { $ submitted = array_filter ( $ submitted , function ( $ value ) { return ! is_null ( $ value ) ; } ) ; } return $ submitted ; }
|
Returns submitted data from input .
|
59,427
|
protected function get_group_values ( Field_Contract $ group , $ data ) { if ( ! $ group -> is_group ( ) || ! $ group -> get_option ( 'fields' ) ) { return null ; } if ( ! is_array ( $ data ) ) { return null ; } $ group = clone $ group ; $ i = 0 ; $ values = [ ] ; foreach ( array_values ( $ data ) as $ _data ) { if ( ! is_array ( $ _data ) || empty ( $ _data ) ) { continue ; } $ group -> index = $ i ; $ fields = array_map ( function ( $ args ) use ( $ group ) { return $ this -> config -> get_field_in_group ( $ group , $ args [ 'id' ] ) ; } , $ group -> get_option ( 'fields' ) ) ; $ values [ $ i ] = Utils :: filter_blank ( $ this -> prepare_submitted_data ( $ fields , $ _data , true ) ) ; $ i ++ ; } return array_filter ( $ values ) ; }
|
Gets values of a group with given data .
|
59,428
|
protected function maybe_skip_field ( Field_Contract $ field ) { if ( in_array ( $ field -> get_type ( ) , static :: $ skip_proccess_types ) ) { return true ; } if ( $ field -> is_disabled ( ) || false === $ field -> get_option ( 'save_field' , true ) ) { return true ; } $ id = $ field -> get_id ( ) ; if ( $ group = $ field -> get_group ( ) ) { $ id = $ group -> get_id ( ) . '.' . $ id ; } if ( in_array ( $ id , $ this -> skip_proccess_fields ) ) { return true ; } return false ; }
|
Check if given field is skipped in the process .
|
59,429
|
protected function get_validate_rules ( ) { $ rules = [ ] ; foreach ( $ this -> fields as $ key => $ field ) { if ( 'group' === $ field -> get_type ( ) ) { continue ; } if ( $ rule = $ field -> get_option ( 'validate' ) ) { $ key = $ field -> is_repeatable ( ) ? $ key . '.*' : $ key ; $ rules [ $ key ] = $ rule ; } } return $ rules ; }
|
Returns the validator rules .
|
59,430
|
protected function validate_use_validator ( array $ data , array $ rules ) { if ( empty ( $ rules ) ) { return ; } $ validator = new Validator ( $ data , $ rules ) ; $ validator -> labels ( $ this -> fields -> pluck ( 'name' , 'id' ) -> all ( ) ) ; if ( $ validator -> fails ( ) ) { foreach ( $ rules as $ key => $ rule ) { $ this -> add_error ( $ key , $ validator -> errors ( $ key ) ) ; } } }
|
Validate fields use validate parameter .
|
59,431
|
protected function validate_by_callbacks ( array $ data , array $ callbacks ) { foreach ( $ callbacks as $ key => $ callback ) { $ validity = new WP_Error ; $ value = array_key_exists ( $ key , $ data ) ? $ data [ $ key ] : null ; $ callback ( $ validity , $ value ) ; if ( is_wp_error ( $ validity ) && count ( $ validity -> errors ) > 0 ) { $ this -> add_error ( $ key , $ validity -> get_error_messages ( ) ) ; } } }
|
Validate fields use validate_cb parameter .
|
59,432
|
public function has_error ( $ key ) { return $ this -> errors && array_key_exists ( $ key , $ this -> errors -> errors ) && count ( $ this -> errors -> errors [ $ key ] ) > 0 ; }
|
Determnies if given field has any errors .
|
59,433
|
public function isPreferred ( ) { if ( ( $ host = $ this -> export ( ) ) === null ) { return $ this -> base === $ this -> effective ; } $ parsed = parse_url ( $ host ) ; $ new = [ 'scheme' => isset ( $ parsed [ 'scheme' ] ) ? $ parsed [ 'scheme' ] : parse_url ( $ this -> base , PHP_URL_SCHEME ) , 'host' => isset ( $ parsed [ 'host' ] ) ? $ parsed [ 'host' ] : $ parsed [ 'path' ] , ] ; $ new [ 'port' ] = isset ( $ parsed [ 'port' ] ) ? $ parsed [ 'port' ] : getservbyname ( $ new [ 'scheme' ] , 'tcp' ) ; return $ this -> base == $ new [ 'scheme' ] . '://' . $ new [ 'host' ] . ':' . $ new [ 'port' ] ; }
|
Is preferred host?
|
59,434
|
public function getWithUriFallback ( ) { if ( ( $ get = $ this -> export ( ) ) !== null ) { return $ get ; } elseif ( $ this -> base !== $ this -> effective && parse_url ( $ this -> base , PHP_URL_HOST ) === ( $ host = parse_url ( $ this -> effective , PHP_URL_HOST ) ) ) { return getservbyname ( $ scheme = parse_url ( $ this -> effective , PHP_URL_SCHEME ) , 'tcp' ) === parse_url ( $ this -> effective , PHP_URL_PORT ) ? $ scheme . '://' . $ host : $ this -> effective ; } return parse_url ( $ this -> effective , PHP_URL_HOST ) ; }
|
Get Host falls back to Effective Request URI if not found
|
59,435
|
public function get_new_storage ( $ id , $ object_type = null ) { $ id = $ id ? : $ this -> context -> get_object_id ( ) ; return new Metadata_Storage ( $ id , $ object_type ? : $ this -> mb_object_type ( ) ) ; }
|
Returns new storage .
|
59,436
|
public function convertToFull ( $ fallbackBase ) { $ this -> encode ( ) ; if ( $ this -> validate ( ) ) { return $ this -> uri ; } elseif ( strpos ( $ this -> uri , '/' ) === 0 ) { $ relative = $ this -> uri ; $ this -> uri = $ fallbackBase ; return $ this -> base ( ) . $ relative ; } throw new \ InvalidArgumentException ( "Invalid URI `$this->uri`" ) ; }
|
Convert relative to full
|
59,437
|
private function baseToLowercase ( ) { if ( ( $ host = parse_url ( $ this -> uri , PHP_URL_HOST ) ) === null ) { return $ this -> uri ; } $ pos = strpos ( $ this -> uri , $ host ) + strlen ( $ host ) ; return $ this -> uri = substr_replace ( $ this -> uri , strtolower ( substr ( $ this -> uri , 0 , $ pos ) ) , 0 , $ pos ) ; }
|
Base uri to lowercase
|
59,438
|
public function validateIP ( $ ipAddress = null ) { if ( $ ipAddress === null ) { $ parsed = parse_url ( $ this -> uri ) ; $ ipAddress = isset ( $ parsed [ 'host' ] ) ? $ parsed [ 'host' ] : null ; } return ( filter_var ( $ ipAddress , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) || filter_var ( trim ( $ ipAddress , '[]' ) , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) ; }
|
Validate IPv4 or IPv6
|
59,439
|
public function getMethod ( $ routeId , $ version , $ method ) { if ( $ version == '*' || empty ( $ version ) ) { $ version = $ this -> methodTable -> getLatestVersion ( $ routeId ) ; } else { $ version = $ this -> methodTable -> getVersion ( $ routeId , $ version ) ; } if ( empty ( $ version ) ) { throw new StatusCode \ UnsupportedMediaTypeException ( 'Version does not exist' ) ; } return $ this -> methodTable -> getMethod ( $ routeId , $ version , $ method ) ; }
|
Returns the method configuration for the provide route version and request method
|
59,440
|
protected function apply_current_section ( Form $ form ) { if ( count ( $ this -> sections ) === 0 ) { return ; } foreach ( $ this -> sections as $ section ) { $ section -> options [ 'active' ] = false ; } $ current = $ this -> current_section_in_cookie ( $ form -> get_id ( ) ) ; if ( ! $ current && $ form -> get_config ( ) -> has_option ( 'active_section' ) ) { $ current = $ form -> get_config ( ) -> get_option ( 'active_section' ) ; } if ( ! $ current || ! isset ( $ this -> sections [ $ current ] ) ) { $ current = Arr :: first ( array_keys ( $ this -> sections ) ) ; } if ( $ section = $ this -> get_section ( $ current ) ) { $ section -> options [ 'active' ] = true ; } }
|
Set the current section .
|
59,441
|
protected function current_section_in_cookie ( $ id ) { if ( empty ( $ _COOKIE [ '_wplibs_current_sections' ] ) ) { return null ; } $ currents = json_decode ( sanitize_text_field ( wp_unslash ( $ _COOKIE [ '_wplibs_current_sections' ] ) ) , true ) ; if ( array_key_exists ( $ id , $ currents ) ) { return $ currents [ $ id ] ; } return null ; }
|
Resolve current section from the cookie .
|
59,442
|
protected function prepare_fields ( Form $ form ) { foreach ( $ form -> all ( ) as $ field ) { if ( ! $ field -> should_show ( ) ) { return ; } $ _section = $ field -> get_option ( 'section' ) ; if ( ! $ _section || ! isset ( $ this -> sections [ $ _section ] ) ) { continue ; } $ this -> sections [ $ _section ] -> fields [ ] = $ field ; } }
|
Maps fields into their section .
|
59,443
|
protected function prepare_sections ( ) { $ this -> sections = wp_list_sort ( $ this -> sections , [ 'priority' => 'ASC' , 'instance_number' => 'ASC' , ] , 'ASC' , true ) ; $ sections = [ ] ; foreach ( $ this -> sections as $ section ) { if ( ! $ section -> check_capabilities ( ) ) { continue ; } if ( ! $ this instanceof Has_Panel || ! $ section -> panel ) { $ sections [ $ section -> id ] = $ section ; continue ; } if ( isset ( $ this -> panels [ $ section -> panel ] ) ) { $ this -> panels [ $ section -> panel ] -> sections [ $ section -> id ] = $ section ; } } $ this -> sections = $ sections ; }
|
Prepare the sections .
|
59,444
|
protected function prepare_panels ( ) { if ( ! $ this instanceof Has_Panel ) { return ; } $ this -> panels = wp_list_sort ( $ this -> panels ( ) , [ 'priority' => 'ASC' , 'instance_number' => 'ASC' , ] , 'ASC' , true ) ; $ panels = [ ] ; foreach ( $ this -> panels ( ) as $ panel ) { if ( ! $ panel -> check_capabilities ( ) ) { continue ; } $ panel -> sections = wp_list_sort ( $ panel -> sections , [ 'priority' => 'ASC' , 'instance_number' => 'ASC' , ] , 'ASC' , true ) ; $ panels [ $ panel -> id ] = $ panel ; } $ this -> panels = $ panels ; }
|
Prepare the panels .
|
59,445
|
protected function getLocale ( ? string $ expectedLocale ) { return $ expectedLocale ?? ( null === $ this -> request ? $ this -> defaultLocale : $ this -> request -> getLocale ( ) ) ; }
|
Always get a locale even if we are not in a request .
|
59,446
|
public function add_section ( $ id , $ args = [ ] ) { $ section = $ this -> manager -> add_section ( $ id , $ args ) ; $ section -> panel = $ this -> id ; return $ section ; }
|
Add a section into this panel .
|
59,447
|
private function convertEncoding ( ) { $ convert = new EncodingHandler ( $ this -> content , $ this -> encoding ) ; if ( ( $ result = $ convert -> auto ( ) ) !== false ) { $ this -> encoding = self :: ENCODING ; mb_internal_encoding ( self :: ENCODING ) ; return $ this -> content = $ result ; } mb_internal_encoding ( self :: ENCODING ) ; return $ this -> content ; }
|
Convert character encoding
|
59,448
|
public function userAgent ( $ product = self :: USER_AGENT , $ version = null ) { return $ this -> handler -> userAgent -> client ( $ product , $ version , $ this -> statusCode ) ; }
|
User - agent specific rules
|
59,449
|
public function attributes ( $ attributes , $ merge_global = false ) { if ( $ merge_global && count ( $ this -> global_attributes ) > 0 ) { $ attributes = $ attributes + $ this -> global_attributes ; } return Utils :: build_html_attributes ( $ attributes ) ; }
|
Create an HTML attribute string from an array .
|
59,450
|
protected function set_textarea_size ( $ options ) { if ( isset ( $ options [ 'size' ] ) ) { list ( $ cols , $ rows ) = explode ( 'x' , $ options [ 'size' ] ) ; } else { $ cols = Arr :: get ( $ options , 'cols' , 50 ) ; $ rows = Arr :: get ( $ options , 'rows' , 10 ) ; } return array_merge ( $ options , compact ( 'cols' , 'rows' ) ) ; }
|
Set the text area size on the attributes .
|
59,451
|
protected function get_checkbox_checked_state ( $ name , $ value , $ checked ) { $ request = $ this -> request ( $ name ) ; if ( ! $ request && null !== $ this -> session && ! $ this -> old_input_is_empty ( ) && is_null ( $ this -> old ( $ name ) ) ) { return false ; } if ( $ this -> missing_old_and_model ( $ name ) && is_null ( $ request ) ) { return $ checked ; } $ posted = $ this -> get_value_attribute ( $ name , $ checked ) ; if ( is_array ( $ posted ) ) { return in_array ( $ value , $ posted ) ; } if ( $ posted instanceof Collection ) { return $ posted -> contains ( 'id' , $ value ) ; } return ( bool ) $ posted ; }
|
Get the check state for a checkbox input .
|
59,452
|
protected function missing_old_and_model ( $ name ) { return ( is_null ( $ this -> old ( $ name ) ) && is_null ( $ this -> get_model_value_attribute ( $ name ) ) ) ; }
|
Determine if old input or model input exists for a key .
|
59,453
|
protected function request ( $ name ) { if ( ! $ this -> consider_request || ! $ this -> request ) { return null ; } return $ this -> request -> input ( $ this -> transform_key ( $ name ) ) ; }
|
Get value from current Request
|
59,454
|
public function set_group ( Field $ group ) { $ this -> group = $ group ; $ this -> form = $ this -> group -> get_form ( ) ; $ this -> storage = $ this -> group -> get_storage ( ) ; return $ this ; }
|
Sets the group field instance .
|
59,455
|
public function js_data ( $ field ) { $ value = $ field -> get_value ( ) ; $ attachment = [ ] ; if ( ! $ value && $ _default = $ field -> get_default ( ) ) { $ type = in_array ( substr ( $ _default , - 3 ) , [ 'jpg' , 'png' , 'gif' , 'bmp' ] ) ? 'image' : 'document' ; $ attachment = [ 'id' => 1 , 'url' => $ _default , 'type' => $ type , 'icon' => wp_mime_type_icon ( $ type ) , 'title' => basename ( $ _default ) , ] ; if ( 'image' === $ type ) { $ attachment [ 'sizes' ] = [ 'full' => [ 'url' => $ _default ] ] ; } } elseif ( $ value ) { $ attachment = wp_prepare_attachment_for_js ( $ value ) ; } return [ 'mime_type' => $ this -> mime_type , 'attachment' => $ attachment , 'labels' => Arr :: only ( $ this -> get_button_labels ( ) , [ 'frame_title' , 'frame_button' ] ) , ] ; }
|
Returns field data for the JS .
|
59,456
|
public function get_button_labels ( ) { $ mime_type = ! empty ( $ this -> mime_type ) ? strtok ( ltrim ( $ this -> mime_type , '/' ) , '/' ) : 'default' ; switch ( $ mime_type ) { case 'video' : return [ 'select' => esc_html__ ( 'Select video' , 'wplibs-form' ) , 'change' => esc_html__ ( 'Change video' , 'wplibs-form' ) , 'default' => esc_html__ ( 'Default' , 'wplibs-form' ) , 'remove' => esc_html__ ( 'Remove' , 'wplibs-form' ) , 'placeholder' => esc_html__ ( 'No video selected' , 'wplibs-form' ) , 'frame_title' => esc_html__ ( 'Select video' , 'wplibs-form' ) , 'frame_button' => esc_html__ ( 'Choose video' , 'wplibs-form' ) , ] ; case 'audio' : return [ 'select' => esc_html__ ( 'Select audio' , 'wplibs-form' ) , 'change' => esc_html__ ( 'Change audio' , 'wplibs-form' ) , 'default' => esc_html__ ( 'Default' , 'wplibs-form' ) , 'remove' => esc_html__ ( 'Remove' , 'wplibs-form' ) , 'placeholder' => esc_html__ ( 'No audio selected' , 'wplibs-form' ) , 'frame_title' => esc_html__ ( 'Select audio' , 'wplibs-form' ) , 'frame_button' => esc_html__ ( 'Choose audio' , 'wplibs-form' ) , ] ; case 'image' : return [ 'select' => esc_html__ ( 'Select image' , 'wplibs-form' ) , 'change' => esc_html__ ( 'Change image' , 'wplibs-form' ) , 'default' => esc_html__ ( 'Default' , 'wplibs-form' ) , 'remove' => esc_html__ ( 'Remove' , 'wplibs-form' ) , 'placeholder' => esc_html__ ( 'No image selected' , 'wplibs-form' ) , 'frame_title' => esc_html__ ( 'Select image' , 'wplibs-form' ) , 'frame_button' => esc_html__ ( 'Choose image' , 'wplibs-form' ) , ] ; default : return [ 'select' => esc_html__ ( 'Select file' , 'wplibs-form' ) , 'change' => esc_html__ ( 'Change file' , 'wplibs-form' ) , 'default' => esc_html__ ( 'Default' , 'wplibs-form' ) , 'remove' => esc_html__ ( 'Remove' , 'wplibs-form' ) , 'placeholder' => esc_html__ ( 'No file selected' , 'wplibs-form' ) , 'frame_title' => esc_html__ ( 'Select file' , 'wplibs-form' ) , 'frame_button' => esc_html__ ( 'Choose file' , 'wplibs-form' ) , ] ; } }
|
Get the button labels .
|
59,457
|
public static function get_system_fonts ( ) { $ fonts = [ ] ; foreach ( static :: $ websafe_fonts as $ label => $ family ) { $ fonts [ ] = [ 'family' => $ family , 'label' => $ label , 'variants' => [ '400' , '400italic' , '700' , '700italic' ] , ] ; } return apply_filters ( 'suru_libs_system_fonts' , $ fonts ) ; }
|
Gets list system fonts .
|
59,458
|
public static function get_google_fonts ( ) { $ google_fonts = get_transient ( '_suru_libs_google_fonts' ) ; if ( ! is_array ( $ google_fonts ) || empty ( $ google_fonts ) ) { $ google_fonts = json_decode ( file_get_contents ( dirname ( dirname ( __DIR__ ) ) . '/Resources/webfonts.json' ) , true ) ; static :: set_transients ( $ google_fonts ) ; } return apply_filters ( 'suru_libs_system_fonts' , $ google_fonts ) ; }
|
Gets the Google Fonts .
|
59,459
|
public static function fetch_google_fonts ( $ api_key = null ) { $ raw_fonts = static :: request_google_fonts ( $ api_key ) ; if ( ! is_array ( $ raw_fonts ) || ! isset ( $ raw_fonts [ 'items' ] ) ) { return [ ] ; } $ fonts = [ ] ; foreach ( $ raw_fonts [ 'items' ] as $ item ) { if ( ! isset ( $ item [ 'kind' ] ) || 'webfonts#webfont' !== $ item [ 'kind' ] ) { continue ; } $ fonts [ ] = Arr :: only ( $ item , [ 'family' , 'category' , 'variants' , 'subset' ] ) ; } static :: flush_transients ( ) ; static :: set_transients ( $ fonts ) ; return $ fonts ; }
|
Get list of fonts from Google Fonts .
|
59,460
|
public static function request_google_fonts ( $ api_key = null ) { $ api_key = apply_filters ( 'suru_libs_google_fonts_api_keys' , $ api_key ) ; if ( empty ( $ api_key ) ) { return false ; } $ response = wp_remote_get ( static :: GOOGLE_FONTS_ENDPOINT . '?sort=alpha' . ( $ api_key ? "&key={$api_key}" : '' ) , [ 'sslverify' => false ] ) ; if ( 200 !== wp_remote_retrieve_response_code ( $ response ) ) { return false ; } return json_decode ( wp_remote_retrieve_body ( $ response ) , true ) ; }
|
Send http request to get fonts from Google Fonts service .
|
59,461
|
public function read ( ) { $ data = get_option ( $ this -> name , [ ] ) ; $ this -> data = is_array ( $ data ) ? $ data : [ ] ; }
|
Read data from storage .
|
59,462
|
public function save ( ) { if ( empty ( $ this -> data ) ) { return delete_option ( $ this -> name ) ; } $ updated = update_option ( $ this -> name , $ this -> data , $ this -> autoload ) ; $ this -> read ( ) ; return $ updated ; }
|
Save data to the storage .
|
59,463
|
public function prepare_new_row ( ) { $ this -> field = [ ] ; $ this -> setup_fields ( ) ; $ values = $ this -> get_value ( ) ; Dependency :: check ( $ this -> fields , isset ( $ values [ $ this -> index ] ) ? ( array ) $ values [ $ this -> index ] : [ ] ) ; }
|
Setup group for a new row .
|
59,464
|
protected function setup_fields ( ) { foreach ( $ this -> prop ( 'fields' ) as $ args ) { $ field = $ this -> builder -> get_field ( $ args , $ this ) -> set_option ( 'context' , $ this -> args ( 'context' ) ) -> initialize ( ) ; if ( ! $ field -> check_capabilities ( ) ) { continue ; } if ( 'hidden' === $ args [ 'type' ] ) { $ this -> builder -> add_hidden_field ( $ args , $ this ) ; continue ; } $ this -> fields [ $ field -> get_id ( ) ] = $ field ; } }
|
Setup field in the group .
|
59,465
|
public function parse ( $ source ) { $ resolver = new RefResolver ( ) ; if ( $ this -> connection !== null ) { $ resolver -> addResolver ( 'schema' , new Resolver ( $ this -> connection ) ) ; } $ parser = new JsonSchema ( null , $ resolver ) ; $ schema = $ parser -> parse ( $ source ) ; return Service \ Schema :: serializeCache ( $ schema ) ; }
|
Parses and resolves the json schema source and returns the object presentation of the schema
|
59,466
|
public function setCredentials ( $ username , $ password ) { $ this -> username = $ username ; $ this -> password = $ password ; $ this -> token = '' ; $ this -> accessToken = '' ; return $ this ; }
|
Set username and password for authentication
|
59,467
|
public function setToken ( $ token ) { $ this -> token = $ token ; $ this -> username = '' ; $ this -> password = '' ; $ this -> accessToken = '' ; return $ this ; }
|
Set simple token for authentication
|
59,468
|
public function setAccessToken ( $ accessToken ) { $ this -> accessToken = $ accessToken ; $ this -> username = '' ; $ this -> password = '' ; $ this -> token = '' ; return $ this ; }
|
Set access token for OAuth2 authentication
|
59,469
|
public function createApplicationFromRepo ( $ source , $ options = array ( ) ) { $ options = array_merge ( $ options , array ( 'create_method' => 'remote_repo' , 'repo' => $ source , ) ) ; return $ this -> createApplication ( $ options ) ; }
|
Create application using GitHub repository
|
59,470
|
public function createApplicationFromFile ( $ source , $ options = array ( ) ) { $ options = array_merge ( $ options , array ( 'create_method' => 'file' , 'file' => $ this -> file ( $ source ) , ) ) ; return $ this -> createApplication ( $ options ) ; }
|
Create application from file
|
59,471
|
public function updateApplicationFromRepo ( $ applicationId , $ options = array ( ) ) { $ options = array_merge ( $ options , array ( 'pull' => true , ) ) ; return $ this -> updateApplication ( $ applicationId , $ options ) ; }
|
Update application from GitHub repository
|
59,472
|
public function updateApplicationFromFile ( $ applicationId , $ source , $ options = array ( ) ) { $ options = array_merge ( $ options , array ( 'file' => $ this -> file ( $ source ) , ) ) ; return $ this -> updateApplication ( $ applicationId , $ options ) ; }
|
Update application from file
|
59,473
|
public function updateApplicationIcon ( $ applicationId , $ source ) { $ options [ 'icon' ] = $ this -> file ( $ source ) ; return $ this -> request ( array ( 'apps' , $ applicationId , 'icon' ) , 'post' , $ options ) ; }
|
Update application icon
|
59,474
|
public function buildApplication ( $ applicationId , $ platforms = array ( ) ) { $ options = array ( ) ; if ( ! empty ( $ platforms ) ) { if ( ! is_array ( $ platforms ) ) { $ platforms = array ( $ platforms ) ; } $ options [ 'platforms' ] = $ platforms ; } return $ this -> request ( array ( 'apps' , $ applicationId , 'build' ) , 'post' , $ options ) ; }
|
Start building application
|
59,475
|
public function addKeyAndroid ( $ title , $ keystore , $ options = array ( ) ) { $ defaults = array ( 'title' => $ title , 'keystore' => $ this -> file ( $ keystore ) , ) ; $ options = array_merge ( $ defaults , $ options ) ; return $ this -> addKeyPlatform ( self :: ANDROID , $ options ) ; }
|
Add key for android
|
59,476
|
public function addKeyIos ( $ title , $ cert , $ profile , $ options = array ( ) ) { $ defaults = array ( 'title' => $ title , 'cert' => $ this -> file ( $ cert ) , 'profile' => $ this -> file ( $ profile ) , ) ; $ options = array_merge ( $ defaults , $ options ) ; return $ this -> addKeyPlatform ( self :: IOS , $ options ) ; }
|
Add key for ios
|
59,477
|
protected function assocToString ( $ array , $ keyValueSeparator = ' - ' , $ pairSeparator = '; ' ) { if ( ! is_array ( $ array ) ) { return print_r ( $ array , true ) ; } foreach ( $ array as $ key => & $ value ) { $ value = $ key . $ keyValueSeparator . $ value ; } return implode ( $ pairSeparator , $ array ) ; }
|
Represent associative array as string
|
59,478
|
private function resolveActionsFromRoutes ( array $ data , $ basePath ) { $ actions = [ ] ; $ type = SystemAbstract :: TYPE_ROUTES ; if ( isset ( $ data [ $ type ] ) && is_array ( $ data [ $ type ] ) ) { foreach ( $ data [ $ type ] as $ name => $ row ) { $ row = IncludeDirective :: resolve ( $ row , $ basePath , $ type ) ; if ( isset ( $ row [ 'methods' ] ) && is_array ( $ row [ 'methods' ] ) ) { foreach ( $ row [ 'methods' ] as $ method => $ config ) { if ( isset ( $ config [ 'action' ] ) && ! $ this -> isName ( $ config [ 'action' ] ) ) { $ name = NameGenerator :: getActionNameFromSource ( $ config [ 'action' ] ) ; $ actions [ $ name ] = [ 'class' => $ config [ 'action' ] ] ; } } } } } return $ actions ; }
|
In case the routes contains a class as action we automatically create a fitting action entry
|
59,479
|
public function clean ( ) { $ delay = self :: OUT_OF_SYNC_TIME_LIMIT ; $ query = $ this -> pdo -> prepare ( <<<SQLDELETE FROM robotstxt__delay0WHERE delayUntil < ((UNIX_TIMESTAMP() - :delay) * 1000000);SQL ) ; $ query -> bindValue ( 'delay' , $ delay , \ PDO :: PARAM_INT ) ; return $ query -> execute ( ) ; }
|
Clean the delay table
|
59,480
|
public function getTopWaitTimes ( $ limit = self :: TOP_X_LIMIT , $ minDelay = self :: TOP_X_MIN_DELAY ) { $ query = $ this -> pdo -> prepare ( <<<SQLSELECT base, userAgent, delayUntil / 1000000 AS delayUntil, lastDelay / 1000000 AS lastDelayFROM robotstxt__delay0WHERE delayUntil > ((UNIX_TIMESTAMP(CURTIME(6)) + :minDelay) * 1000000)ORDER BY delayUntil DESCLIMIT :maxCount;SQL ) ; $ query -> bindValue ( 'minDelay' , $ minDelay , \ PDO :: PARAM_INT ) ; $ query -> bindValue ( 'maxCount' , $ limit , \ PDO :: PARAM_INT ) ; $ query -> execute ( ) ; return $ query -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; }
|
Top X wait time
|
59,481
|
public function onVichUploaderPreUpload ( Event $ event ) { $ media = $ event -> getObject ( ) ; $ this -> checkIfThereIsAName ( $ media ) ; $ this -> checkIfNameEverExistInDatabase ( $ media ) ; $ this -> checkIfFileLocationIsChanging ( $ media ) ; }
|
Check if name exist .
|
59,482
|
public function onVichUploaderPostUpload ( Event $ event ) { $ object = $ event -> getObject ( ) ; $ mapping = $ event -> getMapping ( ) ; $ absoluteDir = $ mapping -> getUploadDestination ( ) . '/' . $ mapping -> getUploadDir ( $ object ) ; $ relativeDir = substr_replace ( $ absoluteDir , '' , 0 , strlen ( $ this -> projectDir ) + 1 ) ; $ object -> setRelativeDir ( $ relativeDir ) ; if ( false !== strpos ( $ object -> getMimeType ( ) , 'image/' ) ) { $ img = $ mapping -> getUploadDestination ( ) . '/' . $ mapping -> getUploadDir ( $ object ) . '/' . $ object -> getMedia ( ) ; $ palette = Palette :: fromFilename ( $ img , Color :: fromHexToInt ( '#FFFFFF' ) ) ; $ extractor = new ColorExtractor ( $ palette ) ; $ colors = $ extractor -> extract ( ) ; $ object -> setMainColor ( Color :: fromIntToHex ( $ colors [ 0 ] ) ) ; $ this -> generateCache ( '/' . $ relativeDir . '/' . $ object -> getMedia ( ) ) ; } }
|
Update RelativeDir .
|
59,483
|
public function nav ( $ nav_class = '' ) { echo '<ul role="tablist" class="wplibs-box__nav ' . esc_attr ( $ nav_class ) . '">' ; foreach ( $ this -> sections ( ) as $ section ) { echo $ section -> navlink ( ) ; } echo '</ul><!-- /.wplibs-box__nav ; }
|
Output the navigation .
|
59,484
|
public function main ( $ main_class = '' ) { if ( count ( $ containers = $ this -> containers ( ) ) > 0 ) { echo '<main class="wplibs-box__container ' . esc_attr ( $ main_class ) . '">' ; $ this -> show_sections ( $ containers ) ; echo '</main>' ; } else { $ this -> show_fields ( $ this -> get_form ( ) -> all ( ) ) ; } }
|
Output the main sections and fields .
|
59,485
|
public function navlink ( ) { $ attributes = [ 'role' => 'tab' , 'aria-controls' => $ this -> uniqid ( ) , 'data-section' => $ this -> id , 'data-open' => ! empty ( $ this -> options [ 'active' ] ) ? 'true' : 'false' , ] ; return sprintf ( '<li%1$s><a href="#" aria-expanded="false">%3$s <span>%2$s</span></a></li>' , Utils :: build_html_attributes ( $ attributes ) , esc_html ( $ this -> title ? : $ this -> id ) , $ this -> icon ( ) ) ; }
|
Returns the nav - link of the section .
|
59,486
|
public function output ( ) { if ( ! $ form = $ this -> manager -> get_form ( ) ) { _doing_it_wrong ( __FUNCTION__ , 'Cannot output the section until the form is created' , null ) ; return ; } $ attributes = [ 'role' => 'tabpanel' , 'id' => $ this -> uniqid ( ) , 'aria-hidden' => ! empty ( $ this -> options [ 'active' ] ) ? 'false' : 'true' , ] ; echo '<section' . Utils :: build_html_attributes ( $ attributes ) . '>' ; foreach ( $ this -> fields as $ field ) { $ form -> show ( $ field ) ; } echo '</section>' ; }
|
Output the section content .
|
59,487
|
private function newAction ( $ class , $ engine ) { if ( ! class_exists ( $ engine ) ) { throw new StatusCode \ BadRequestException ( 'Could not resolve engine' ) ; } try { $ action = $ this -> actionFactory -> factory ( $ class , $ engine ) ; } catch ( FactoryResolveException $ e ) { throw new StatusCode \ BadRequestException ( $ e -> getMessage ( ) ) ; } if ( ! $ action instanceof ActionInterface ) { throw new StatusCode \ BadRequestException ( 'Could not resolve action' ) ; } return $ action ; }
|
Checks whether the provided class is resolvable and returns an action instance
|
59,488
|
public function set_object_type ( $ object_type ) { if ( ! in_array ( $ object_type , $ supported = [ 'user' , 'comment' , 'term' , 'post' ] ) ) { _doing_it_wrong ( __FUNCTION__ , 'The object type must be one of: ' . implode ( ', ' , $ supported ) , null ) ; } $ this -> object_type = $ object_type ; return $ this ; }
|
Sets the current object type .
|
59,489
|
public static function guest_object_id ( $ object_id = 0 , $ object_type = null ) { global $ pagenow ; if ( is_null ( $ object_type ) ) { $ object_type = static :: guest_object_type ( ) ; } switch ( $ object_type ) { case 'user' : $ object_id = isset ( $ _REQUEST [ 'user_id' ] ) ? sanitize_text_field ( wp_unslash ( $ _REQUEST [ 'user_id' ] ) ) : $ object_id ; if ( ! $ object_id && 'user-new.php' !== $ pagenow && isset ( $ GLOBALS [ 'user_ID' ] ) ) { $ object_id = $ GLOBALS [ 'user_ID' ] ; } break ; case 'comment' : $ object_id = isset ( $ _REQUEST [ 'c' ] ) ? sanitize_text_field ( wp_unslash ( $ _REQUEST [ 'c' ] ) ) : $ object_id ; if ( ! $ object_id && isset ( $ GLOBALS [ 'comments' ] -> comment_ID ) ) { $ object_id = $ GLOBALS [ 'comments' ] -> comment_ID ; } break ; case 'term' : $ object_id = isset ( $ _REQUEST [ 'tag_ID' ] ) ? sanitize_text_field ( wp_unslash ( $ _REQUEST [ 'tag_ID' ] ) ) : $ object_id ; break ; default : $ object_id = isset ( $ GLOBALS [ 'post' ] -> ID ) ? $ GLOBALS [ 'post' ] -> ID : $ object_id ; if ( ! $ object_id && isset ( $ _REQUEST [ 'post' ] ) ) { $ object_id = sanitize_text_field ( wp_unslash ( $ _REQUEST [ 'post' ] ) ) ; } break ; } return absint ( $ object_id ) ; }
|
Guest the object ID from global space .
|
59,490
|
public function get_form ( ) { $ this -> throws_if_locked ( 'access' ) ; $ form = new Form ( $ this -> get_form_config ( ) ) ; foreach ( $ this -> prop ( 'fields' ) as $ args ) { $ form -> add ( $ this -> get_field ( $ args ) -> initialize ( ) ) ; } if ( $ this -> get_auto_initialize ( ) ) { $ form -> initialize ( ) ; } return $ form ; }
|
Creates the form .
|
59,491
|
public function get_html_builder ( ) { if ( ! $ this -> html_builder ) { $ this -> html_builder = new Html_Form ( ) ; } $ this -> html_builder -> global_attributes ( array_merge ( ( array ) $ this -> field -> args ( 'attributes' ) , [ 'data-hash' => $ this -> field -> hash_id ( ) , 'data-iterator' => $ this -> field -> is_repeatable ( ) ? $ this -> iterator : null , ] ) ) ; return $ this -> html_builder ; }
|
Gets the html form builder helper .
|
59,492
|
public function _input_id ( $ suffix = '' ) { return $ this -> field -> id ( ) . $ suffix . ( $ this -> field -> is_repeatable ( ) ? '_' . $ this -> iterator : '' ) ; }
|
Generate the ID attribute .
|
59,493
|
public function cacheDelay ( ) { return $ this -> handler -> cacheDelay -> client ( $ this -> product , $ this -> crawlDelay ( ) -> getValue ( ) ) ; }
|
Cache - delay
|
59,494
|
public function requestRate ( ) { return $ this -> handler -> requestRate -> client ( $ this -> product , $ this -> crawlDelay ( ) -> getValue ( ) ) ; }
|
RequestClient - rate
|
59,495
|
public function numberOfDays ( ) { if ( self :: APRIL === $ this -> month || self :: JUNE === $ this -> month || self :: SEPTEMBER === $ this -> month || self :: NOVEMBER === $ this -> month ) { return 30 ; } if ( self :: FEBRURY === $ this -> month ) { return $ this -> year -> isLeap ( ) ? 29 : 28 ; } return 31 ; }
|
Gets the number of days in this month .
|
59,496
|
public function startDay ( ) { $ dateString = sprintf ( '%04d-%02d-01' , $ this -> year -> value ( ) , $ this -> month ) ; $ datetime = new \ DateTime ( $ dateString ) ; return ( int ) $ datetime -> format ( 'N' ) ; }
|
Returns the day of the week that the 1st of this month is on .
|
59,497
|
private function checkOverride ( $ uri ) { if ( parse_url ( $ uri , PHP_URL_PATH ) === self :: PATH ) { return self :: DIRECTIVE_ALLOW ; } $ statusCodeParser = new StatusCodeParser ( $ this -> statusCode , parse_url ( $ this -> base , PHP_URL_SCHEME ) ) ; if ( ( $ result = $ statusCodeParser -> accessOverride ( ) ) !== false ) { return $ result ; } if ( $ this -> handler -> visitTime -> client ( ) -> isVisitTime ( ) === false ) { return self :: DIRECTIVE_DISALLOW ; } return false ; }
|
Check for overrides
|
59,498
|
protected function createConnection ( TableMap $ tableMap ) { $ this -> con = Propel :: getConnection ( $ tableMap :: DATABASE_NAME ) ; $ this -> con -> beginTransaction ( ) ; if ( method_exists ( $ this -> con , 'useDebug' ) ) { Logger :: log ( 'Enabling debug queries mode' , LOG_INFO ) ; $ this -> con -> useDebug ( Config :: getParam ( 'debug' ) ) ; } }
|
Initialize db connection
|
59,499
|
protected function closeTransaction ( $ status ) { if ( null !== $ this -> con ) { $ this -> traceDebugQuery ( ) ; if ( null !== $ this -> con && $ this -> con -> inTransaction ( ) ) { if ( $ status === 200 ) { $ this -> con -> commit ( ) ; } else { $ this -> con -> rollBack ( ) ; } } Propel :: closeConnections ( ) ; } }
|
Close transactions if are requireds
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.