idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
47,600
public function appendExtension ( $ name , array $ config = [ ] ) { $ merged = array_merge_recursive ( $ this -> getExtension ( $ name ) , $ config ) ; $ this -> addExtension ( $ name , $ merged ) ; }
Merge with current extension configuration appending new values to old ones .
47,601
public function mergeExtension ( $ name , array $ config ) { $ this -> addExtension ( $ name , array_merge ( $ this -> getExtension ( $ name ) , $ config ) ) ; }
Merge with current extension configuration overwriting with new values .
47,602
public function auto ( $ name = null , $ initial = null , $ size = null ) { $ this -> strategy = 'AUTO' ; $ this -> customize ( $ name , $ initial , $ size ) ; return $ this ; }
Tells Doctrine to pick the strategy that is preferred by the used database platform . The preferred strategies are IDENTITY for MySQL SQLite MsSQL and SQL Anywhere and SEQUENCE for Oracle and PostgreSQL . This strategy provides full portability .
47,603
public function sequence ( $ name = null , $ initial = null , $ size = null ) { $ this -> strategy = 'SEQUENCE' ; $ this -> customize ( $ name , $ initial , $ size ) ; return $ this ; }
Tells Doctrine to use a database sequence for ID generation . This strategy does currently not provide full portability . Sequences are supported by Oracle PostgreSql and SQL Anywhere .
47,604
public function build ( ) { $ delayed = [ ] ; foreach ( $ this -> getQueued ( ) as $ buildable ) { if ( $ buildable instanceof Delay ) { $ delayed [ ] = $ buildable ; } else { $ buildable -> build ( ) ; } } foreach ( $ delayed as $ buildable ) { $ buildable -> build ( ) ; } }
Execute the build process for all queued buildables .
47,605
public function cacheable ( $ usage = ClassMetadataInfo :: CACHE_USAGE_READ_ONLY , $ region = null ) { $ meta = $ this -> builder -> getClassMetadata ( ) ; $ meta -> enableCache ( compact ( 'usage' , $ region === null ? : 'region' ) ) ; return $ this ; }
Enables second - level cache on this entity . If you want to enable second - level cache you must enable it on the EntityManager configuration . Depending on the cache mode selected you may also need to configure lock modes .
47,606
public static function enable ( ) { Builder :: macro ( self :: MACRO_METHOD , function ( Fluent $ builder , callable $ callback = null ) { $ tree = new static ( $ builder ) ; if ( is_callable ( $ callback ) ) { call_user_func ( $ callback , $ tree ) ; } return $ tree ; } ) ; NestedSet :: enable ( ) ; MaterializedPath :: enable ( ) ; ClosureTable :: enable ( ) ; }
Enable extension .
47,607
public function readExtendedMetadata ( $ meta , array & $ config ) { if ( ! $ meta instanceof ExtensibleClassMetadata ) { return ; } $ config = array_merge_recursive ( $ config , $ meta -> getExtension ( $ this -> getExtensionName ( ) ) ) ; }
Read extended metadata configuration for a single mapped class .
47,608
public function get ( $ item ) { $ data = $ this -> getData ( ) ; return empty ( $ data -> $ item ) ? null : $ data -> $ item ; }
Get from Data Attribute .
47,609
public function capture ( ) { $ storage = new Storage ( ) ; $ config = new Config ( $ storage -> getAccount ( ) ) ; if ( $ config -> getDriver ( ) == 'database' ) { return PayuPayment :: find ( $ storage -> getPayment ( ) ) ; } return new PayuPayment ( $ storage -> getPayment ( ) ) ; }
Receive Payment and Return Payment Model .
47,610
public function verify ( $ transactionId ) { session ( ) -> put ( 'tzsk_payu_data' , [ 'account' => $ this -> account ] ) ; $ transactionId = is_array ( $ transactionId ) ? $ transactionId : explode ( '|' , $ transactionId ) ; return $ this -> getVerifier ( $ transactionId ) -> verify ( ) ; }
Get Status of a given Transaction .
47,611
public function getStatus ( ) { switch ( strtolower ( $ this -> request -> status ) ) { case 'success' : return self :: STATUS_COMPLETED ; case 'pending' : return self :: STATUS_PENDING ; case 'failure' : return self :: STATUS_FAILED ; default : return self :: STATUS_FAILED ; } }
Get the status of the Payment .
47,612
public function redirectTo ( $ url , $ parameters = [ ] , $ secure = null ) { $ this -> url = url ( $ url , $ parameters , $ secure ) ; return $ this ; }
Set Redirect URL .
47,613
public function payment ( Request $ request ) { $ payment = ( new Processor ( $ request ) ) -> process ( ) ; Session :: put ( 'tzsk_payu_data.payment' , $ payment ) ; return redirect ( ) -> to ( base64_decode ( $ request -> callback ) ) ; }
After payment it will return here .
47,614
protected static function _get_menu_item_fields ( $ meta ) { $ fields = array_merge ( array ( array ( 'id' => 'type' , 'label' => __ ( 'Type' , 'menu-icons' ) , 'value' => $ meta [ 'type' ] , ) , array ( 'id' => 'icon' , 'label' => __ ( 'Icon' , 'menu-icons' ) , 'value' => $ meta [ 'icon' ] , ) , ) , Menu_Icons_Settings :: get_settings_fields ( $ meta ) ) ; return $ fields ; }
Get menu item setting fields
47,615
public static function _save ( $ menu_id , $ menu_item_db_id , $ menu_item_args ) { if ( defined ( 'DOING_AJAX' ) && DOING_AJAX ) { return ; } $ screen = get_current_screen ( ) ; if ( ! $ screen instanceof WP_Screen || 'nav-menus' !== $ screen -> id ) { return ; } check_admin_referer ( 'update-nav_menu' , 'update-nav-menu-nonce' ) ; if ( ! empty ( $ _POST [ 'menu-icons' ] [ $ menu_item_db_id ] ) ) { $ value = array_map ( 'sanitize_text_field' , wp_unslash ( ( array ) $ _POST [ 'menu-icons' ] [ $ menu_item_db_id ] ) ) ; } else { $ value = array ( ) ; } Menu_Icons_Meta :: update ( $ menu_item_db_id , $ value ) ; }
Save menu item s icons metadata
47,616
public static function _media_templates ( ) { $ id_prefix = 'tmpl-menu-icons' ; $ templates = apply_filters ( 'menu_icons_media_templates' , array ( ) ) ; if ( ! empty ( $ templates ) ) { if ( WP_DEBUG ) { _deprecated_function ( 'menu_icons_media_templates' , '0.9.0' , 'menu_icons_js_templates' ) ; } foreach ( $ templates as $ key => $ template ) { $ id = sprintf ( '%s-%s' , $ id_prefix , $ key ) ; self :: _print_tempate ( $ id , $ template ) ; } } require_once dirname ( __FILE__ ) . '/media-template.php' ; }
Get and print media templates from all types
47,617
public static function _add_extra_type_props_data ( $ props , $ id , $ type ) { $ settings_fields = array ( 'hide_label' , 'position' , 'vertical_align' , ) ; if ( 'Font' === $ props [ 'controller' ] ) { $ settings_fields [ ] = 'font_size' ; } switch ( $ id ) { case 'image' : $ settings_fields [ ] = 'image_size' ; break ; case 'svg' : $ settings_fields [ ] = 'svg_width' ; break ; } $ props [ 'data' ] [ 'settingsFields' ] = $ settings_fields ; return $ props ; }
Add extra icon type properties data
47,618
public static function is_menu_icons_disabled_for_menu ( $ menu_id = 0 ) { if ( empty ( $ menu_id ) ) { $ menu_id = self :: get_current_menu_id ( ) ; } if ( empty ( $ menu_id ) ) { return true ; } $ menu_settings = self :: get_menu_settings ( $ menu_id ) ; $ is_disabled = ! empty ( $ menu_settings [ 'disabled' ] ) ; return $ is_disabled ; }
Check if menu icons is disabled for a menu
47,619
public static function get_current_menu_id ( ) { global $ nav_menu_selected_id ; if ( ! empty ( $ nav_menu_selected_id ) ) { return $ nav_menu_selected_id ; } if ( is_admin ( ) && isset ( $ _REQUEST [ 'menu' ] ) ) { $ menu_id = absint ( $ _REQUEST [ 'menu' ] ) ; } else { $ menu_id = absint ( get_user_option ( 'nav_menu_recently_edited' ) ) ; } return $ menu_id ; }
Get ID of menu being edited
47,620
public static function get_menu_settings ( $ menu_id ) { $ menu_settings = self :: get ( sprintf ( 'menu_%d' , $ menu_id ) ) ; $ menu_settings = apply_filters ( 'menu_icons_menu_settings' , $ menu_settings , $ menu_id ) ; if ( ! is_array ( $ menu_settings ) ) { $ menu_settings = array ( ) ; } return $ menu_settings ; }
Get menu settings
47,621
public static function _ajax_menu_icons_update_settings ( ) { check_ajax_referer ( self :: UPDATE_KEY , self :: UPDATE_KEY ) ; if ( empty ( $ _POST [ 'menu-icons' ] [ 'settings' ] ) ) { wp_send_json_error ( ) ; } $ redirect_url = self :: _update_settings ( $ _POST [ 'menu-icons' ] [ 'settings' ] ) ; wp_send_json_success ( array ( 'redirectUrl' => $ redirect_url ) ) ; }
Update settings via ajax
47,622
public static function _admin_notices ( ) { $ messages = array ( 'updated' => __ ( '<strong>Menu Icons Settings</strong> have been successfully updated.' , 'menu-icons' ) , 'reset' => __ ( '<strong>Menu Icons Settings</strong> have been successfully reset.' , 'menu-icons' ) , ) ; $ message_type = get_transient ( self :: TRANSIENT_KEY ) ; if ( ! empty ( $ message_type ) && ! empty ( $ messages [ $ message_type ] ) ) { printf ( '<div class="updated notice is-dismissible"><p>%s</p></div>' , wp_kses ( $ messages [ $ message_type ] , array ( 'strong' => true ) ) ) ; } delete_transient ( self :: TRANSIENT_KEY ) ; }
Print admin notices
47,623
public static function _meta_box ( ) { ?> <div class="taxonomydiv"> <ul id="menu-icons-settings-tabs" class="taxonomy-tabs add-menu-item-tabs hide-if-no-js"> <?php foreach ( self :: get_fields ( ) as $ section ) : ?> <?php printf ( '<li><a href="#" title="%s" class="mi-settings-nav-tab" data-type="menu-icons-settings-%s">%s</a></li>' , esc_attr ( $ section [ 'description' ] ) , esc_attr ( $ section [ 'id' ] ) , esc_html ( $ section [ 'title' ] ) ) ; ?> <?php endforeach ; ?> <?php printf ( '<li><a href="#" class="mi-settings-nav-tab" data-type="menu-icons-settings-extensions">%s</a></li>' , esc_html__ ( 'Extensions' , 'menu-icons' ) ) ; ?> </ul> <?php foreach ( self :: _get_fields ( ) as $ section_index => $ section ) : ?> <div id="menu-icons-settings- <?php echo esc_attr ( $ section [ 'id' ] ) ?> " class="tabs-panel _ <?php echo esc_attr ( $ section_index ) ?> "> <h4 class="hide-if-js"> <?php echo esc_html ( $ section [ 'title' ] ) ?> </h4> <?php foreach ( $ section [ 'fields' ] as $ field ) : ?> <div class="_field"> <?php printf ( '<label for="%s" class="_main">%s</label>' , esc_attr ( $ field -> id ) , esc_html ( $ field -> label ) ) ; ?> <?php $ field -> render ( ) ?> </div> <?php endforeach ; ?> </div> <?php endforeach ; ?> <div id="menu-icons-settings-extensions" class="tabs-panel _extensions"> <h4 class="hide-if-js"> <?php echo esc_html__ ( 'Extensions' , 'menu-icons' ) ?> </h4> <ul> <li><a target="_blank" href="http://wordpress.org/plugins/menu-icons-icomoon/">IcoMoon</a></li> </ul> </div> </div> <p class="submitbox button-controls"> <?php wp_nonce_field ( self :: UPDATE_KEY , self :: UPDATE_KEY ) ?> <span class="list-controls"> <?php printf ( '<a href="%s" title="%s" class="select-all submitdelete">%s</a>' , esc_url ( wp_nonce_url ( admin_url ( '/nav-menus.php' ) , self :: RESET_KEY , self :: RESET_KEY ) ) , esc_attr__ ( 'Discard all changes and reset to default state' , 'menu-icons' ) , esc_html__ ( 'Reset' , 'menu-icons' ) ) ; ?> </span> <span class="add-to-menu"> <span class="spinner"></span> <?php submit_button ( __ ( 'Save Settings' , 'menu-icons' ) , 'secondary' , 'menu-icons-settings-save' , false ) ; ?> </span> </p> <?php }
Settings meta box
47,624
public static function get_fields ( ) { $ menu_id = self :: get_current_menu_id ( ) ; $ icon_types = wp_list_pluck ( Menu_Icons :: get ( 'types' ) , 'name' ) ; asort ( $ icon_types ) ; $ sections = array ( 'global' => array ( 'id' => 'global' , 'title' => __ ( 'Global' , 'menu-icons' ) , 'description' => __ ( 'Global settings' , 'menu-icons' ) , 'fields' => array ( array ( 'id' => 'icon_types' , 'type' => 'checkbox' , 'label' => __ ( 'Icon Types' , 'menu-icons' ) , 'choices' => $ icon_types , 'value' => self :: get ( 'global' , 'icon_types' ) , ) , ) , 'args' => array ( ) , ) , ) ; if ( ! empty ( $ menu_id ) ) { $ menu_term = get_term ( $ menu_id , 'nav_menu' ) ; $ menu_key = sprintf ( 'menu_%d' , $ menu_id ) ; $ menu_settings = self :: get_menu_settings ( $ menu_id ) ; $ sections [ 'menu' ] = array ( 'id' => $ menu_key , 'title' => __ ( 'Current Menu' , 'menu-icons' ) , 'description' => sprintf ( __ ( '"%s" menu settings' , 'menu-icons' ) , apply_filters ( 'single_term_title' , $ menu_term -> name ) ) , 'fields' => self :: get_settings_fields ( $ menu_settings ) , 'args' => array ( 'inline_description' => true ) , ) ; } return apply_filters ( 'menu_icons_settings_sections' , $ sections , $ menu_id ) ; }
Get settings sections
47,625
private static function _get_fields ( ) { if ( ! class_exists ( 'Kucrut_Form_Field' ) ) { require_once Menu_Icons :: get ( 'dir' ) . 'includes/library/form-fields.php' ; } $ keys = array ( 'menu-icons' , 'settings' ) ; $ sections = self :: get_fields ( ) ; foreach ( $ sections as & $ section ) { $ _keys = array_merge ( $ keys , array ( $ section [ 'id' ] ) ) ; $ _args = array_merge ( array ( 'keys' => $ _keys ) , $ section [ 'args' ] ) ; foreach ( $ section [ 'fields' ] as & $ field ) { $ field = Kucrut_Form_Field :: create ( $ field , $ _args ) ; } unset ( $ field ) ; } unset ( $ section ) ; return $ sections ; }
Get processed settings fields
47,626
public static function get ( $ id , $ defaults = array ( ) ) { $ defaults = wp_parse_args ( $ defaults , self :: $ defaults ) ; $ value = get_post_meta ( $ id , self :: KEY , true ) ; $ value = wp_parse_args ( ( array ) $ value , $ defaults ) ; if ( empty ( $ value [ 'icon' ] ) && ! empty ( $ value [ 'type' ] ) && ! empty ( $ value [ "{$value['type']}-icon" ] ) ) { $ value [ 'icon' ] = $ value [ "{$value['type']}-icon" ] ; } if ( ! empty ( $ value [ 'width' ] ) ) { $ value [ 'svg_width' ] = $ value [ 'width' ] ; } unset ( $ value [ 'width' ] ) ; if ( isset ( $ value [ 'position' ] ) && ! in_array ( $ value [ 'position' ] , array ( 'before' , 'after' ) , true ) ) { $ value [ 'position' ] = $ defaults [ 'position' ] ; } if ( isset ( $ value [ 'size' ] ) && ! isset ( $ value [ 'font_size' ] ) ) { $ value [ 'font_size' ] = $ value [ 'size' ] ; unset ( $ value [ 'size' ] ) ; } if ( ! empty ( $ value [ 'icon' ] ) && in_array ( $ value [ 'type' ] , array ( 'image' , 'svg' ) , true ) ) { $ value [ 'url' ] = wp_get_attachment_image_url ( $ value [ 'icon' ] , 'thumbnail' , false ) ; } return $ value ; }
Get menu item meta value
47,627
public static function update ( $ id , $ value ) { $ _value = apply_filters ( 'menu_icons_values' , $ value , $ id ) ; if ( $ _value !== $ value && WP_DEBUG ) { _deprecated_function ( 'menu_icons_values' , '0.8.0' , 'menu_icons_item_meta_values' ) ; } $ value = apply_filters ( 'menu_icons_item_meta_values' , $ _value , $ id ) ; if ( empty ( $ value [ 'type' ] ) || empty ( $ value [ 'icon' ] ) ) { $ value = false ; } if ( ! empty ( $ value ) ) { update_post_meta ( $ id , self :: KEY , $ value ) ; } else { delete_post_meta ( $ id , self :: KEY ) ; } }
Update menu item metadata
47,628
public static function init ( ) { $ active_types = Menu_Icons_Settings :: get ( 'global' , 'icon_types' ) ; if ( empty ( $ active_types ) ) { return ; } foreach ( Menu_Icons :: get ( 'types' ) as $ type ) { if ( in_array ( $ type -> id , $ active_types , true ) ) { self :: $ icon_types [ $ type -> id ] = $ type ; } } self :: $ hidden_label_class = apply_filters ( 'menu_icons_hidden_label_class' , self :: $ hidden_label_class ) ; self :: $ default_style = apply_filters ( 'menu_icons_default_style' , self :: $ default_style ) ; add_action ( 'wp_enqueue_scripts' , array ( __CLASS__ , '_enqueue_styles' ) , 7 ) ; add_filter ( 'wp_nav_menu_args' , array ( __CLASS__ , '_add_menu_item_title_filter' ) ) ; add_filter ( 'wp_nav_menu' , array ( __CLASS__ , '_remove_menu_item_title_filter' ) ) ; }
Add hooks for front - end functionalities
47,629
public static function _add_icon ( $ title , $ id ) { $ meta = Menu_Icons_Meta :: get ( $ id ) ; $ icon = self :: get_icon ( $ meta ) ; if ( empty ( $ icon ) ) { return $ title ; } $ title_class = ! empty ( $ meta [ 'hide_label' ] ) ? self :: $ hidden_label_class : '' ; $ title_wrapped = sprintf ( '<span%s>%s</span>' , ( ! empty ( $ title_class ) ) ? sprintf ( ' class="%s"' , esc_attr ( $ title_class ) ) : '' , $ title ) ; if ( 'after' === $ meta [ 'position' ] ) { $ title_with_icon = "{$title_wrapped}{$icon}" ; } else { $ title_with_icon = "{$icon}{$title_wrapped}" ; } $ title_with_icon = apply_filters ( 'menu_icons_item_title' , $ title_with_icon , $ id , $ meta , $ title ) ; return $ title_with_icon ; }
Add icon to menu item title
47,630
public static function get_icon_style ( $ meta , $ keys , $ as_attribute = true ) { $ style_a = array ( ) ; $ style_s = '' ; foreach ( $ keys as $ key ) { if ( ! isset ( self :: $ default_style [ $ key ] ) ) { continue ; } $ rule = self :: $ default_style [ $ key ] ; if ( ! isset ( $ meta [ $ key ] ) || $ meta [ $ key ] === $ rule [ 'value' ] ) { continue ; } $ value = $ meta [ $ key ] ; if ( ! empty ( $ rule [ 'unit' ] ) ) { $ value .= $ rule [ 'unit' ] ; } $ style_a [ $ rule [ 'property' ] ] = $ value ; } if ( empty ( $ style_a ) ) { return $ style_s ; } foreach ( $ style_a as $ key => $ value ) { $ style_s .= "{$key}:{$value};" ; } $ style_s = esc_attr ( $ style_s ) ; if ( $ as_attribute ) { $ style_s = sprintf ( ' style="%s"' , $ style_s ) ; } return $ style_s ; }
Get icon style
47,631
public static function get_icon_classes ( $ meta , $ output = 'string' ) { $ classes = array ( '_mi' ) ; if ( empty ( $ meta [ 'hide_label' ] ) ) { $ classes [ ] = "_{$meta['position']}" ; } if ( 'string' === $ output ) { $ classes = implode ( ' ' , $ classes ) ; } return $ classes ; }
Get icon classes
47,632
public static function get_font_icon ( $ meta ) { $ classes = sprintf ( '%s %s %s' , self :: get_icon_classes ( $ meta ) , $ meta [ 'type' ] , $ meta [ 'icon' ] ) ; $ style = self :: get_icon_style ( $ meta , array ( 'font_size' , 'vertical_align' ) ) ; return sprintf ( '<i class="%s" aria-hidden="true"%s></i>' , esc_attr ( $ classes ) , $ style ) ; }
Get font icon
47,633
public static function get_image_icon ( $ meta ) { $ args = array ( 'class' => sprintf ( '%s _image' , self :: get_icon_classes ( $ meta ) ) , 'aria-hidden' => 'true' , ) ; $ style = self :: get_icon_style ( $ meta , array ( 'vertical_align' ) , false ) ; if ( ! empty ( $ style ) ) { $ args [ 'style' ] = $ style ; } return wp_get_attachment_image ( $ meta [ 'icon' ] , $ meta [ 'image_size' ] , false , $ args ) ; }
Get image icon
47,634
public static function get_svg_icon ( $ meta ) { $ classes = sprintf ( '%s _svg' , self :: get_icon_classes ( $ meta ) ) ; $ style = self :: get_icon_style ( $ meta , array ( 'svg_width' , 'vertical_align' ) ) ; return sprintf ( '<img src="%s" class="%s" aria-hidden="true"%s />' , esc_url ( wp_get_attachment_url ( $ meta [ 'icon' ] ) ) , esc_attr ( $ classes ) , $ style ) ; }
Get SVG icon
47,635
protected function create_name ( ) { $ format = '%s' ; $ format .= str_repeat ( '[%s]' , ( count ( $ this -> args -> keys ) - 1 ) ) ; return $ this -> create_id_name ( $ format ) ; }
Create name attribute
47,636
protected function build_attributes ( $ excludes = array ( ) ) { $ excludes = array_filter ( ( array ) $ excludes ) ; $ attributes = '' ; foreach ( $ this -> attributes as $ key => $ value ) { if ( in_array ( $ key , $ excludes , true ) ) { continue ; } if ( 'class' === $ key ) { $ value = implode ( ' ' , ( array ) $ value ) ; } $ attributes .= sprintf ( ' %s="%s"' , esc_attr ( $ key ) , esc_attr ( $ value ) ) ; } return $ attributes ; }
Build field attributes
47,637
public function description ( ) { if ( ! empty ( $ this -> field [ 'description' ] ) ) { $ tag = ( ! empty ( $ this -> args -> inline_description ) ) ? 'span' : 'p' ; printf ( '<%1$s class="description">%2$s</%1$s>' , $ tag , wp_kses ( $ this -> field [ 'description' ] , $ this -> allowed_html ) ) ; } }
Print field description
47,638
public function getThumbnail ( $ video_path , $ storage_path , $ thumnail_name , $ tts = 10 ) { try { if ( config ( 'thumbnail.binaries.enabled' ) ) { $ ffmpeg = FFMpeg :: create ( array ( 'ffmpeg.binaries' => config ( 'thumbnail.binaries.path.ffmpeg' ) , 'ffprobe.binaries' => config ( 'thumbnail.binaries.path.ffprobe' ) , 'timeout' => config ( 'thumbnail.binaries.path.timeout' ) , 'ffmpeg.threads' => config ( 'thumbnail.binaries.path.threads' ) , ) ) ; } else { $ ffmpeg = FFMpeg :: create ( ) ; } $ video = $ ffmpeg -> open ( $ video_path ) ; $ result_image = $ storage_path . '/' . $ thumnail_name ; $ video -> filters ( ) -> resize ( new Coordinate \ Dimension ( config ( 'thumbnail.dimensions.height' ) , config ( 'thumbnail.dimensions.width' ) ) ) -> synchronize ( ) ; $ video -> frame ( Coordinate \ TimeCode :: fromSeconds ( $ tts ) ) -> save ( $ result_image ) ; if ( $ video ) { if ( config ( 'thumbnail.watermark.image.enabled' ) ) { $ src = imagecreatefrompng ( config ( 'thumbnail.watermark.image.path' ) ) ; $ got_image = imagecreatefromjpeg ( $ result_image ) ; $ width = imagesx ( $ got_image ) ; $ height = imagesy ( $ got_image ) ; $ newwidth = config ( 'thumbnail.dimensions.width' ) ; $ newheight = config ( 'thumbnail.dimensions.height' ) ; $ tmp = imagecreatetruecolor ( $ newwidth , $ newheight ) ; imagecopyresampled ( $ tmp , $ got_image , 0 , 0 , 0 , 0 , $ newwidth , $ newheight , $ width , $ height ) ; imagesetbrush ( $ tmp , $ src ) ; imageline ( $ tmp , imagesx ( $ tmp ) / 2 , imagesy ( $ tmp ) / 2 , imagesx ( $ tmp ) / 2 , imagesy ( $ tmp ) / 2 , IMG_COLOR_BRUSHED ) ; imagejpeg ( $ tmp , $ result_image , 100 ) ; } return true ; } else { return false ; } } catch ( Exception $ thumbnailException ) { throw new Exception ( $ thumbnailException -> getMessage ( ) ) ; } }
Create Thumbnail Image
47,639
public function clipWebM ( $ src , $ dest , $ from , $ to ) { $ ffmpeg = FFMpeg :: create ( ) ; $ video = $ ffmpeg -> open ( $ src ) ; if ( $ from >= $ to ) throw new Exception ( "The start clipping time must be less than end clipping time" ) ; $ video -> filters ( ) -> clip ( Coordinate \ TimeCode :: fromSeconds ( $ from ) , Coordinate \ TimeCode :: fromSeconds ( $ to ) ) ; $ video -> save ( new Video \ WebM ( ) , $ dest ) ; if ( $ video ) return true ; else return false ; }
Clips the given video
47,640
public function watermarkVideo ( $ src , $ dest ) { $ ffmpeg = FFMpeg :: create ( ) ; $ video = $ ffmpeg -> open ( $ src ) ; if ( ! config ( 'thumbnail.watermark.video.enabled' ) ) throw new Exception ( "Configure watermark path in env file" ) ; $ video -> filters ( ) -> watermark ( config ( 'thumbnail.watermark.video.path' ) , array ( 'position' => 'relative' , 'bottom' => 50 , 'right' => 50 , ) ) ; $ video -> save ( new Video \ WebM ( ) , $ dest ) ; if ( $ video ) return true ; else return false ; }
Insert watermark on the given video
47,641
public function getToken ( $ request = null ) { $ request = $ request ? : $ this -> makeRequest ( ) ; list ( $ token ) = sscanf ( $ request -> header ( $ this -> getAuthHeaderKey ( ) ) , 'Bearer %s' ) ; if ( ! $ token ) { $ name = $ this -> getInputName ( ) ; $ token = $ request -> input ( $ name ) ; } return $ token ; }
Get the JWT token from the request
47,642
public function jwtToken ( $ request = null ) { $ token = $ this -> getToken ( $ request ) ; if ( ! $ token ) throw new NoTokenException ( 'JWT token is required.' ) ; $ driver = $ this -> makeDriver ( ) ; $ jwt = new JwtToken ( $ driver ) ; $ jwt -> setToken ( $ token ) ; return $ jwt ; }
Create a new JWT token object from the token in the request
47,643
public function jwtPayload ( $ path = null , $ request = null ) { $ jwt = $ this -> jwtToken ( $ request ) ; return $ jwt -> payload ( $ path ) ; }
Get payload from JWT token
47,644
public function validateToken ( $ token , $ secret , $ algorithm = 'HS256' ) { try { JWT :: decode ( $ token , $ secret , [ $ algorithm ] ) ; } catch ( \ Exception $ e ) { return false ; } return true ; }
Validate that the provided token
47,645
public function decodeToken ( $ token , $ secret , $ algorithm = 'HS256' ) { $ decoded = JWT :: decode ( $ token , $ secret , [ $ algorithm ] ) ; return $ this -> convertObjectToArray ( $ decoded ) ; }
Decode the provided token into an array
47,646
private function convertObjectToArray ( $ data ) { $ converted = [ ] ; foreach ( $ data as $ key => $ value ) { if ( is_object ( $ value ) ) { $ converted [ $ key ] = $ this -> convertObjectToArray ( $ value ) ; } else { $ converted [ $ key ] = $ value ; } } return $ converted ; }
Recursively convert the provided object to an array
47,647
public function handle ( $ request , Closure $ next ) { $ token = $ this -> getTokenFromRequest ( $ request ) ; $ this -> jwt -> setToken ( $ token ) -> validateOrFail ( ) ; return $ next ( $ request ) ; }
Validate JWT token before passing on to the next middleware
47,648
public function handleJwtException ( JwtException $ e ) { if ( $ e instanceof InvalidTokenException ) { return $ this -> handleJwtInvalidToken ( $ e ) ; } elseif ( $ e instanceof NoTokenException ) { return $ this -> handleJwtNoToken ( $ e ) ; } elseif ( $ e instanceof NoSecretException ) { return $ this -> handleJwtNoSecret ( $ e ) ; } else { $ message = getenv ( 'JWT_MESSAGE_ERROR' ) ? : 'There was an error while validating the authorization token.' ; return response ( ) -> json ( [ 'error' => $ message ] , 500 ) ; } }
Render JWT exception
47,649
public function validateOrFail ( $ secret = null , $ algo = null ) { if ( ! $ this -> validate ( $ secret , $ algo ) ) { throw new InvalidTokenException ( 'Token is not valid.' ) ; } return true ; }
Validate the token or throw an exception
47,650
public function payload ( $ path = null , $ secret = null , $ algo = null ) { $ token = $ this -> token ( ) ; $ secret = $ secret ? : $ this -> secret ( ) ; $ algo = $ algo ? : $ this -> algorithm ( ) ; $ payload = $ this -> jwt -> decodeToken ( $ token , $ secret , $ algo ) ; return $ this -> queryPayload ( $ payload , $ path ) ; }
Get the payload from the current token
47,651
private function queryPayload ( $ payload , $ path = null ) { if ( is_null ( $ path ) ) return $ payload ; if ( array_key_exists ( $ path , $ payload ) ) { return $ payload [ $ path ] ; } $ dotData = Arr :: dot ( $ payload ) ; if ( array_key_exists ( $ path , $ dotData ) ) { return $ dotData [ $ path ] ; } return null ; }
Query the payload using dot syntax to find specific data
47,652
public function createToken ( $ payload , $ secret = null , $ algo = null ) { $ algo = $ algo ? : $ this -> algorithm ( ) ; $ secret = $ secret ? : $ this -> secret ( ) ; if ( $ payload instanceof JwtPayloadInterface ) { $ payload = $ payload -> getPayload ( ) ; } $ newToken = $ this -> jwt -> createToken ( $ payload , $ secret , $ algo ) ; $ token = clone $ this ; $ token -> setToken ( $ newToken ) ; return $ token ; }
Create a new token with the provided payload
47,653
public function dispatchFrom ( $ command , ArrayAccess $ source , array $ extras = [ ] ) { return $ this -> dispatch ( $ this -> marshal ( $ command , $ source , $ extras ) ) ; }
Marshal a command and dispatch it to its appropriate handler .
47,654
protected function marshal ( $ command , ArrayAccess $ source , array $ extras = [ ] ) { $ injected = [ ] ; $ reflection = new ReflectionClass ( $ command ) ; if ( $ constructor = $ reflection -> getConstructor ( ) ) { $ injected = array_map ( function ( $ parameter ) use ( $ command , $ source , $ extras ) { return $ this -> getParameterValueForCommand ( $ command , $ source , $ parameter , $ extras ) ; } , $ constructor -> getParameters ( ) ) ; } return $ reflection -> newInstanceArgs ( $ injected ) ; }
Marshal a command from the given array accessible object .
47,655
public function resolveHandler ( $ command ) { if ( $ command instanceof SelfHandling ) { return $ command ; } return $ this -> container -> make ( $ this -> getHandlerClass ( $ command ) ) ; }
Get the handler instance for the given command .
47,656
private function getFormattedResults ( $ results ) { $ profileName = $ results -> getProfileInfo ( ) -> getProfileName ( ) ; $ output = '<h3>Results for profile: ' . htmlspecialchars ( $ profileName , ENT_NOQUOTES ) . '</h3>' ; if ( count ( $ results -> getRows ( ) ) > 0 ) { $ table = '<table>' ; $ table .= '<tr>' ; foreach ( $ results -> getColumnHeaders ( ) as $ header ) { $ table .= '<th>' . $ header -> getName ( ) . '</th>' ; } $ table .= '</tr>' ; foreach ( $ results -> getRows ( ) as $ row ) { $ table .= '<tr>' ; foreach ( $ row as $ cell ) { $ table .= '<td>' . htmlspecialchars ( $ cell , ENT_NOQUOTES ) . '</td>' ; } $ table .= '</tr>' ; } $ table .= '</table>' ; } else { $ table = '<p>No results found.</p>' ; } return $ output . $ table ; }
Formats the results from the Core Reporting API into some nice HTML . The profile name is printed as a header . The results of the query is printed as a table . Note all the results from the API are html escaped to prevent malicious code from running on the page .
47,657
public function getQueryParams ( ) { if ( $ pos = strpos ( $ this -> url , '?' ) ) { $ queryStr = substr ( $ this -> url , $ pos + 1 ) ; $ params = array ( ) ; parse_str ( $ queryStr , $ params ) ; return $ params ; } return array ( ) ; }
Misc function that returns an array of the query parameters of the current url used by the OAuth signing class to calculate the signature
47,658
public function setTokenFromStorage ( ) { $ accessToken = $ this -> storage -> get ( ) ; if ( isset ( $ accessToken ) ) { $ this -> client -> setAccessToken ( $ accessToken ) ; } }
Retrieves an access token from the storage object and sets it into the client object .
47,659
public function revokeToken ( ) { $ accessToken = $ this -> storage -> get ( ) ; if ( $ accessToken ) { $ tokenObj = json_decode ( $ accessToken ) ; try { $ this -> client -> revokeToken ( $ tokenObj -> refresh_token ) ; $ this -> storage -> delete ( ) ; } catch ( Google_AuthException $ e ) { $ this -> errorMsg = $ e -> getMessage ( ) ; } } header ( "Location: $this->controllerUrl" ) ; }
Revokes an authorization token . This both revokes the token by making a Google Accounts API request to revoke the token as well as deleting the token from the storage mechanism . If any errors occur the authorization exception is caught and the message is stored in error .
47,660
public function execute ( ) { if ( count ( $ this -> getInputParameters ( ) ) ) { if ( $ this -> isSubmitComplete ( ) ) { $ this -> formValues = $ this -> getFormValues ( ) ; $ this -> run ( ) ; } else { $ this -> renderInputForm ( ) ; } } else { $ this -> run ( ) ; } }
Executes the example checks if the examples requires parameters and request them before invoking run .
47,661
protected function renderInputForm ( ) { $ parameters = $ this -> getInputParameters ( ) ; if ( count ( $ parameters ) ) { printf ( '<h2>Enter %s parameters</h2>' , $ this -> getName ( ) ) ; print '<form method="POST"><fieldset>' ; foreach ( $ parameters as $ parameter ) { $ name = $ parameter [ 'name' ] ; $ display = $ parameter [ 'display' ] ; $ currentValue = isset ( $ _POST [ $ name ] ) ? $ _POST [ $ name ] : '' ; printf ( '%s: <input name="%s" value="%s">' , $ display , $ name , $ currentValue ) ; if ( $ parameter [ 'required' ] ) { print '*' ; } print '</br>' ; } print '</fieldset>*required<br/>' ; print '<input type="submit" name="submit" value="Submit"/>' ; print '</form>' ; } }
Renders an input form to capture the example parameters .
47,662
protected function isSubmitComplete ( ) { if ( ! isset ( $ _POST [ 'submit' ] ) ) { return false ; } foreach ( $ this -> getInputParameters ( ) as $ parameter ) { if ( $ parameter [ 'required' ] && empty ( $ _POST [ $ parameter [ 'name' ] ] ) ) { return false ; } } return true ; }
Checks if the form has been submitted and all required parameters are set .
47,663
protected function getFormValues ( ) { $ input = array ( ) ; foreach ( $ this -> getInputParameters ( ) as $ parameter ) { if ( isset ( $ _POST [ $ parameter [ 'name' ] ] ) ) { $ input [ $ parameter [ 'name' ] ] = $ _POST [ $ parameter [ 'name' ] ] ; } } return $ input ; }
Retrieves the submitted form values .
47,664
private function queryCoreReportingApi ( $ tableId ) { $ optParams = array ( 'dimensions' => 'ga:source,ga:keyword' , 'sort' => '-ga:visits,ga:keyword' , 'filters' => 'ga:medium==organic' , 'max-results' => '25' ) ; return $ this -> analytics -> data_ga -> get ( urldecode ( $ tableId ) , '2010-01-01' , '2010-01-15' , 'ga:visits' , $ optParams ) ; }
Queries the Core Reporting API for the top 25 organic search terms ordered by visits . Because the table id comes from the query parameter it needs to be URI decoded .
47,665
private function getFormattedResults ( & $ results ) { return implode ( '' , array ( $ this -> getReportInfo ( $ results ) , $ this -> getPaginationInfo ( $ results ) , $ this -> getProfileInformation ( $ results ) , $ this -> getQueryParameters ( $ results ) , $ this -> getColumnHeaders ( $ results ) , $ this -> getTotalsForAllResults ( $ results ) , $ this -> getRows ( $ results ) ) ) ; }
Returns the results from the API as a HTML formatted string .
47,666
private function getQueryParameters ( & $ results ) { $ query = $ results -> getQuery ( ) ; $ html = '<h3>Query Parameters</h3><pre>' ; foreach ( $ query as $ paramName => $ value ) { $ html .= "$paramName = $value\n" ; } $ html .= '</pre>' ; return $ html ; }
Returns all the query parameters in the initial API query .
47,667
private function getColumnHeaders ( & $ results ) { $ html = '<h3>Column Headers</h3><pre>' ; $ headers = $ results -> getColumnHeaders ( ) ; foreach ( $ headers as $ header ) { $ html .= <<<HTMLColumn Name = {$header->getName()}Column Type = {$header->getColumnType()}Data Type = {$header->getDataType()}HTML ; } $ html .= '</pre>' ; return $ html ; }
Returns all the column headers for the table view .
47,668
private function getTotalsForAllResults ( & $ results ) { $ rowCount = count ( $ results -> getRows ( ) ) ; $ totalResults = $ results -> getTotalResults ( ) ; $ html = '<h3>Total Metrics For All Results</h3>' ; $ html .= "<p>This query returned $rowCount rows. <br>" ; $ html .= "But the query matched $totalResults total results. <br>" ; $ html .= 'Here are the metric totals for the matched results.</p>' ; $ html .= '<pre>' ; $ totals = $ results -> getTotalsForAllResults ( ) ; foreach ( $ totals as $ metricName => $ metricTotal ) { $ html .= "Metric Name = $metricName\n" ; $ html .= "Metric Total = $metricTotal" ; } $ html .= '</pre>' ; return $ html ; }
Returns the totals for all the results .
47,669
private function getRows ( $ results ) { $ table = '<h3>Rows Of Data</h3>' ; if ( count ( $ results -> getRows ( ) ) > 0 ) { $ table .= '<table>' ; $ table .= '<tr>' ; foreach ( $ results -> getColumnHeaders ( ) as $ header ) { $ table .= '<th>' . $ header -> name . '</th>' ; } $ table .= '</tr>' ; foreach ( $ results -> getRows ( ) as $ row ) { $ table .= '<tr>' ; foreach ( $ row as $ cell ) { $ table .= '<td>' . htmlspecialchars ( $ cell , ENT_NOQUOTES ) . '</td>' ; } $ table .= '</tr>' ; } $ table .= '</table>' ; } else { $ table .= '<p>No results found.</p>' ; } return $ table ; }
Returns the rows of data as an HTML Table .
47,670
private function buildTree ( $ account , & $ data , $ parent ) { $ data [ ] = array ( $ account [ 'name' ] , null , 1 ) ; if ( $ account [ 'subAccounts' ] ) { foreach ( $ account [ 'subAccounts' ] as $ subAccount ) { $ this -> buildTree ( $ subAccount , $ data , $ account [ 'name' ] ) ; } } }
Builds the data structure to represent the tree from the API response .
47,671
private function getTraverseManagementApiHtml ( ) { $ accounts = $ this -> analytics -> management_accounts -> listManagementAccounts ( ) ; $ html = $ this -> getAccountsHtml ( $ accounts ) ; if ( count ( $ accounts -> getItems ( ) ) > 0 ) { $ firstAccountId = $ this -> getFirstId ( $ accounts ) ; $ webproperties = $ this -> analytics -> management_webproperties -> listManagementWebproperties ( $ firstAccountId ) ; $ html .= $ this -> getWebpropertiesHtml ( $ webproperties ) ; if ( count ( $ webproperties -> getItems ( ) ) > 0 ) { $ firstWebpropertyId = $ this -> getFirstId ( $ webproperties ) ; $ profiles = $ this -> analytics -> management_profiles -> listManagementProfiles ( $ firstAccountId , $ firstWebpropertyId ) ; $ html .= $ this -> getProfilesHtml ( $ profiles ) ; if ( count ( $ profiles -> getItems ( ) ) > 0 ) { $ firstProfileId = $ this -> getFirstId ( $ profiles ) ; $ goals = $ this -> analytics -> management_goals -> listManagementGoals ( $ firstAccountId , $ firstWebpropertyId , $ firstProfileId ) ; $ html .= $ this -> getGoalsHtml ( $ goals ) ; } } } $ segments = $ this -> analytics -> management_segments -> listManagementSegments ( ) ; $ html .= $ this -> getSegmentsHtml ( $ segments ) ; return $ html ; }
Traverses the Management API . A query is made to the Accounts collection . The first account ID is used to then query the webproperties collection . The first webproperty ID is used to query the profiles collection . The first profile is used to query the goals collection . Finally the segments collection is queries . At each level an HTML representation is rendered of the entire collection . If one of the levels has no entities to query for a child level then traversal stops .
47,672
private function getAccountsHtml ( & $ accounts ) { $ html = '<h3>Accounts Collection</h3>' . $ this -> getCollectionInfoHtml ( $ accounts ) ; $ items = $ accounts -> getItems ( ) ; if ( count ( $ items ) == 0 ) { $ html .= '<p>No Accounts Found</p>' ; } else { foreach ( $ items as & $ account ) { $ html .= <<<HTML<hr><pre>Account ID = {$account->getId()}Kind = {$account->getKind()}Self Link = {$account->getSelfLink()}Account Name = {$account->getName()}Created = {$account->getCreated()}Updated = {$account->getUpdated()}</pre>HTML ; } } return $ html ; }
Returns important information from the accounts collection .
47,673
private function getWebpropertiesHtml ( & $ webproperties ) { $ html = '<h3>Webproperties Collection</h3>' . $ this -> getCollectionInfoHtml ( $ webproperties ) ; $ items = $ webproperties -> getItems ( ) ; if ( count ( $ items ) == 0 ) { $ html .= '<p>No Web Properties Found</p>' ; } else { foreach ( $ items as & $ webproperty ) { $ html .= <<<HTML<hr><pre>Kind = {$webproperty->getKind()}Account ID = {$webproperty->getAccountId()}Webproperty ID = {$webproperty->getId()}Internal Webproperty ID = {$webproperty->getInternalWebPropertyId()}Website URL = {$webproperty->getWebsiteUrl()}Created = {$webproperty->getCreated()}Updated = {$webproperty->getUpdated()}Self Link = {$webproperty->getSelfLink()}Parent LinkParent link href = {$webproperty->getParentLink()->getHref()}Parent link type = {$webproperty->getParentLink()->getType()}Child LinkChild link href = {$webproperty->getChildLink()->getHref()}Child link type = {$webproperty->getChildLink()->getType()}</pre>HTML ; } } return $ html ; }
Returns important information from the webproperties collection .
47,674
private function getProfilesHtml ( & $ profiles ) { $ html = '<h3>Profiles Collections</h3>' . $ this -> getCollectionInfoHtml ( $ profiles ) ; $ items = $ profiles -> getItems ( ) ; if ( count ( $ items ) == 0 ) { $ html .= '<p>No Profiles Found</p>' ; } else { foreach ( $ items as & $ profile ) { $ html .= <<<HTML<hr><pre>Kind = {$profile->getKind()}Account ID = {$profile->getAccountId()}Web Property ID = {$profile->getWebPropertyId()}Internal Web Property ID = {$profile->getInternalWebPropertyId()}Profile ID = {$profile->getId()}Profile Name = {$profile->getName()}Currency = {$profile->getCurrency()}Timezone = {$profile->getTimezone()}Default Page = {$profile->getDefaultPage()}Exclude Query Parameters = {$profile->getExcludeQueryParameters()}Site Search Category Parameters = {$profile->getSiteSearchCategoryParameters()}Site Search Query Parameters = {$profile->getSiteSearchQueryParameters()}Created = {$profile->getCreated()}Updated = {$profile->getUpdated()}Self Link = {$profile->getSelfLink()}Parent LinkParent Link href = {$profile->getParentLink()->getHref()}Parent link type = {$profile->getParentLink()->getType()}Child LinkChild link href = {$profile->getChildLink()->getHref()}Child link type = {$profile->getChildLink()->getType()}</pre>HTML ; } } return $ html ; }
Returns important information from the profiles collection .
47,675
private function getGoalsHtml ( & $ goals ) { $ html = '<h3>Goals Collections</h3>' . $ this -> getCollectionInfoHtml ( $ goals ) ; $ items = $ goals -> getItems ( ) ; if ( count ( $ items ) == 0 ) { $ html .= '<p>No Goals Found</p>' ; } else { foreach ( $ items as & $ goal ) { $ html .= <<<HTML<hr><pre>Goal ID = {$goal->getId()}Kind = {$goal->getKind()}Self Link = {$goal->getSelfLink()}Account ID = {$goal->getAccountId()}Web Property ID = {$goal->getWebPropertyId()}Internal Web Property ID = {$goal->getInternalWebPropertyId()}Profile IDGoal Name = {$goal->getName()}Goal Value = {$goal->getValue()}Goal Active = {$goal->getActive()}Goal Type = {$goal->getType()}Created = {$goal->getCreated()}Updated = {$goal->getUpdated()}Parent LinkParent link href = {$goal->getParentLink()->getHref()}Parent link type = {$goal->getParentLink()->getHref()}</pre>HTML ; switch ( $ goal -> getType ( ) ) { case 'URL_DESTINATION' : $ html .= $ this -> getUrlDestinationDetailsHtml ( $ goal -> getUrlDestinationDetails ( ) ) ; break ; case 'VISIT_TIME_ON_SITE' : $ html .= $ this -> getVisitTimeOnSiteDetailsHtml ( $ goal -> getVisitTimeOnSiteDetails ( ) ) ; break ; case 'VISIT_NUM_PAGES' : $ html .= $ this -> getVisitNumPagesDetailsHtml ( $ goal -> getVisitNumPagesDetails ( ) ) ; break ; case 'EVENT' : $ html .= $ this -> getEventDetailsHtml ( $ goal -> getEventDetails ( ) ) ; break ; } } } return $ html ; }
Returns important information from the goals collection .
47,676
private function getUrlDestinationDetailsHtml ( & $ details ) { $ html = '<h4>Url Destination Goal</h4>' ; $ html .= <<<HTML<pre>Goal URL = {$details->getUrl()}Case Sensitive = {$details->getCaseSensitive()}Match Type = {$details->getMatchType()}First Step Required = {$details->getFirstStepRequired()}</pre>HTML ; $ html .= '<h4>Destination Goal Steps</h4>' ; $ steps = $ details -> getSteps ( ) ; if ( count ( $ steps ) == 0 ) { $ html .= '<p>No Steps Configured</p>' ; } else { foreach ( $ steps as & $ step ) { $ html .= <<<HTML<pre>Step Number = {$step->getNumber()}Step Name = {$step->getName()}Step URL = {$step->getUrl()}</pre>HTML ; } } return $ html ; }
Returns important information for url destination type goals .
47,677
private function getEventDetailsHtml ( & $ details ) { $ html = '<h4>Event Goal</h4><pre>' . 'Use Event Value = ' . $ details -> getUseEventValue ( ) ; $ conditions = $ details -> getEventConditions ( ) ; $ stringTypes = array ( 'CATEGORY' , 'ACTION' , 'LABEL' ) ; foreach ( $ conditions as & $ condition ) { $ html .= "Event Type = $condition->getEventType()" ; $ eventType = $ condition -> getType ( ) ; if ( in_array ( $ eventType , $ stringTypes ) ) { $ html .= "Match Type = $condition->getMatchType()" . "Expression = $condition->getExpression()" ; } else { $ html .= "Comparison Type = $condition->getComparisonType()" . "Comparison Value = $condition->getComparisonValue()" ; } } return $ html . '</pre>' ; }
Returns important information for event goals .
47,678
private function getSegmentsHtml ( & $ segments ) { $ html = '<h3>Segments Collection</h3>' . $ this -> getCollectionInfoHtml ( $ segments ) ; $ items = $ segments -> getItems ( ) ; if ( count ( $ items ) == 0 ) { $ html .= '<p>No Segments Found</p>' ; } else { foreach ( $ items as & $ segment ) { $ html .= <<<HTML<hr><pre>Segment ID = {$segment->getId()}Kind = {$segment->getKind()}Self Link = {$segment->getSelfLink()}Name = {$segment->getName()}Definition = {$segment->getDefinition()}Created = {$segment->getCreated()}Updated = {$segment->getUpdated()}</pre>HTML ; } } return $ html ; }
Returns important information from the segments collection .
47,679
private function getCollectionInfoHtml ( & $ collection ) { $ previousLink = $ collection -> getPreviousLink ( ) ? $ collection -> getPreviousLink ( ) : 'none' ; $ nextLink = $ collection -> getNextLink ( ) ? $ collection -> getNextLink ( ) : 'none' ; return <<<HTML<pre>Username = {$collection->getUsername()}Items Per Page = {$collection->getItemsPerPage()}Total Results = {$collection->getTotalResults()}Start Index = {$collection->getStartIndex()}Previous Link = {$previousLink}Next Link = {$nextLink}</pre>HTML ; }
Returns important information common to each collection in the API . Most of this data can be used to paginate through the results .
47,680
public static function processFileUpload ( $ file , $ mime ) { if ( ! $ file ) return array ( ) ; if ( substr ( $ file , 0 , 1 ) != '@' ) { $ file = '@' . $ file ; } $ params = array ( 'postBody' => array ( 'file' => $ file ) ) ; if ( $ mime ) { $ params [ 'content-type' ] = $ mime ; } return $ params ; }
Prepares a standard file upload via cURL .
47,681
public function refreshToken ( ) { if ( $ this -> apiClient -> getAccessToken ( ) != null ) { $ dbh = new PDO ( 'sqlite:examples.sqlite' ) ; $ this -> saveToken ( $ dbh , true , $ this -> apiClient -> getAccessToken ( ) ) ; } }
During the request the access code might have been changed for another . This function updates the token in the db .
47,682
private function getToken ( $ dbh ) { $ stmt = $ dbh -> prepare ( 'SELECT token FROM auth WHERE user= ?' ) ; $ stmt -> execute ( array ( $ this -> user ) ) ; $ row = $ stmt -> fetch ( PDO :: FETCH_ASSOC ) ; return $ row [ 'token' ] ; }
Retrieves token for use .
47,683
public function setCustomFieldValue ( $ field_name , $ value , $ editor = null , $ required = null ) { $ custom_fields = isset ( $ this -> custom_fields ) ? json_decode ( $ this -> custom_fields ) : array ( ) ; $ custom_fields [ ] = array ( 'name' => $ field_name , 'value' => $ value , 'editor' => $ editor , 'required' => $ required ) ; $ this -> custom_fields = json_encode ( $ custom_fields ) ; return $ this ; }
Set the value for a custom field with the given field name and optionally define a Role allowed to edit it and if the field is required to be filled
47,684
public function addAttachment ( $ name , $ signer_index , $ instructions = null , $ required = null ) { $ attachment = new Attachment ( array ( 'name' => $ name , 'instructions' => $ instructions , 'signer_index' => $ signer_index , 'required' => $ required ) ) ; $ this -> attachments [ ] = $ attachment ; return $ this ; }
Adds an Attachment to the SignatureRequest
47,685
public function getMetadata ( $ key ) { if ( ! is_array ( $ this -> metadata ) ) { $ this -> metadata = json_decode ( json_encode ( $ this -> metadata ) , true ) ; } return ( isset ( $ this -> metadata [ $ key ] ) ) ? $ this -> metadata [ $ key ] : null ; }
Get the current metadata value for the provided key .
47,686
public function setCollection ( $ array ) { foreach ( $ array as $ key => $ object ) { $ class_name = "HelloSign\\{$this->resource_class}" ; $ resource = new $ class_name ; $ resource -> fromObject ( $ object ) ; $ this -> collection [ $ key ] = $ resource ; } return $ this ; }
Populate collection from array
47,687
public function addSigner ( $ email_or_signer , $ name = null , $ index = null ) { $ signer = ( $ email_or_signer instanceof Signer ) ? $ email_or_signer : new Signer ( array ( 'name' => $ name , 'email_address' => $ email_or_signer ) ) ; if ( isset ( $ index ) ) { $ this -> signers [ $ index ] = $ signer ; } else { $ this -> signers [ ] = $ signer ; } return $ this ; }
Adds a signer to the signature request
47,688
public function addGroup ( $ name , $ group_index_or_role = 0 ) { $ group = new SignerGroup ( array ( 'name' => $ name ) ) ; $ this -> signers [ $ group_index_or_role ] = $ group ; return $ this ; }
Adds a Signer Group to the Signature Request
47,689
public function addGroupSigner ( $ name , $ email , $ signer_index , $ group_index_or_role = 0 ) { $ signer = new Signer ( array ( 'name' => $ name , 'email_address' => $ email ) ) ; $ this -> signers [ $ group_index_or_role ] -> $ signer_index = $ signer ; return $ this ; }
Adds Signers to a Signer Group in the Signature Request
47,690
public function isValid ( $ api_key ) { if ( ! $ api_key ) { return false ; } return ( $ this -> event_hash == $ this -> calculateHash ( $ api_key ) ) ? true : false ; }
Check the event is valid or not
47,691
public function setTemplateId ( $ id , $ order = null ) { if ( $ order === null ) { $ this -> template_ids [ ] = $ id ; } else { $ this -> template_ids [ $ order ] = $ id ; } return $ this ; }
Set the template ID along with an optional order
47,692
public function setSigner ( $ role , $ email_or_signer , $ name = null ) { return parent :: addSigner ( $ email_or_signer , $ name , $ role ) ; }
Set the signer to the list of signers for this request
47,693
public function setCC ( $ role , $ email ) { $ obj = new stdClass ; $ obj -> email_address = $ email ; $ this -> ccs [ $ role ] = $ obj ; return $ this ; }
Sets the CC email address for the provided role
47,694
public function fromResponse ( $ response ) { $ this -> page = $ response -> list_info -> page ; $ this -> num_pages = $ response -> list_info -> num_pages ; $ this -> num_results = $ response -> list_info -> num_results ; $ this -> page_size = $ response -> list_info -> page_size ; property_exists ( $ response , $ this -> list_type ) && $ this -> setCollection ( $ response -> { $ this -> list_type } ) ; return $ this ; }
Populate from response
47,695
public function addSignerfile ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new Error ( 'file not found' , 'File does not exist. Please use an absolute file path.' ) ; } $ this -> signer_file = fopen ( $ file , 'rb' ) ; return $ this ; }
Adds a list of signers in a CSV file . Required unless signer_list is used .
47,696
public function sendSignatureRequest ( SignatureRequest $ request ) { $ params = $ request -> toParams ( ) ; $ response = $ this -> rest -> post ( static :: SIGNATURE_REQUEST_SEND_PATH , $ params ) ; $ this -> checkResponse ( $ response ) ; return $ request -> fromResponse ( $ response ) ; }
Send a new SignatureRequest with the submitted documents
47,697
public function cancelSignatureRequest ( $ id ) { $ response = $ this -> rest -> post ( static :: SIGNATURE_REQUEST_CANCEL_PATH . '/' . $ id ) ; $ this -> checkResponse ( $ response , false ) ; return true ; }
Cancels an existing signature request
47,698
public function requestEmailReminder ( $ request_id , $ email , $ name = null ) { $ response = $ this -> rest -> post ( static :: SIGNATURE_REQUEST_REMIND_PATH . '/' . $ request_id , array ( 'email_address' => $ email , 'name' => $ name ) ) ; $ this -> checkResponse ( $ response ) ; return new SignatureRequest ( $ response ) ; }
Instructs HelloSign to email the given address with a reminder to sign the SignatureRequest referenced by the given request ID .
47,699
public function updateSignatureRequest ( $ request_id , $ signature_id , $ email ) { $ response = $ this -> rest -> post ( static :: SIGNATURE_REQUEST_UPDATE_PATH . '/' . $ request_id , array ( 'signature_id' => $ signature_id , 'email_address' => $ email ) ) ; $ this -> checkResponse ( $ response ) ; return new SignatureRequest ( $ response ) ; }
Updates the email address for a given signer on a SignatureRequest