idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
33,500
protected static function boot ( ) { parent :: boot ( ) ; self :: creating ( function ( $ model ) { do { $ id = mt_rand ( pow ( 10 , 9 ) , pow ( 2 , 32 ) - 1 ) ; } while ( self :: find ( $ id ) ) ; $ model -> { $ model -> getKeyName ( ) } = $ id ; } ) ; }
Find and use an unused non - sequential ID for a record as part of a model s creation . ID will be a 32 - bit unsigned integer of 10 characters in length .
33,501
private function array_walk ( & $ original , $ callback , $ userdata = [ ] ) { $ resolved = ( array ) $ original ; array_walk ( $ resolved , $ callback , $ userdata ) ; if ( count ( ( array ) $ original ) == 1 ) $ resolved = reset ( $ resolved ) ; $ original = $ resolved ; }
Used to translate shorthand
33,502
public function createProperty ( $ name , $ type = NULL , $ default = self :: UNDEFINED , $ modifiers = GProperty :: MODIFIER_PROTECTED ) { $ gProperty = GProperty :: create ( $ name , $ type , $ default , $ modifiers ) ; $ this -> addProperty ( $ gProperty ) ; return $ gProperty ; }
Creates a new property and adds it to the class
33,503
public function createConstant ( $ name , $ type = NULL , $ default = self :: UNDEFINED , $ modifiers = GConstant :: MODIFIER_PROTECTED ) { $ gConstant = GConstant :: create ( $ name , $ type , $ default , $ modifiers ) ; $ this -> addConstant ( $ gConstant ) ; return $ gConstant ; }
Creates a new constant and adds it to the class
33,504
protected function needsImplementation ( Gmethod $ method ) { return ( $ method -> isAbstract ( ) || $ method -> isInInterface ( ) ) && ! $ this -> hasMethod ( $ method -> getName ( ) ) ; }
Returns if the method needs implementation in this class
33,505
public function setFQN ( $ fqn ) { if ( FALSE !== ( $ pos = mb_strrpos ( $ fqn , '\\' ) ) ) { $ this -> namespace = ltrim ( mb_substr ( $ fqn , 0 , $ pos + 1 ) , '\\' ) ; $ this -> setName ( mb_substr ( $ fqn , $ pos ) ) ; } else { $ this -> namespace = NULL ; $ this -> setName ( $ fqn ) ; } }
Replaces the Namespace and Name of the Class
33,506
public function getAllInterfaces ( $ types = self :: FULL_HIERARCHY ) { if ( $ types & self :: WITH_OWN ) { $ interfaces = clone $ this -> interfaces ; } else { $ interfaces = new GObjectCollection ( array ( ) ) ; } if ( ( $ types & self :: WITH_PARENTS ) && ( $ parent = $ this -> getParent ( ) ) != NULL ) { $ parentTypes = $ types | self :: WITH_OWN ; foreach ( $ parent -> getAllInterfaces ( $ parentTypes ) as $ interface ) { if ( ! $ interfaces -> has ( $ interface ) ) { $ interfaces -> add ( $ interface ) ; } } } return $ interfaces -> toArray ( ) ; }
Returns the interfaces from the class and from all parents
33,507
public function getAllProperties ( $ types = self :: FULL_HIERARCHY ) { if ( $ types & self :: WITH_OWN ) { $ properties = clone $ this -> properties ; } else { $ properties = new GObjectCollection ( array ( ) ) ; } if ( $ types & self :: WITH_PARENTS && $ this -> getParent ( ) != NULL ) { $ parentTypes = $ types | self :: WITH_OWN ; foreach ( $ this -> getParent ( ) -> getAllProperties ( $ parentTypes ) as $ property ) { if ( ! $ properties -> has ( $ property ) ) { $ properties -> add ( $ property ) ; } } } return $ properties -> toArray ( ) ; }
Returns the properties of the class and the properties of all parents
33,508
public function getAllMethods ( $ types = self :: FULL_HIERARCHY ) { if ( $ types & self :: WITH_OWN ) { $ methods = clone $ this -> methods ; } else { $ methods = new GObjectCollection ( array ( ) ) ; } if ( $ types & self :: WITH_PARENTS && $ this -> getParent ( ) != NULL ) { $ parentTypes = $ types | self :: WITH_OWN ; foreach ( $ this -> getParent ( ) -> getAllMethods ( $ parentTypes ) as $ method ) { if ( ! $ methods -> has ( $ method ) ) { $ methods -> add ( $ method ) ; } } } $ interfaceTypes = 0x000000 ; if ( $ types & self :: WITH_INTERFACE ) $ interfaceTypes |= self :: WITH_OWN ; if ( $ types & self :: WITH_PARENTS_INTERFACES ) $ interfaceTypes |= self :: WITH_PARENTS ; foreach ( $ this -> getAllInterfaces ( $ interfaceTypes ) as $ interface ) { foreach ( $ interface -> getMethods ( ) as $ method ) { if ( ! $ methods -> has ( $ method ) ) { $ methods -> add ( $ method ) ; } } } return $ methods -> toArray ( ) ; }
Returns the methods of the class and the methods of all parents
33,509
public function addImport ( ClassInterface $ gClass , $ alias = NULL ) { $ this -> ownImports -> add ( $ gClass , $ alias ) ; return $ this ; }
Adds an import to the Class
33,510
public function getImports ( $ types = 0x000000 ) { $ imports = clone $ this -> ownImports ; foreach ( $ this -> getProperties ( ) as $ property ) { if ( $ property -> getType ( ) instanceof ObjectType && $ property -> getType ( ) -> hasClass ( ) ) { $ imports -> add ( new GClass ( $ property -> getType ( ) -> getClassFQN ( ) ) ) ; } } foreach ( $ this -> getMethods ( ) as $ method ) { foreach ( $ method -> getParameters ( ) as $ parameter ) { if ( $ parameter -> getType ( ) instanceof ObjectType && $ parameter -> getType ( ) -> hasClass ( ) ) { $ imports -> add ( new GClass ( $ parameter -> getType ( ) -> getClassFQN ( ) ) ) ; } } } if ( $ types & self :: WITH_EXTENDS && $ this -> parentClass != NULL ) { $ imports -> add ( $ this -> parentClass ) ; } if ( $ types & self :: WITH_INTERFACE ) { foreach ( $ this -> getInterfaces ( ) as $ interface ) { $ imports -> add ( $ interface ) ; } } return $ imports ; }
Returns the Imports which are used in the code of the class
33,511
public static function attachToUser ( Model $ user , array $ scopes ) { $ attach_scopes = [ ] ; foreach ( $ scopes as $ scope ) { $ attach_scopes [ ] = [ 'user_id' => $ user -> id , 'oauth_scope_id' => $ scope , ] ; } DB :: table ( 'oauth_scope_user' ) -> insert ( $ attach_scopes ) ; }
Provide a convenience method for attaching scopes to a user
33,512
public function getResultMessage ( ) { $ parts = [ ] ; $ node = $ this -> getFirst ( '//epp:epp/epp:response/epp:result/epp:msg' ) ; $ parts [ ] = $ node -> nodeValue ; $ nodes = $ this -> get ( '//epp:epp/epp:response/epp:result/epp:extValue/epp:value/*' ) ; foreach ( $ nodes as $ node ) { $ parts [ ] = $ this -> saveXML ( $ node ) ; } $ nodes = $ this -> get ( '//epp:epp/epp:response/epp:result/epp:extValue/epp:reason' ) ; foreach ( $ nodes as $ node ) { $ parts [ ] = $ node -> nodeValue ; } return implode ( "\n" , $ parts ) ; }
Human - readable description of the response code .
33,513
protected function getQueryInfos ( $ query ) { $ type = strtolower ( substr ( $ query , 0 , 6 ) ) ; switch ( $ type ) { case 'select' : $ pattern = '/SELECT\s((.|\n)*)\sFROM\s(?P<table>[a-zA-Z_]*)($|(.*)$)/i' ; break ; case 'insert' : $ pattern = '/INSERT(\s+)INTO(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i' ; break ; case 'update' : $ pattern = '/UPDATE(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i' ; break ; case 'delete' : $ pattern = '/DELETE(\s+)FROM(\s+)(?P<table>[a-zA-Z_]*)(\s*)(.*)/i' ; break ; default : $ type = 'other' ; $ pattern = false ; } if ( $ pattern && preg_match ( $ pattern , $ query , $ matches ) ) { return array ( $ type , $ matches [ 'table' ] ) ; } return array ( $ type , '__unknown' ) ; }
These patterns will match most of the doctrine generated queries
33,514
public static function response ( $ mdata = array ( ) , $ status = null , $ msg = '' ) { if ( is_array ( $ mdata ) && isset ( $ mdata [ 'msg' ] ) && isset ( $ mdata [ 'data' ] ) && isset ( $ mdata [ 'status' ] ) && ! $ status ) { $ status = $ mdata [ 'status' ] ; $ msg = $ mdata [ 'msg' ] ; $ mdata = $ mdata [ 'data' ] ; } if ( ! $ status && count ( $ mdata ) ) { $ status = 200 ; } elseif ( ! $ status ) { $ status = 400 ; } $ response = array ( 'status' => $ status , 'msg' => $ msg , 'data' => $ mdata ) ; return $ response ; }
Response Wrapper Helper
33,515
public static function responseMerge ( $ mdata , $ mergedData , $ status = null , $ msg = null ) { $ data = self :: response ( $ mdata , $ status , $ msg ) ; $ data = Arr :: merge ( $ data , $ mergedData ) ; return $ data ; }
Little response helper to merge data
33,516
public static function getCountries ( ) { $ countries = array ( ) ; $ frequently = array ( ) ; foreach ( Convert :: $ aCountries as $ k => $ country ) { if ( in_array ( strtolower ( $ k ) , [ 'be' , 'fr' , 'gb' ] ) ) { $ frequently [ strtolower ( $ k ) ] = $ country ; } else { $ countries [ strtolower ( $ k ) ] = $ country ; } } return array_merge ( $ frequently , $ countries ) ; }
Get Countries available
33,517
public function build ( ) { foreach ( $ this -> child as $ element ) { $ element -> build ( ) ; $ this -> node -> appendChild ( $ element -> getNode ( ) ) ; } return $ this ; }
Building a request for sending .
33,518
protected function getSpecialPageList ( ) { $ siteId = $ this -> contextManager -> getSiteId ( ) ; $ language = $ this -> contextManager -> getSiteDefaultLanguage ( ) ; $ specialPages = $ this -> nodeRepository -> findAllSpecialPage ( $ language , $ siteId ) ; $ specialPageChoice = array ( ) ; foreach ( $ specialPages as $ node ) { $ specialPageChoice [ $ node -> getId ( ) ] = $ node -> getSpecialPageName ( ) ; } return $ specialPageChoice ; }
get special pages list
33,519
protected function _f ( string $ P , string $ S , int $ c , int $ i ) : string { $ U = $ this -> _prf -> compute ( $ P , $ S . pack ( "N" , $ i ) ) ; $ result = $ U ; for ( $ x = 2 ; $ x <= $ c ; ++ $ x ) { $ U_x = $ this -> _prf -> compute ( $ P , $ U ) ; $ result ^= $ U_x ; $ U = $ U_x ; } return $ result ; }
XOR - sum function F .
33,520
protected function getArguments ( ) { return array ( array ( 'name' , InputArgument :: REQUIRED , false ) , array ( 'type' , InputArgument :: OPTIONAL , false ) , array ( 'folder' , InputArgument :: OPTIONAL , false ) , ) ; }
Get the console command arguments .
33,521
public function nested_table ( $ instance_name = '' , $ field = '' , $ inner_tbl = '' , $ tbl_field = '' ) { if ( $ instance_name && $ field && $ inner_tbl && $ tbl_field ) { $ fdata = $ this -> _parse_field_names ( $ field , 'nested_table' ) ; foreach ( $ fdata as $ fitem ) { $ this -> inner_table_instance [ $ instance_name ] = $ fitem [ 'table' ] . '.' . $ fitem [ 'field' ] ; $ instance = Fruit :: get_instance ( $ instance_name ) ; $ instance -> table ( $ this -> prefix . $ inner_tbl ) ; $ instance -> is_inner = true ; $ fdata2 = $ this -> _parse_field_names ( $ tbl_field , 'nested_table' , $ inner_tbl ) ; $ instance -> inner_where [ $ fitem [ 'table' ] . '.' . $ fitem [ 'field' ] ] = key ( $ fdata2 ) ; return $ instance ; } } }
nested table constructor
33,522
public function mass_alert ( $ email_table = '' , $ email_column = '' , $ emeil_where = '' , $ subject = '' , $ message = '' , $ link = false , $ field = false , $ value = false , $ mode = 'all' ) { $ table = $ this -> _get_table ( 'mass_alert' ) ; $ field = $ this -> table . '.' . $ field ; if ( $ mode == 'all' or $ mode == 'create' ) $ this -> mass_alert_create [ ] = array ( 'email_table' => $ email_table , 'email_column' => $ email_column , 'where' => $ emeil_where , 'subject' => $ subject , 'message' => $ message , 'link' => $ link , 'field' => $ field , 'value' => $ value , 'table' => $ table ) ; if ( $ mode == 'all' or $ mode == 'edit' ) $ this -> mass_alert_edit [ ] = array ( 'email_table' => $ email_table , 'email_column' => $ email_column , 'where' => $ emeil_where , 'subject' => $ subject , 'message' => $ message , 'link' => $ link , 'field' => $ field , 'value' => $ value , 'table' => $ table ) ; return $ this ; }
NEEDS TO BE REWRITTEN
33,523
public function render ( $ task = false , $ primary = false ) { $ this -> benchmark_start ( ) ; $ this -> _receive_post ( $ task , $ primary ) ; $ this -> _regenerate_key ( ) ; $ this -> _remove_and_save_uploads ( ) ; $ this -> _get_language ( ) ; $ this -> _get_theme_config ( ) ; if ( $ this -> query ) { return $ this -> render_custom_query_task ( ) ; } $ this -> _get_table_info ( ) ; return $ this -> _run_task ( ) ; }
public renderer final instance method
33,524
protected function _run_task ( ) { if ( $ this -> after && $ this -> after == $ this -> task ) { return self :: error ( 'Task recursion!' ) ; } if ( ! $ this -> task ) { $ this -> task = 'list' ; } switch ( $ this -> task ) { case 'create' : $ this -> _set_field_types ( 'create' ) ; return $ this -> _create ( ) ; break ; case 'edit' : $ this -> _set_field_types ( 'edit' ) ; return $ this -> _entry ( 'edit' ) ; break ; case 'save' : if ( ! $ this -> before ) { return self :: error ( 'Restricted task!' ) ; } $ this -> _set_field_types ( $ this -> before ) ; return $ this -> _save ( ) ; break ; case 'remove' : $ this -> _set_field_types ( 'list' ) ; $ this -> _remove ( ) ; return $ this -> _list ( ) ; break ; case 'upload' : return $ this -> _upload ( ) ; break ; case 'remove_upload' : return $ this -> _remove_upload ( ) ; break ; case 'crop_image' : return $ this -> manual_crop ( ) ; break ; case 'unique' : $ this -> _set_field_types ( 'edit' ) ; return $ this -> _check_unique_value ( ) ; break ; case 'clone' : $ this -> _set_field_types ( 'list' ) ; $ this -> _clone_row ( ) ; return $ this -> _list ( ) ; break ; case 'print' : if ( ! $ this -> is_print ) { return self :: error ( 'Restricted' ) ; } $ this -> _set_field_types ( 'list' , Fruit_config :: $ print_all_fields ) ; $ this -> theme = 'printout' ; return $ this -> _list ( ) ; break ; case 'depend' : return $ this -> create_relation ( $ this -> _post ( 'name' , false , 'base64' ) , $ this -> _post ( 'value' ) , $ this -> get_field_attr ( $ this -> _post ( 'name' , false , 'base64' ) , 'edit' ) , $ this -> _post ( 'dependval' ) ) ; break ; case 'view' : $ this -> _set_field_types ( 'view' ) ; return $ this -> _entry ( 'view' ) ; break ; case 'query' : break ; case 'external' : break ; case 'action' : return $ this -> _call_action ( ) ; break ; case 'file' : $ this -> _set_field_types ( 'list' ) ; return $ this -> _render_file ( ) ; break ; case 'csv' : $ this -> _set_field_types ( 'list' , Fruit_config :: $ csv_all_fields ) ; return $ this -> _csv ( ) ; break ; case 'list' : default : $ this -> _set_field_types ( 'list' ) ; return $ this -> _list ( ) ; break ; } }
main task trigger
33,525
protected function _create ( $ postdata = array ( ) ) { if ( ! $ this -> is_create || $ this -> table_ro ) return self :: error ( 'Forbidden' ) ; $ this -> primary_val = null ; $ this -> result_row = array_merge ( $ this -> defaults , $ postdata ) ; if ( $ this -> before_create ) { $ path = $ this -> check_file ( $ this -> before_create [ 'path' ] , 'before_create' ) ; include_once ( $ path ) ; if ( is_callable ( $ this -> before_create [ 'callable' ] ) ) { $ postdata = new Fruit_postdata ( $ this -> result_row , $ this ) ; call_user_func_array ( $ this -> before_create [ 'callable' ] , array ( $ postdata , $ this ) ) ; $ this -> result_row = $ postdata -> to_array ( ) ; } } $ this -> _set_field_names ( ) ; if ( $ this -> condition ) { foreach ( $ this -> condition as $ params ) { if ( ! isset ( $ params [ 'mode' ] [ 'create' ] ) ) continue ; $ params [ 'value' ] = $ this -> replace_text_variables ( $ params [ 'value' ] , $ this -> result_row ) ; if ( array_key_exists ( $ params [ 'field' ] , $ this -> result_row ) && $ this -> _compare ( $ this -> result_row [ $ params [ 'field' ] ] , $ params [ 'operator' ] , $ params [ 'value' ] ) ) { if ( is_array ( $ params [ 'method' ] ) && is_callable ( $ params [ 'method' ] ) ) { call_user_func_array ( $ params [ 'method' ] , $ params [ 'params' ] ) ; } elseif ( is_callable ( array ( $ this , $ params [ 'method' ] ) ) ) { $ this -> condition_backup ( $ params [ 'method' ] ) ; call_user_func_array ( array ( $ this , $ params [ 'method' ] ) , $ params [ 'params' ] ) ; } elseif ( is_callable ( $ params [ 'method' ] ) ) { call_user_func_array ( $ params [ 'method' ] , $ params [ 'params' ] ) ; } } } } return $ this -> _render_details ( 'create' ) ; }
creates fieldlist for adding record
33,526
protected function where_pri ( $ fields = false , $ where_val = false , $ glue = 'AND' , $ index = false ) { if ( $ fields !== false && $ where_val !== false ) { $ fdata = $ this -> _parse_field_names ( $ fields , 'where_pri' ) ; foreach ( $ fdata as $ fitem ) { if ( $ index ) { $ this -> where_pri [ $ index ] = array ( 'table' => $ fitem [ 'table' ] , 'field' => $ fitem [ 'field' ] , 'value' => isset ( $ fitem [ 'value' ] ) ? $ fitem [ 'value' ] : $ where_val , 'glue' => $ glue ) ; } else { $ this -> where_pri [ ] = array ( 'table' => $ fitem [ 'table' ] , 'field' => $ fitem [ 'field' ] , 'value' => isset ( $ fitem [ 'value' ] ) ? $ fitem [ 'value' ] : $ where_val , 'glue' => $ glue ) ; } } unset ( $ fields , $ fdata ) ; } elseif ( $ fields ) { if ( $ index ) { $ this -> where_pri [ $ index ] = array ( 'custom' => $ fields , 'glue' => $ glue ) ; } else { $ this -> where_pri [ ] = array ( 'custom' => $ fields , 'glue' => $ glue ) ; } unset ( $ where_val ) ; } return $ this ; }
defines primary condition for internal usage
33,527
protected function subselect_query ( $ name ) { if ( isset ( $ this -> subselect_query [ $ name ] ) ) { $ sql = $ this -> subselect_query [ $ name ] ; } else { $ sql = preg_replace_callback ( '/\{(.+)\}/Uu' , array ( $ this , 'subselect_callback' ) , $ this -> subselect [ $ name ] ) ; $ this -> subselect_query [ $ name ] = $ sql ; } return "({$sql}) AS `{$name}`" ; }
creates subselect subquery for grid view
33,528
protected function _receive_post ( $ task = false , $ primary = false ) { if ( ! $ this -> table_name && ! $ this -> query ) $ this -> table_name = $ this -> _humanize ( mb_substr ( $ this -> table , mb_strlen ( $ this -> prefix ) ) ) ; if ( $ task ) { switch ( $ task ) { case 'create' : $ this -> task = $ task ; $ this -> before = $ task ; return ; break ; case 'edit' : case 'view' : if ( $ primary !== false ) { $ this -> task = $ task ; $ this -> before = $ task ; $ this -> primary_val = $ primary ; return ; } break ; case 'list' : $ this -> task = $ task ; return ; break ; } } else { $ this -> task = $ this -> _post ( 'task' , 'list' ) ; } if ( $ this -> is_get ) { $ this -> task = $ this -> _get ( 'task' ) ; $ this -> primary_val = $ this -> _get ( 'primary' ) ; } else { $ this -> order_column = $ this -> _post ( 'orderby' , false , 'key' ) ; $ this -> order_direct = $ this -> _post ( 'order' ) == 'desc' ? 'desc' : 'asc' ; if ( $ this -> order_column ) { if ( ! $ this -> query ) $ this -> order_column = key ( $ this -> _parse_field_names ( $ this -> order_column , 'receive_post' , false , false ) ) ; if ( isset ( $ this -> order_by [ $ this -> order_column ] ) ) unset ( $ this -> order_by [ $ this -> order_column ] ) ; $ this -> order_by = array_merge ( array ( $ this -> order_column => $ this -> order_direct ) , $ this -> order_by ) ; } $ this -> search = $ this -> _post ( 'search' , $ this -> search , 'int' ) ; if ( $ this -> search ) { $ this -> column = $ this -> _post ( 'column' , false , 'key' ) ; $ this -> phrase = $ this -> _post ( 'phrase' ) ; $ this -> range = $ this -> _post ( 'range' , '' ) ; } $ this -> start = $ this -> _post ( 'start' , 0 , 'int' ) ; $ this -> limit = $ this -> _post ( 'limit' , ( $ this -> limit ? $ this -> limit : Fruit_config :: $ limit ) ) ; $ this -> after = $ this -> _post ( 'after' ) ; $ this -> primary_val = $ this -> _post ( 'primary' ) ; } }
receiving user data
33,529
protected function _get_table_info ( ) { $ this -> table_info = array ( ) ; $ db = Fruit_db :: get_instance ( $ this -> connection ) ; $ db -> query ( "SHOW COLUMNS FROM `{$this->table}`" ) ; $ this -> table_info [ $ this -> table ] = $ db -> result ( ) ; if ( $ this -> join ) { foreach ( $ this -> join as $ alias => $ join ) { $ db -> query ( "SHOW COLUMNS FROM `{$join['join_table']}`" ) ; $ this -> table_info [ $ alias ] = $ db -> result ( ) ; } } return true ; }
informatiuon about table columns
33,530
public function inner_where ( $ value = false ) { if ( $ value !== false ) { $ this -> inner_value = $ value ; } if ( $ this -> is_inner && $ this -> inner_where ) { $ field = reset ( $ this -> inner_where ) ; $ this -> where_pri ( $ field , $ this -> inner_value , 'AND' , 'nstd_tbl' ) ; $ this -> pass_default ( $ field , $ this -> inner_value ) ; } }
defines nested main condition must be public . Only for internal usage .
33,531
protected function get_table_tooltip ( ) { $ out = '' ; if ( $ this -> table_tooltip ) { $ out .= ' ' ; $ out .= $ this -> open_tag ( array ( 'tag' => 'a' , 'href' => 'javascript:;' , 'class' => 'fruit-tooltip fruit-button-link' , 'title' => $ this -> table_tooltip [ 'tooltip' ] ) ) ; $ out .= $ this -> open_tag ( array ( 'tag' => 'i' , 'class' => ( $ this -> table_tooltip [ 'icon' ] ? $ this -> table_tooltip [ 'icon' ] : $ this -> theme_config ( 'tooltip_icon' ) ) ) ) ; $ out .= $ this -> close_tag ( 'i' ) ; $ out .= $ this -> close_tag ( 'a' ) ; } return $ out ; }
table tooltip render
33,532
protected function get_field_tooltip ( $ field , $ mode ) { $ out = '' ; if ( $ this -> field_tooltip && isset ( $ this -> field_tooltip [ $ field ] ) ) { $ out .= ' ' ; $ out .= $ this -> open_tag ( array ( 'tag' => 'a' , 'href' => 'javascript:;' , 'class' => 'fruit-tooltip fruit-button-link' , 'title' => $ this -> field_tooltip [ $ field ] [ 'tooltip' ] ) ) ; $ out .= $ this -> open_tag ( array ( 'tag' => 'i' , 'class' => ( $ this -> field_tooltip [ $ field ] [ 'icon' ] ? $ this -> field_tooltip [ $ field ] [ 'icon' ] : $ this -> theme_config ( 'tooltip_icon' ) ) ) ) ; $ out .= $ this -> close_tag ( 'i' ) ; $ out .= $ this -> close_tag ( 'a' ) ; } return $ out ; }
field tooltip render
33,533
protected function get_column_tooltip ( $ field ) { $ out = '' ; if ( $ this -> column_tooltip && isset ( $ this -> column_tooltip [ $ field ] ) ) { $ out .= ' ' ; $ out .= $ this -> open_tag ( array ( 'tag' => 'a' , 'href' => 'javascript:;' , 'class' => 'fruit-tooltip fruit-button-link' , 'title' => $ this -> column_tooltip [ $ field ] [ 'tooltip' ] ) ) ; $ out .= $ this -> open_tag ( array ( 'tag' => 'i' , 'class' => ( $ this -> column_tooltip [ $ field ] [ 'icon' ] ? $ this -> column_tooltip [ $ field ] [ 'icon' ] : $ this -> theme_config ( 'tooltip_icon' ) ) ) ) ; $ out .= $ this -> close_tag ( 'i' ) ; $ out .= $ this -> close_tag ( 'a' ) ; } return $ out ; }
column tooltip render
33,534
protected function render_button ( $ name = '' , $ task = '' , $ after = '' , $ class = '' , $ icon = '' , $ mode = '' , $ primary = '' ) { $ out = '' ; if ( isset ( $ this -> { 'is_' . $ after } ) && ! $ this -> { 'is_' . $ after } ) { return $ out ; } if ( isset ( $ this -> { 'is_' . $ task } ) && ! $ this -> { 'is_' . $ task } ) { return $ out ; } if ( ! isset ( $ this -> hide_button [ $ name ] ) ) { if ( $ mode ) { $ mode = $ this -> parse_comma_separated ( $ mode ) ; if ( ! in_array ( $ this -> task , $ mode ) ) { return $ out ; } } $ tag = array ( 'tag' => 'a' , 'href' => 'javascript:;' , 'data-task' => $ task ) ; if ( $ after ) { $ tag [ 'data-after' ] = $ after ; } if ( $ class ) { $ tag [ 'class' ] = $ class ; } if ( $ primary ) { $ tag [ 'data-primary' ] = $ primary ; } elseif ( $ this -> primary_val ) { $ tag [ 'data-primary' ] = $ this -> primary_val ; } $ out .= $ this -> open_tag ( $ tag , 'fruit-action' ) ; if ( $ icon && ! $ this -> is_rtl ) { $ out .= $ this -> open_tag ( array ( 'tag' => 'i' , 'class' => $ icon ) ) . $ this -> close_tag ( 'i' ) . ' ' ; } $ out .= $ this -> lang ( $ name ) ; if ( $ icon && $ this -> is_rtl ) { $ out .= ' ' . $ this -> open_tag ( array ( 'tag' => 'i' , 'class' => $ icon ) ) . $ this -> close_tag ( 'i' ) ; } $ out .= $ this -> close_tag ( $ tag ) ; } return $ out ; }
renders action button for details view
33,535
protected function formatUrl ( $ scope , $ name , $ opts , $ truncateKey = true ) { $ url = Config :: getInstance ( ) -> api_base . $ scope . '/' . $ name . '.xml.aspx' ; if ( $ truncateKey && count ( $ opts ) ) { if ( isset ( $ opts [ 'apikey' ] ) ) { $ opts [ 'apikey' ] = substr ( $ opts [ 'apikey' ] , 0 , 16 ) . '...' ; } if ( isset ( $ opts [ 'vCode' ] ) ) { $ opts [ 'vCode' ] = substr ( $ opts [ 'vCode' ] , 0 , 16 ) . '...' ; } } if ( Config :: getInstance ( ) -> http_post ) { $ url .= ' DATA: ' . http_build_query ( $ opts , '' , '&' ) ; } elseif ( count ( $ opts ) ) { $ url .= '?' . http_build_query ( $ opts , '' , '&' ) ; } return $ url ; }
returns formatted url for logging
33,536
public function getMainPrefixAndPath ( Dir $ rootDir ) { $ prefixesPaths = $ this -> getPrefixes ( ) ; $ prefixes = array_keys ( $ prefixesPaths ) ; if ( count ( $ prefixes ) > 0 ) { $ firstPrefixPaths = array_shift ( $ prefixesPaths ) ; $ path = array_shift ( $ firstPrefixPaths ) ; $ dir = $ path instanceof Dir ? $ path : $ rootDir -> sub ( $ path ) ; return array ( array_shift ( $ prefixes ) , $ dir ) ; } throw new NoAutoLoadPrefixException ( 'Cannot retrieve the main Prefix and Library Path from AutoLoadInfo. AutoLoadInfo is defined: ' . print_r ( $ prefixesPaths , true ) . "\nPlease insert autoload informations into your composer.json" ) ; }
Returns the first to find prefix and path in autoloadInfo
33,537
public function boot ( ) { foreach ( $ this -> getFiles ( ) as $ filename ) { $ path = $ this -> path . '/' . $ filename ; if ( file_exists ( $ path ) ) { require $ path ; } ; } }
Boot the theme .
33,538
public function toArray ( ) { return [ 'name' => $ this -> name , 'description' => $ this -> description , 'author' => $ this -> author , 'enabled' => $ this -> enabled , 'path' => $ this -> path , 'files' => $ this -> files , ] ; }
Convert theme instance to array .
33,539
public function config ( $ key , $ default = null ) { $ parts = explode ( '.' , $ key ) ; $ filename = head ( $ parts ) ; $ parts = array_slice ( $ parts , 0 ) ; $ path = $ this -> path . "/config/config.php" ; if ( ! file_exists ( $ path ) ) { $ path = $ this -> path . "/config/{$filename}.php" ; } $ key = implode ( '.' , $ parts ) ; $ config = file_exists ( $ path ) ? require $ path : [ ] ; return array_get ( $ config , $ key , $ default ) ; }
Get theme s config value .
33,540
public function send ( MessageInterface $ message , $ skipErrors = true ) { $ mobitex = $ this -> getClient ( ) ; foreach ( $ message -> getRecipient ( ) as $ recipient ) { try { $ mobitex -> sendMessage ( $ recipient , $ message -> getText ( ) ) ; } catch ( Exception $ e ) { $ this -> addError ( new SendingError ( $ recipient , $ e -> getCode ( ) , $ e -> getMessage ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } } } return $ this -> getErrors ( ) -> count ( ) === 0 ; }
Send message through SmsCenter . pl gateway
33,541
public function qos ( $ size , $ count ) { try { $ this -> channel -> basic_qos ( $ size , $ count , false ) ; } catch ( Exception $ e ) { return false ; } return true ; }
Set the Quality Of Service settings for the given channel .
33,542
public function createDocBlock ( $ body = NULL ) { $ block = new DocBlock ( $ body ) ; $ this -> setDocBlock ( $ block ) ; return $ block ; }
Creates a new DocBlock for the class
33,543
public function addObject ( $ object , $ cdata = false , $ key = false ) { if ( ! is_object ( $ object ) && ! is_array ( $ object ) ) { return ; } if ( $ key && Conversion :: validateNodeName ( $ key ) ) { $ key = $ this -> dom -> createElement ( $ key ) ; $ conversion = new Conversion ( $ object ) ; $ conversion -> objectToDomElement ( $ object , $ key , $ this -> dom ) ; } else { $ conversion = new Conversion ( $ object ) ; $ conversion -> objectToDomElement ( $ object , $ this -> page , $ this -> dom ) ; } }
Adds an object to XML tree .
33,544
public function parse ( $ asxml = false ) { $ xml = new stdClass ( ) ; if ( isset ( $ _SESSION [ 'messages' ] ) && ! empty ( $ _SESSION [ 'messages' ] ) ) { $ xml -> messages = $ _SESSION [ 'messages' ] ; unset ( $ _SESSION [ 'messages' ] ) ; } foreach ( $ this -> requisites as $ k => $ v ) { if ( is_array ( $ v ) ) { $ v = array_unique ( $ v ) ; } $ xml -> { $ k } = $ v ; } foreach ( $ this -> properties as $ k => $ v ) { if ( ! empty ( $ v ) ) { $ xml -> $ k = $ v ; } } $ this -> addObject ( $ xml , false , 'common' ) ; $ module = $ this -> dom -> createElement ( 'module' ) ; $ module -> appendChild ( $ this -> page ) ; $ this -> dom -> firstChild -> appendChild ( $ module ) ; if ( error_reporting ( ) === E_ALL ) { Debug :: __print ( htmlspecialchars ( $ this -> toString ( ) ) ) ; } try { $ retval = $ this -> asxml ? $ this -> toString ( ) : $ this -> xsl -> parse ( $ this -> dom ) ; } catch ( Exception $ e ) { Debug :: __print ( $ e -> getMessage ( ) ) ; $ retval = false ; } return $ retval ; }
Adds common XML data and returns XSL parser output .
33,545
public function detectMainTemplate ( ) { $ name = ( isset ( $ this -> mainxsl ) && ! empty ( $ this -> mainxsl ) ) ? $ this -> mainxsl : 'index' ; foreach ( $ this -> getIncludePaths ( ) as $ path ) { if ( is_readable ( $ path . DIRECTORY_SEPARATOR . $ name . '.xsl' ) ) { $ this -> xsl -> includeXSL ( $ path . DIRECTORY_SEPARATOR . $ name . '.xsl' , true ) ; return $ path . DIRECTORY_SEPARATOR . $ name . '.xsl' ; } } }
Detects path and file of main XSL file .
33,546
public function addTemplate ( $ name = false ) { if ( in_array ( $ name , $ this -> ignoreTemplates ) ) { return false ; } $ name .= '.xsl' ; foreach ( $ this -> paths as $ path ) { if ( is_readable ( $ path . DIRECTORY_SEPARATOR . $ name ) ) { $ this -> xsl -> includeXSL ( $ path . DIRECTORY_SEPARATOR . $ name ) ; return ; } } }
Add XSL - file to parser .
33,547
public function assign ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> data = array_merge ( $ this -> data , $ key ) ; } else { $ this -> data [ $ key ] = $ value ; if ( ! isset ( $ this -> { $ key } ) ) { $ this -> { $ key } = $ this -> data [ $ key ] ; } } }
Assign data to template and controller
33,548
public function setBodyAttributes ( $ layout , $ data = array ( ) ) { $ data = Arr :: merge ( $ data , array ( 'body' => array ( 'attributes' => array ( 'class' => static :: $ tplPrefixClass . str_replace ( array ( '::' , '.' ) , '-' , $ layout ) ) ) ) ) ; $ data = $ this -> getCommonVars ( $ data ) ; view ( ) -> share ( 'body' , $ data [ 'body' ] ) ; return $ data ; }
Set body attributes
33,549
protected function initializeFileLoader ( FileLoader $ fileLoader = null ) { if ( ! isset ( $ this -> fileLoader ) ) { $ this -> setFileLoader ( ( $ fileLoader ) ? $ fileLoader : new FileLoader ( ) ) ; } }
Makes sure a FileLoader object was created or creates one .
33,550
public function loadFiles ( array $ files , $ append = false , $ namespace = true , $ strict = true ) { $ this -> initializeFileLoader ( ) ; $ this -> fileLoader -> addFiles ( $ files ) ; $ data = $ this -> fileLoader -> process ( $ namespace , $ strict ) ; $ this -> hydrate ( $ data , $ append ) ; }
This method adds the file loading functionality .
33,551
public function registerTplEngine ( $ resolver ) { $ app = $ this -> app ; $ resolver -> register ( 'tpl' , function ( ) use ( $ app ) { $ cache = $ app [ 'path.storage' ] . '/views' ; $ compiler = new TplCompiler ( $ app [ 'files' ] , $ cache ) ; return new CompilerEngine ( $ compiler , $ app [ 'files' ] ) ; } ) ; }
Register the Tpl engine implementation .
33,552
protected function registerSessionBinder ( ) { list ( $ app , $ me ) = array ( $ this -> app , $ this ) ; $ app -> booted ( function ( ) use ( $ app , $ me ) { if ( $ me -> sessionHasErrors ( $ app ) ) { $ errors = $ app [ 'session.store' ] -> get ( 'errors' ) ; $ app [ 'view' ] -> share ( 'errors' , $ errors ) ; } else { $ app [ 'view' ] -> share ( 'errors' , new ViewErrorBag ) ; } } ) ; }
Register the session binder for the view environment .
33,553
public function sessionHasErrors ( $ app ) { $ config = $ app [ 'config' ] [ 'session' ] ; if ( isset ( $ app [ 'session.store' ] ) && ! is_null ( $ config [ 'driver' ] ) ) { return $ app [ 'session.store' ] -> has ( 'errors' ) ; } }
Determine if the application session has errors .
33,554
public static function fromAlgorithmIdentifier ( PBEAlgorithmIdentifier $ algo , Crypto $ crypto = null ) : PBEScheme { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; if ( $ algo instanceof PBES1AlgorithmIdentifier ) { return new PBES1 ( $ algo -> hashFunc ( ) , $ algo -> blockCipher ( ) , $ algo -> salt ( ) , $ algo -> iterationCount ( ) , $ crypto ) ; } if ( $ algo instanceof PBES2AlgorithmIdentifier ) { $ prf = PRF :: fromAlgorithmIdentifier ( $ algo -> kdfAlgorithmIdentifier ( ) -> prfAlgorithmIdentifier ( ) ) ; return new PBES2 ( $ prf , $ algo -> esAlgorithmIdentifier ( ) , $ algo -> salt ( ) , $ algo -> iterationCount ( ) , $ crypto ) ; } throw new \ UnexpectedValueException ( sprintf ( "No encryption scheme for %s algorithm." , $ algo -> name ( ) ) ) ; }
Get PBEScheme by algorithm identifier .
33,555
public function toArray ( ) : array { $ result = [ ] ; if ( ! empty ( $ this -> id ) ) { $ result [ 'id' ] = $ this -> id ; } if ( ! empty ( $ this -> link ) ) { $ result [ 'links' ] [ 'about' ] = $ this -> link ; } if ( ! empty ( $ this -> status ) ) { $ result [ 'status' ] = "{$this->status}" ; } if ( ! empty ( $ this -> code ) ) { $ result [ 'code' ] = "{$this->code}" ; } if ( ! empty ( $ this -> title ) ) { $ result [ 'title' ] = $ this -> title ; } if ( ! empty ( $ this -> detail ) ) { $ result [ 'detail' ] = $ this -> detail ; } if ( ! empty ( $ this -> source ) ) { $ result [ 'source' ] = $ this -> source -> map ( function ( $ item ) { return $ item ; } ) ; } if ( ! empty ( $ this -> meta ) ) { $ result [ 'meta' ] = $ this -> meta ; } if ( ! empty ( $ this -> exception ) ) { $ e = $ this -> exception ; if ( $ e instanceof ExtendedLoggingInformation ) { $ result [ 'exception' ] = $ e -> context ( ) ; } else { $ result [ 'exception' ] = [ 'exception' => get_class ( $ e ) , 'message' => $ e -> getMessage ( ) , 'stacktrace' => $ e -> getTrace ( ) , ] ; } } return $ result ; }
returns the JSON Api Error object as array
33,556
public function hook ( $ data , $ params = array ( ) ) { $ aDefParams = array ( 'function' => 'array_merge_recursive' ) ; $ params = array_merge_recursive ( $ aDefParams , $ params ) ; if ( is_array ( $ this -> _data -> __var ) ) { $ this -> _data -> __var = call_user_func ( $ params [ 'function' ] , $ this -> _data -> __var , $ data ) ; } return $ this -> _data -> __var ; }
Get the compiler implementation .
33,557
public function connect ( ) { $ this -> conn = imap_open ( $ this -> server , $ this -> user , $ this -> pass ) ; }
Open the imap connection
33,558
public function fetch ( $ index = null , $ params = array ( 'index' => true , 'overview' => true , 'structure' => true , 'header' => true , 'body' => true , 'plain' => true , 'attachments' => true , ) ) { $ params = Arr :: mergeWithDefaultParams ( $ params ) ; $ this -> attachments = [ ] ; if ( ! $ index ) { $ index = 1 ; } $ this -> messageNumber = $ index ; $ structure = @ imap_fetchstructure ( $ this -> conn , $ index ) ; if ( ! $ structure ) { return false ; } else { $ data = [ ] ; if ( $ params [ 'index' ] ) { $ data [ 'index' ] = $ index ; } if ( $ params [ 'overview' ] ) { $ data [ 'overview' ] = @ imap_fetch_overview ( $ this -> conn , $ index ) ; } if ( $ params [ 'structure' ] ) { $ data [ 'structure' ] = $ structure ; } if ( $ params [ 'header' ] ) { $ data [ 'header' ] = @ imap_header ( $ this -> conn , $ index ) ; } if ( $ params [ 'body' ] ) { $ this -> bodyHTML = $ data [ 'body' ] = @ imap_body ( $ this -> conn , $ index ) ; } if ( $ params [ 'plain' ] ) { $ data [ 'plain' ] = @ imap_fetchbody ( $ this -> conn , $ index , 1.2 ) ; } if ( $ params [ 'attachments' ] ) { $ this -> recurse ( $ structure -> parts ) ; $ data [ 'attachments' ] = $ this -> attachments ; } return $ data ; } }
Fetch structure by index
33,559
public function getCount ( $ folder = null ) { if ( $ folder ) { $ conn = $ this -> getFolder ( $ folder ) ; } else { $ conn = $ this -> conn ; } return imap_num_msg ( $ conn ) ; }
Get Count of a folder
33,560
public function getFolder ( $ folder = '' ) { $ conn = substr ( $ this -> server , 0 , strpos ( $ this -> server , '}' ) + 1 ) . $ folder ; return $ conn ; }
Get folder conn
33,561
public function getFilenameFromPart ( $ part ) { $ filename = '' ; if ( $ part -> ifdparameters ) { foreach ( $ part -> dparameters as $ object ) { if ( strtolower ( $ object -> attribute ) == 'filename' ) { $ filename = $ object -> value ; } } } if ( ! $ filename && $ part -> ifparameters ) { foreach ( $ part -> parameters as $ object ) { if ( strtolower ( $ object -> attribute ) == 'name' ) { $ filename = $ object -> value ; } } } return $ filename ; }
Get The filename from part
33,562
public function move ( $ msg_index , $ folder = 'INBOX.Processed' ) { imap_mail_move ( $ this -> conn , $ msg_index , $ folder ) ; imap_expunge ( $ this -> conn ) ; $ this -> inbox ( $ this -> msg_cnt ) ; }
Move mail to folder
33,563
public function recurse ( $ messageParts , $ prefix = '' , $ index = 1 , $ fullPrefix = true ) { foreach ( $ messageParts as $ part ) { $ partNumber = $ prefix . $ index ; if ( $ part -> type == 0 ) { if ( $ part -> subtype == 'PLAIN' ) { $ this -> bodyPlain .= $ this -> getPart ( $ partNumber , $ part -> encoding ) ; } else { $ this -> bodyHTML .= $ this -> getPart ( $ partNumber , $ part -> encoding ) ; } } elseif ( $ part -> type == 2 ) { $ msg = new self ( $ this -> conn , $ this -> messageNumber ) ; $ msg -> getAttachments = $ this -> getAttachments ; $ msg -> recurse ( $ part -> parts , $ partNumber . '.' , 0 , false ) ; $ this -> attachments [ ] = array ( 'type' => $ part -> type , 'subtype' => $ part -> subtype , 'filename' => '' , 'data' => $ msg , 'inline' => false , ) ; } elseif ( isset ( $ part -> parts ) ) { if ( $ fullPrefix ) { $ this -> recurse ( $ part -> parts , $ prefix . $ index . '.' ) ; } else { $ this -> recurse ( $ part -> parts , $ prefix ) ; } } elseif ( $ part -> type > 2 ) { if ( isset ( $ part -> id ) ) { $ id = str_replace ( array ( '<' , '>' ) , '' , $ part -> id ) ; $ this -> attachments [ $ id ] = array ( 'type' => $ part -> type , 'subtype' => $ part -> subtype , 'filename' => $ this -> getFilenameFromPart ( $ part ) , 'data' => $ this -> getAttachments ? $ this -> getPart ( $ partNumber , $ part -> encoding ) : '' , 'inline' => true , ) ; } else { $ this -> attachments [ ] = array ( 'type' => $ part -> type , 'subtype' => $ part -> subtype , 'filename' => $ this -> getFilenameFromPart ( $ part ) , 'data' => $ this -> getAttachments ? $ this -> getPart ( $ partNumber , $ part -> encoding ) : '' , 'inline' => false , ) ; } } $ index ++ ; } return $ this -> attachments ; }
Recursive function to get message parts
33,564
public function addHost ( $ host ) { if ( ! isset ( $ this -> hosts [ $ host ] ) ) { $ this -> hosts [ $ host ] = $ host ; } return $ this ; }
Adding a host to the list .
33,565
public function removeHost ( $ host ) { if ( isset ( $ this -> hosts [ $ host ] ) ) { unset ( $ this -> hosts [ $ host ] ) ; } return $ this ; }
Removing a host from the list .
33,566
public function isAvailable ( $ domain ) { $ domaincdNode = $ this -> getDomaincd ( $ domain ) ; $ node = $ this -> getFirst ( 'domain:name' , $ domaincdNode ) ; return in_array ( $ node -> getAttribute ( 'avail' ) , [ '1' , 'true' ] ) ; }
Domain is available for creating .
33,567
public function getReason ( $ domain ) { $ domaincdNode = $ this -> getDomaincd ( $ domain ) ; $ node = $ this -> getFirst ( 'domain:reason' , $ domaincdNode ) ; return $ node === null ? null : $ node -> nodeValue ; }
The reason why a domain is not available for creation .
33,568
public static function objectToArray ( $ OBJ ) { if ( is_object ( $ OBJ ) ) { $ OBJ = get_object_vars ( $ OBJ ) ; } if ( is_array ( $ OBJ ) ) { return array_map ( [ get_called_class ( ) , __FUNCTION__ ] , $ OBJ ) ; } return $ OBJ ; }
inline recursive function calling is so stupid is so stupid is so stupid is so stupid ...
33,569
protected function getMail ( $ toEmail , $ toName , $ subject , $ view , array $ data = array ( ) , $ options = null ) { return $ this -> mail -> compose ( $ toEmail , $ toName , $ subject , $ view , $ data , $ options ) ; }
Compose an e - mail .
33,570
public function renderAjaxBlock ( \ Twig_Environment $ environment , $ controllerName , array $ controllerParams = array ( ) , array $ options = array ( ) ) { $ routeParams = array ( '_ajaxController' => $ controllerName ) + $ controllerParams ; $ controllerParams [ AjaxBlockControllerEventListener :: JGP_AJAX_BLOCK_TAG ] = true ; $ options = array_merge ( $ this -> defaultOptions , $ options ) ; $ variables = array ( 'controllerName' => $ controllerName , 'controllerParams' => $ controllerParams , 'routeName' => 'jgp_ajax_block' , 'routeParams' => $ routeParams , 'autoload' => isset ( $ options [ 'autoload' ] ) && $ options [ 'autoload' ] , ) ; $ template = 'AjaxBlocksBundle::ajax_block.html.twig' ; return $ environment -> render ( $ template , $ variables ) ; }
Renders the ajax block
33,571
public function send ( MessageInterface $ message , $ skipErrors = true ) { $ smsapi = new SmsFactory ( ) ; $ smsapi -> setClient ( $ this -> getClient ( ) ) ; $ actionSend = $ smsapi -> actionSend ( ) ; $ sender = $ this -> getParam ( 'sender' ) ; if ( empty ( $ sender ) ) { throw new ConfigurationException ( __CLASS__ . ' is not configured properly. Please set "sender" parameter properly.' ) ; } $ actionSend -> setSender ( $ sender ) ; $ actionSend -> setText ( $ message -> getText ( ) ) ; foreach ( $ message -> getRecipient ( ) as $ recipient ) { try { $ actionSend -> setTo ( $ recipient ) ; $ response = $ actionSend -> execute ( ) ; foreach ( $ response -> getList ( ) as $ status ) { if ( in_array ( $ status -> getStatus ( ) , [ 407 , 406 , 405 , 401 , 402 ] ) ) { $ this -> addError ( new SendingError ( $ status -> getNumber ( ) , $ status -> getStatus ( ) , $ status -> getError ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ status -> getError ( ) , $ status -> getStatus ( ) ) ; } } } } catch ( SmsapiException $ e ) { $ this -> addError ( new SendingError ( $ recipient , $ e -> getCode ( ) , $ e -> getMessage ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , true ) ; } } } return $ this -> getErrors ( ) -> count ( ) === 0 ; }
Send message through SmsApi . pl gateway
33,572
public static function fromRequest ( $ request = null ) { $ request = $ request ? : app ( 'request' ) ; $ data = $ request -> json ( ) ; $ dataContainer = $ data -> get ( 'data' , [ ] ) ; if ( array_has ( $ dataContainer , '0' ) ) { return RequestModelCollection :: fromDataContainer ( $ dataContainer , $ request ) ; } return ( new static ( $ request ) ) -> data ( $ data -> all ( ) ) ; }
creates instance from request
33,573
public function defineRelation ( string $ resource , \ Closure $ closure , string $ description = null ) { $ this -> relations -> push ( new ResourceDefinition ( $ this -> version , $ resource , $ description ) ) ; $ resourceDefinition = $ this -> relation ( $ resource , $ this -> version ) ; call_user_func_array ( $ closure , [ $ resourceDefinition ] ) ; return $ this ; }
defines a relation
33,574
public function relation ( string $ resource , int $ version = null ) : ResourceDefinition { $ version = $ version ?? $ this -> version ; $ found = $ this -> relations -> filter ( function ( ResourceDefinition $ definition ) use ( $ resource , $ version ) { return $ definition -> version === $ version && $ definition -> resource === $ resource ; } ) ; if ( $ found -> isEmpty ( ) ) { throw ResourceNotDefinedException :: resource ( $ resource , 'version ' . $ version ) ; } return $ found -> first ( ) ; }
returns relation by resource and version
33,575
public function ensureDefaultFormat ( $ file ) { if ( ! pathinfo ( $ file , PATHINFO_EXTENSION ) ) { $ file .= '.' . $ this -> defaultFormat ; } return empty ( $ this -> configFolder ) ? $ file : $ this -> configFolder . DIRECTORY_SEPARATOR . $ file ; }
Ensures a default config format
33,576
public function setEnvironment ( $ environment ) { if ( $ environment ) { $ environment = trim ( $ environment , DIRECTORY_SEPARATOR ) ; } $ this -> environment = $ environment ; }
Sets the environment
33,577
public function reload ( $ name , $ group = true ) { if ( $ group === true ) { $ group = pathinfo ( $ name , PATHINFO_FILENAME ) ; } $ this -> delete ( $ group ) ; return $ this -> load ( $ name , $ group ) ; }
Reloads a group
33,578
public function load ( $ name , $ group = null ) { if ( $ group === true ) { $ group = pathinfo ( $ name , PATHINFO_FILENAME ) ; } if ( $ group and $ cached = $ this -> get ( $ group ) ) { return $ cached ; } $ name = $ this -> ensureDefaultFormat ( $ name ) ; $ paths = $ this -> finder -> findAllFiles ( $ name ) ; if ( empty ( $ paths ) ) { return false ; } $ config = array ( ) ; foreach ( $ paths as $ path ) { $ extension = pathinfo ( $ path , PATHINFO_EXTENSION ) ; $ handler = $ this -> getHandler ( $ extension ) ; $ config = Arr :: merge ( $ config , $ handler -> load ( $ path ) ) ; } if ( $ group ) { $ this -> set ( $ group , $ config ) ; } elseif ( $ group === null ) { $ this -> merge ( $ config ) ; } return $ config ; }
Loads a config file
33,579
public function save ( $ group , $ destination = null ) { if ( $ destination === null ) { $ destination = $ group ; } if ( ! $ this -> has ( $ group ) ) { throw new \ RuntimeException ( 'Unable to save non-existig config group: ' . $ group ) ; } $ destination = $ this -> ensureDefaultFormat ( $ destination ) ; $ format = pathinfo ( $ destination , PATHINFO_EXTENSION ) ; $ handler = $ this -> getHandler ( $ format ) ; $ data = $ this -> get ( $ group ) ; $ output = $ handler -> format ( $ data ) ; $ path = $ this -> findDestination ( $ destination ) ; if ( ! $ path ) { throw new \ RuntimeException ( sprintf ( 'Could not save group "%" as "%s".' , $ group , $ destination ) ) ; } return file_put_contents ( $ path , $ output ) ; }
Stores a config file
33,580
public function findDestination ( $ destination ) { if ( is_file ( $ destination ) ) { return $ destination ; } if ( $ location = $ this -> finder -> findFileReversed ( $ destination ) ) { return $ location ; } $ paths = $ this -> finder -> getPaths ( ) ; if ( empty ( $ paths ) ) { return false ; } $ last = end ( $ paths ) ; return $ last . ltrim ( $ destination , DIRECTORY_SEPARATOR ) ; }
Finds a config file
33,581
public function getHandler ( $ extension ) { if ( isset ( $ this -> handlers [ $ extension ] ) ) { return $ this -> handlers [ $ extension ] ; } $ class = 'Fuel\Config\Handler\\' . ucfirst ( $ extension ) ; if ( ! class_exists ( $ class , true ) ) { throw new \ RuntimeException ( 'Could not find config handler for extension: ' . $ extension ) ; } $ handler = new $ class ; $ this -> handlers [ $ extension ] = $ handler ; return $ handler ; }
Retrieves the handler for a file type
33,582
public static function macro ( $ name , $ macro ) { $ html = self :: getInstance ( ) -> html ; $ args = func_get_args ( ) ; call_user_func_array ( array ( $ html , __FUNCTION__ ) , $ args ) ; }
Register a custom HTML macro .
33,583
public static function linkRoute ( $ name , $ title = null , $ parameters = array ( ) , $ attributes = array ( ) ) { $ html = self :: getInstance ( ) -> html ; $ args = func_get_args ( ) ; return call_user_func_array ( array ( $ html , __FUNCTION__ ) , $ args ) ; }
Generate a HTML link to a named route .
33,584
public static function email ( $ email ) { $ html = self :: getInstance ( ) -> html ; $ args = func_get_args ( ) ; return call_user_func_array ( array ( $ html , __FUNCTION__ ) , $ args ) ; }
Obfuscate an e - mail address to prevent spam - bots from sniffing it .
33,585
public static function ol ( $ list , $ attributes = array ( ) ) { $ html = self :: getInstance ( ) -> html ; $ args = func_get_args ( ) ; return call_user_func_array ( array ( $ html , __FUNCTION__ ) , $ args ) ; }
Generate an ordered list of items .
33,586
public static function obfuscate ( $ value ) { $ html = self :: getInstance ( ) -> html ; $ args = func_get_args ( ) ; return call_user_func_array ( array ( $ html , __FUNCTION__ ) , $ args ) ; }
Obfuscate a string to prevent spam - bots from sniffing it .
33,587
public function getMediaType ( $ mimetype ) { foreach ( $ this -> mediaTypes as $ type => $ mimeTypes ) { if ( in_array ( $ mimetype , $ mimeTypes ) ) { return $ type ; } } return null ; }
Returns the media type for given mimetype
33,588
public function getMediaModelName ( $ type ) { return isset ( $ this -> modelTypes [ $ type ] ) ? $ this -> modelTypes [ $ type ] : $ this -> getDefaultMediaModelName ( ) ; }
Returns the model class name for given type
33,589
public function build ( $ input ) { $ scaffold = new Scaffold ( $ this -> blueprint -> class , $ input ) ; $ this -> applyInstructions ( $ scaffold , Instruction :: PHASE_PRE_INST ) ; $ this -> makeInstance ( $ scaffold ) ; $ this -> applyInstructions ( $ scaffold , Instruction :: PHASE_POST_INST ) ; $ this -> assignProperties ( $ scaffold ) ; $ this -> applyInstructions ( $ scaffold , Instruction :: PHASE_FINAL ) ; return $ scaffold -> instance ; }
Builds class instance based on input configuration .
33,590
protected function applyInstructions ( Scaffold $ scaffold , $ phase ) { $ instructions = $ this -> blueprint -> getInstructions ( $ phase ) ; foreach ( $ instructions as $ instruction ) { $ instruction -> apply ( $ scaffold ) ; } }
Applies to scaffold all build instructions that have specified build phase .
33,591
protected function makeInstance ( Scaffold $ scaffold ) { $ scaffold -> instance = mp \ instantiate ( $ scaffold -> class , $ scaffold -> constructor_arguments ) ; }
Creates target class instance .
33,592
protected function assignProperties ( Scaffold $ scaffold ) { $ scaffold -> properties = array_merge ( $ scaffold -> input , $ scaffold -> properties ) ; mp \ setValues ( $ scaffold -> instance , $ scaffold -> properties ) ; }
Assigns public properties and properties with setters to target class instance .
33,593
public function run ( ) { if ( ! defined ( 'ABSPATH' ) ) { return ; } require_once ABSPATH . ( defined ( 'WPINC' ) ? WPINC : 'wp-includes' ) . '/plugin.php' ; add_filter ( 'pre_option_active_plugins' , ( $ callback = function ( $ plugins ) use ( & $ callback ) { remove_filter ( 'pre_option_active_plugins' , $ callback ) ; $ this -> loadPlugins ( ) ; return $ plugins ; } ) ) ; $ this -> addActivePluginsFilter ( ) ; add_action ( 'wp_loaded' , function ( ) { $ this -> addAdminFilter ( ) ; } ) ; }
Create a new autolader instance .
33,594
protected function loadPlugins ( ) { if ( ! defined ( 'WP_PLUGIN_DIR' ) || ! defined ( 'WPMU_PLUGIN_DIR' ) || ! is_blog_installed ( ) ) { return ; } $ cache = get_site_option ( 'wordplate_autoloader_plugin_cache' ) ; if ( $ cache !== false && isset ( $ cache [ 'files' ] ) ) { $ cacheFiles = $ cache [ 'files' ] ; foreach ( $ cacheFiles as $ file ) { if ( ! file_exists ( WPMU_PLUGIN_DIR . '/' . $ file ) ) { $ cache = false ; break ; } } } else { $ cache = false ; $ cacheFiles = [ ] ; } require_once ABSPATH . 'wp-admin/includes/plugin.php' ; $ this -> relativePath = UrlGenerator :: getRelativePath ( WP_PLUGIN_DIR . '/' , WPMU_PLUGIN_DIR . '/' ) ; $ this -> autoloadPlugins = get_plugins ( '/' . $ this -> relativePath ) ; $ this -> mustUsePlugins = get_mu_plugins ( ) ; $ this -> plugins = array_diff_key ( $ this -> autoloadPlugins , $ this -> mustUsePlugins ) ; $ this -> files = array_keys ( $ this -> plugins ) ; $ this -> relativeFiles = preg_filter ( '/^/' , $ this -> relativePath , $ this -> files ) ; $ this -> activate = array_diff ( $ this -> files , $ cacheFiles ) ; if ( $ this -> activate ) { $ cache = false ; } if ( $ cache === false ) { update_site_option ( 'wordplate_autoloader_plugin_cache' , [ 'files' => $ this -> files , ] ) ; } $ activated = array_diff ( $ this -> files , $ this -> activate ) ; foreach ( $ activated as $ file ) { include_once WPMU_PLUGIN_DIR . '/' . $ file ; } add_action ( 'after_setup_theme' , function ( ) { $ this -> activatePlugins ( ) ; } ) ; }
Check if plugins changed & load plugins .
33,595
protected function activatePlugins ( ) { if ( $ this -> activate ) { foreach ( $ this -> activate as $ file ) { include_once WPMU_PLUGIN_DIR . '/' . $ file ; do_action ( 'activate_' . $ file ) ; } } }
Activate the plugins .
33,596
protected function addAdminFilter ( ) { if ( ! is_admin ( ) ) { return ; } add_filter ( 'show_advanced_plugins' , function ( bool $ show , string $ type ) : bool { return $ this -> showAdvancedPlugins ( $ show , $ type ) ; } , 0 , 2 ) ; add_filter ( 'plugin_row_meta' , function ( array $ links , string $ file ) : array { return $ this -> pluginRowMeta ( $ links , $ file ) ; } , 10 , 2 ) ; }
Add admin filter hooks .
33,597
protected function addActivePluginsFilter ( ) { add_filter ( 'option_active_plugins' , function ( $ plugins ) { if ( $ this -> isPluginsScreen ( ) ) { return $ plugins ; } if ( empty ( $ plugins ) ) { return $ this -> relativeFiles ; } return array_unique ( array_merge ( $ plugins , $ this -> relativeFiles ) ) ; } ) ; add_filter ( 'pre_update_option_active_plugins' , function ( $ plugins ) { foreach ( $ plugins as $ index => & $ plugin ) { if ( strpos ( $ plugin , $ this -> relativePath ) === 0 ) { unset ( $ plugins [ $ index ] ) ; } } return array_unique ( array_values ( $ plugins ) ) ; } ) ; }
Add filter for active_plugins site option .
33,598
protected function showAdvancedPlugins ( bool $ show , string $ type ) : bool { if ( ! $ this -> isPluginsScreen ( ) || $ type !== 'mustuse' || ! current_user_can ( 'activate_plugins' ) ) { return $ show ; } $ plugins = array_merge ( $ this -> autoloadPlugins , $ this -> mustUsePlugins ) ; $ GLOBALS [ 'plugins' ] [ 'mustuse' ] = array_unique ( $ plugins , SORT_REGULAR ) ; return false ; }
Display autoloaded plugins in must - use plugin list .
33,599
protected function pluginRowMeta ( array $ links , string $ file ) : array { if ( in_array ( $ file , $ this -> files ) ) { $ links [ ] = 'Loaded with <a href="https://wordplate.github.io">WordPlate</a>' ; } return $ links ; }
Add plugin row meta displaying that plugin is loaded with autoloader .