idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
8,000
private function renderHiddenInput ( $ responseName , $ responseId ) { $ pattern = '<input type="hidden" %s%s' ; $ closingBracket = $ this -> getInlineClosingBracket ( ) ; $ attributes = $ this -> createAttributesString ( [ 'name' => $ responseName , 'id' => $ responseId , ] ) ; $ response = sprintf ( $ pattern , $ attributes , $ closingBracket ) ; return $ response ; }
Render hidden input elements for the response
8,001
protected function prepare ( $ match ) { \ ManiaLive \ Utilities \ Logger :: debug ( $ match ) ; $ this -> players = array_fill_keys ( $ match -> players , Services \ PlayerInfo :: PLAYER_STATE_NOT_CONNECTED ) ; $ this -> match = $ match ; $ this -> matchId = $ match -> id ; Label :: EraseAll ( ) ; foreach ( $ match -> players as $ login ) { $ this -> connection -> addGuest ( ( string ) $ login , true ) ; } $ this -> connection -> restartMap ( false , true ) ; $ this -> connection -> executeMulticall ( ) ; $ this -> enableDedicatedEvents ( ServerEvent :: ON_PLAYER_CONNECT | ServerEvent :: ON_PLAYER_DISCONNECT | ServerEvent :: ON_END_MATCH | ServerEvent :: ON_END_ROUND | ServerEvent :: ON_PLAYER_INFO_CHANGED | ServerEvent :: ON_MODE_SCRIPT_CALLBACK | ServerEvent :: ON_MODE_SCRIPT_CALLBACK_ARRAY ) ; \ ManiaLive \ Utilities \ Logger :: debug ( sprintf ( 'Preparing match for %s (%s)' , $ this -> lobby -> login , implode ( ',' , array_keys ( $ this -> players ) ) ) ) ; $ this -> changeState ( self :: WAITING ) ; $ this -> waitingTime = 0 ; $ this -> connection -> setForcedTeams ( true ) ; }
Prepare the server config to host a match Then wait players connection
8,002
protected function end ( ) { \ ManiaLive \ Utilities \ Logger :: debug ( 'end()' ) ; $ this -> showTansfertLabel ( null , - 50 ) ; foreach ( $ this -> storage -> players as $ player ) { try { $ this -> connection -> sendOpenLink ( ( string ) $ player -> login , '#qjoin=' . $ this -> lobby -> backLink , 1 ) ; } catch ( \ DedicatedApi \ Xmlrpc \ Exception $ e ) { } } $ this -> connection -> cleanGuestList ( ) ; $ this -> match = null ; $ this -> matchId = null ; $ this -> matchMakingService -> updateServerCurrentMatchId ( null , $ this -> storage -> serverLogin , $ this -> scriptName , $ this -> titleIdString ) ; $ this -> connection -> setForcedTeams ( false ) ; $ this -> sleep ( ) ; }
Free the match for the lobby
8,003
public function makeUnique ( $ id , $ slug ) { $ repo = $ this -> getRepository ( ) ; $ scope = $ this -> getConfig ( 'scope' ) ; foreach ( [ $ repo -> select ( ) -> where ( $ this -> getConfig ( 'slug' ) , $ slug ) , $ repo -> select ( ) -> where ( $ this -> getConfig ( 'slug' ) , 'like' , $ slug . '%' ) ] as $ i => $ query ) { if ( $ scope ) { $ query -> bindCallback ( $ scope ) ; } if ( $ id ) { $ query -> where ( $ repo -> getPrimaryKey ( ) , '!=' , $ id ) ; } $ count = $ query -> count ( ) ; if ( $ count <= 0 ) { break ; } else if ( $ i ) { return $ slug . '-' . $ count ; } } return $ slug ; }
Validate the slug is unique by querying for other slugs . If the slug is not unique append a count to it .
8,004
public function preSave ( Event $ event , Query $ query , $ id , array & $ data ) { $ config = $ this -> allConfig ( ) ; if ( empty ( $ data ) || empty ( $ data [ $ config [ 'field' ] ] ) || ! empty ( $ data [ $ config [ 'slug' ] ] ) ) { return true ; } else if ( $ query -> getType ( ) === Query :: UPDATE && ! $ config [ 'onUpdate' ] ) { return true ; } $ slug = static :: slugify ( $ data [ $ config [ 'field' ] ] ) ; if ( mb_strlen ( $ slug ) > ( $ config [ 'length' ] - 3 ) ) { $ slug = mb_substr ( $ slug , 0 , ( $ config [ 'length' ] - 3 ) ) ; } if ( $ config [ 'unique' ] ) { $ slug = $ this -> makeUnique ( $ id , $ slug ) ; } $ data [ $ config [ 'slug' ] ] = $ slug ; return true ; }
Before a save occurs generate a unique slug using another field as the base . If no data exists or the base doesn t exist or the slug is already set exit early .
8,005
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof UserQuery ) { return $ criteria ; } $ query = new UserQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new UserQuery object .
8,006
public function filterBySalt ( $ salt = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ salt ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ salt ) ) { $ salt = str_replace ( '*' , '%' , $ salt ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( UserPeer :: SALT , $ salt , $ comparison ) ; }
Filter the query on the salt column
8,007
public function filterByFirstname ( $ firstname = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ firstname ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ firstname ) ) { $ firstname = str_replace ( '*' , '%' , $ firstname ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( UserPeer :: FIRSTNAME , $ firstname , $ comparison ) ; }
Filter the query on the firstname column
8,008
public function filterByLastname ( $ lastname = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ lastname ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ lastname ) ) { $ lastname = str_replace ( '*' , '%' , $ lastname ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( UserPeer :: LASTNAME , $ lastname , $ comparison ) ; }
Filter the query on the lastname column
8,009
public function filterByPhone ( $ phone = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ phone ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ phone ) ) { $ phone = str_replace ( '*' , '%' , $ phone ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( UserPeer :: PHONE , $ phone , $ comparison ) ; }
Filter the query on the phone column
8,010
public function filterByMemo ( $ memo = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ memo ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ memo ) ) { $ memo = str_replace ( '*' , '%' , $ memo ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( UserPeer :: MEMO , $ memo , $ comparison ) ; }
Filter the query on the memo column
8,011
public function filterByActivated ( $ activated = null , $ comparison = null ) { if ( is_string ( $ activated ) ) { $ activated = in_array ( strtolower ( $ activated ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( UserPeer :: ACTIVATED , $ activated , $ comparison ) ; }
Filter the query on the activated column
8,012
public function filterByLastLogin ( $ lastLogin = null , $ comparison = null ) { if ( is_array ( $ lastLogin ) ) { $ useMinMax = false ; if ( isset ( $ lastLogin [ 'min' ] ) ) { $ this -> addUsingAlias ( UserPeer :: LAST_LOGIN , $ lastLogin [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ lastLogin [ 'max' ] ) ) { $ this -> addUsingAlias ( UserPeer :: LAST_LOGIN , $ lastLogin [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( UserPeer :: LAST_LOGIN , $ lastLogin , $ comparison ) ; }
Filter the query on the last_login column
8,013
private function _set_params ( ) { $ params = \ Request :: route ( 'params' ) ; $ filepath = $ this -> config [ 'abs_path' ] . '/' . \ Request :: route ( 'imagepath' ) ; if ( $ this -> config [ 'enforce_presets' ] && ! in_array ( $ params , $ this -> config [ 'presets' ] ) ) { abort ( 404 ) ; } $ image = new Image ( ) ; $ image -> configure ( config ( 'image' ) ) ; if ( function_exists ( 'exif_read_data' ) ) { $ this -> image = $ image -> make ( $ filepath ) -> orientate ( ) ; } else { $ this -> image = $ image -> make ( $ filepath ) ; } $ raw_params = explode ( '-' , $ params ) ; foreach ( $ raw_params as $ raw_param ) { $ name = $ raw_param [ 0 ] ; $ value = substr ( $ raw_param , 1 , strlen ( $ raw_param ) - 1 ) ; if ( $ name == 'c' ) { $ this -> url_params [ $ name ] = TRUE ; if ( empty ( $ this -> url_params [ 'w' ] ) ) { $ this -> url_params [ 'w' ] = $ this -> url_params [ 'h' ] ; } if ( empty ( $ this -> url_params [ 'h' ] ) ) { $ this -> url_params [ 'h' ] = $ this -> url_params [ 'w' ] ; } } elseif ( key_exists ( $ name , $ this -> url_params ) ) { $ this -> url_params [ $ name ] = $ value ; } else { $ this -> url_params [ $ raw_param ] = $ raw_param ; } } if ( ! $ this -> config [ 'scale_up' ] ) { if ( $ this -> url_params [ 'w' ] > $ this -> image -> width ( ) ) { $ this -> url_params [ 'w' ] = $ this -> image -> width ( ) ; } if ( $ this -> url_params [ 'h' ] > $ this -> image -> height ( ) ) { $ this -> url_params [ 'h' ] = $ this -> image -> height ( ) ; } } if ( empty ( $ this -> url_params [ 'w' ] ) and empty ( $ this -> url_params [ 'h' ] ) ) { throw new HTTP_Exception_404 ( 'The requested URL :uri was not found on this server.' , array ( ':uri' => Request :: $ current -> uri ( ) ) ) ; } $ this -> source_file = $ filepath ; }
Sets the operations params from the url
8,014
private function _cached_required ( ) { $ image_info = getimagesize ( $ this -> source_file ) ; if ( ( $ this -> url_params [ 'w' ] == $ image_info [ 0 ] ) and ( $ this -> url_params [ 'h' ] == $ image_info [ 1 ] ) ) { $ this -> serve_default = TRUE ; return FALSE ; } return TRUE ; }
Checks that the param dimensions are are lower then current image dimensions
8,015
private function _encoded_filename ( ) { $ ext = strtolower ( pathinfo ( $ this -> source_file , PATHINFO_EXTENSION ) ) ; $ encode = md5 ( $ this -> source_file . http_build_query ( $ this -> url_params ) ) ; $ encoded_name = $ encode . '-' . $ this -> source_modified . '.' . $ ext ; return $ encoded_name ; }
Returns a hash of the filepath and params plus last modified of source to be used as a unique filename
8,016
private function _create_headers ( $ file_data ) { $ last_modified = gmdate ( 'D, d M Y H:i:s' , filemtime ( $ file_data ) ) . ' GMT' ; $ filesystem = new \ Illuminate \ Filesystem \ Filesystem ; $ content_type = $ filesystem -> mimeType ( $ file_data ) ; $ content_length = filesize ( $ file_data ) ; $ expires = gmdate ( 'D, d M Y H:i:s' , ( time ( ) + $ this -> config [ 'cache_expire' ] ) ) . ' GMT' ; $ max_age = 'max-age=' . $ this -> config [ 'cache_expire' ] . ', public' ; header ( "Last-Modified: $last_modified" ) ; header ( "Content-Type: $content_type" ) ; header ( "Content-Length: $content_length" ) ; header ( "Expires: $expires" ) ; header ( "Cache-Control: $max_age" ) ; $ this -> _modified_headers ( $ last_modified ) ; header ( "Connection: close" ) ; }
Create the image HTTP headers
8,017
private function _modified_headers ( $ last_modified ) { $ modified_since = ( isset ( $ _SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] ) ) ? stripslashes ( $ _SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] ) : FALSE ; if ( ! $ modified_since or $ modified_since != $ last_modified ) return ; header ( 'HTTP/1.1 304 Not Modified' ) ; header ( 'Connection: close' ) ; exit ( ) ; }
Rerurns 304 Not Modified HTTP headers if required and exits
8,018
private function _serve_file ( ) { if ( $ this -> serve_default ) { $ file_data = $ this -> source_file ; } else { $ file_data = $ this -> cached_file ; } $ this -> _output_file ( $ file_data ) ; }
Decide which filesource we are using and serve
8,019
private function _output_file ( $ file_data ) { $ this -> _create_headers ( $ file_data ) ; $ data = file_get_contents ( $ file_data ) ; $ chunk_size = 1024 * 8 ; $ fp = fopen ( 'php://memory' , 'r+b' ) ; fwrite ( $ fp , $ data ) ; rewind ( $ fp ) ; while ( ! feof ( $ fp ) ) { echo fread ( $ fp , $ chunk_size ) ; flush ( ) ; } fclose ( $ fp ) ; exit ( ) ; }
Outputs the cached image file and exits
8,020
public function getClient ( ) : ClientInterface { if ( ! isset ( $ this -> client ) ) { $ this -> client = new GuzzleClient ( ) ; } return $ this -> client ; }
Get the Http client .
8,021
public function lookup ( string $ postcode , string $ number ) : array { $ input = [ 'postcode' => $ postcode , 'number' => $ number ] ; $ request = $ this -> request ( $ input ) ; $ response = null ; try { return $ this -> parse ( $ response = $ this -> client -> send ( $ request ) , $ input ) ; } catch ( GuzzleException $ e ) { if ( $ e instanceof RequestException && $ e -> hasResponse ( ) ) { return $ this -> parse ( $ e -> getResponse ( ) , $ input ) ; } throw new HttpException ( 'Guzzle: ' . $ e -> getMessage ( ) , $ request , $ response , $ e ) ; } catch ( Throwable $ e ) { if ( $ e instanceof PostcodesException ) { throw $ e ; } throw new LogicException ( 'Uncaught exception: ' . $ e -> getMessage ( ) , 0 , $ e ) ; } }
Lookup an address by postcode and house number .
8,022
public function remove ( $ key ) { $ file = $ this -> getFile ( $ this -> getKey ( $ key ) ) ; $ file -> delete ( ) ; return $ this ; }
Entfernt die Dateia us dem Cache
8,023
public static function uninstall ( ) { $ results = array ( ) ; $ plugins = Factory :: getPlugins ( 'all' , false , 0 ) ; foreach ( $ plugins as $ plugin ) { $ model = new Plugin ( ) ; $ result = $ model -> uninstall ( $ plugin -> name ) ; $ r = new stdClass ( ) ; $ result [ 'status' ] = 1 ; $ r -> status = $ result [ 'status' ] ; if ( ! $ r -> status ) { $ r -> message = Text :: _ ( 'UNINSTALL' ) . ' ' . $ plugin -> name . ' ' . Text :: _ ( 'FAILED' ) ; } else { $ r -> message = Text :: _ ( 'UNINSTALL' ) . ' ' . $ plugin -> name . ' ' . Text :: _ ( 'SUCCESS' ) ; } $ results [ ] = $ r ; } $ db = Factory :: getDBO ( ) ; $ query = 'DROP TABLE IF EXISTS #__jfusion' ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; $ query = 'DROP TABLE IF EXISTS #__jfusion_sync' ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; $ query = 'DROP TABLE IF EXISTS #__jfusion_sync_details' ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; $ query = 'DROP TABLE IF EXISTS #__jfusion_users' ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; return $ results ; }
method to uninstall the component
8,024
protected function renderTools ( ) { $ tools = '' ; if ( $ this -> collapseButton !== false ) { $ tools .= '<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>' ; } if ( $ this -> closeButton !== false ) { $ tools .= '<a class="close-link"><i class="fa fa-times"></i></a>' ; } if ( ! empty ( $ tools ) ) { return Html :: tag ( 'div' , $ tools , [ 'class' => 'ibox-tools' ] ) ; } else { return null ; } }
Renders the tools
8,025
public static function search ( Userinfo $ userinfo , $ lookup = false ) { $ exsistingUser = null ; if ( $ lookup && $ userinfo -> getJname ( ) !== null ) { $ userPlugin = Factory :: getUser ( $ userinfo -> getJname ( ) ) ; $ exsistingUser = $ userPlugin -> lookupUser ( $ userinfo ) ; } if ( ! $ exsistingUser instanceof Userinfo ) { $ plugins = Factory :: getPlugins ( ) ; foreach ( $ plugins as $ plugin ) { try { $ JFusionSlave = Factory :: getUser ( $ plugin -> name ) ; $ exsistingUser = $ JFusionSlave -> getUser ( $ userinfo ) ; if ( $ exsistingUser instanceof Userinfo ) { break ; } } catch ( Exception $ e ) { } } } return $ exsistingUser ; }
Finds the first user that match starting with master
8,026
public static function remove ( Userinfo $ userinfo ) { $ db = Factory :: getDBO ( ) ; $ query = $ db -> getQuery ( true ) -> delete ( '#__jfusion_users' ) -> where ( 'userid = ' . $ db -> quote ( $ userinfo -> userid ) ) ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; }
Delete old user data in the lookup table
8,027
public function meta ( ) { $ xml = ( array ) $ this -> xml ; unset ( $ xml [ 'entry' ] ) ; $ xml [ 'link' ] = ( object ) $ xml [ 'link' ] -> { "@attributes" } ; return ( object ) $ xml ; }
Get the meta information of the xml feed
8,028
protected function getXML ( ) { $ key = 'xml_' . md5 ( $ this -> url ) ; if ( $ this -> cache -> has ( $ key ) ) { $ this -> xml = $ this -> cache -> get ( $ key ) ; } else { $ this -> xml = $ this -> fetchXML ( ) ; $ this -> xml = $ this -> changeLinkElements ( $ this -> xml ) ; $ this -> cache -> put ( $ key , $ this -> xml , $ this -> cacheTime ) ; } }
Get the xml from the server and cache the result
8,029
static function register_assets ( ) { \ wp_enqueue_script ( 'jquery' ) ; \ wp_enqueue_script ( 'jquery-ui' ) ; \ wp_enqueue_script ( 'jquery-ui-datepicker' ) ; \ wp_enqueue_script ( 'jquery-ui-spinner' ) ; \ wp_enqueue_script ( 'jquery-ui-slider' ) ; \ wp_enqueue_script ( 'jquery-ui-resizable' ) ; \ wp_enqueue_script ( 'wp-color-picker' ) ; \ wp_enqueue_script ( 'amarkal' , AMARKAL_ASSETS_URL . 'js/amarkal.min.js' , array ( 'jquery' ) , AMARKAL_VERSION , true ) ; \ wp_enqueue_script ( 'select2' , AMARKAL_ASSETS_URL . 'js/select2.min.js' , array ( 'jquery' ) , '4.0.3' , true ) ; \ wp_enqueue_script ( 'ace-editor' , 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.6/ace.js' , array ( ) , '1.2.6' , true ) ; \ wp_enqueue_style ( 'font-awesome' , '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' , array ( ) , '4.7.0' ) ; \ wp_enqueue_style ( 'amarkal' , AMARKAL_ASSETS_URL . 'css/amarkal.min.css' , array ( 'wp-color-picker' ) , AMARKAL_VERSION ) ; \ wp_enqueue_style ( 'select2' , AMARKAL_ASSETS_URL . 'css/select2.min.css' , array ( ) , '4.0.3' ) ; }
Register Amarkal Scripts and Stylesheets
8,030
function getDefaultUsergroup ( ) { $ usergroups = Groups :: get ( $ this -> getJname ( ) , true ) ; $ groups = array ( ) ; if ( $ usergroups !== null ) { $ list = $ this -> getUsergroupList ( ) ; foreach ( $ list as $ group ) { if ( in_array ( $ group -> id , $ usergroups ) ) { $ groups [ ] = $ group -> name ; } } } return $ groups ; }
Function used to display the default usergroup in the JFusion plugin overview
8,031
function debugConfig ( ) { $ jname = $ this -> getJname ( ) ; $ new_registration = $ this -> allowRegistration ( ) ; if ( $ new_registration ) { $ plugins = Framework :: getSlaves ( ) ; foreach ( $ plugins as $ plugin ) { if ( $ plugin -> name == $ jname ) { Framework :: raise ( LogLevel :: NOTICE , Text :: _ ( 'DISABLE_REGISTRATION' ) , $ jname ) ; } } } else { $ master = Framework :: getMaster ( ) ; if ( $ master && $ master -> name == $ jname ) { Framework :: raise ( LogLevel :: NOTICE , Text :: _ ( 'ENABLE_REGISTRATION' ) , $ jname ) ; } } $ cookie_domain = $ this -> params -> get ( 'cookie_domain' , - 1 ) ; if ( $ cookie_domain !== - 1 ) { $ cookie_domain = str_replace ( array ( 'http://' , 'https://' ) , array ( '' , '' ) , $ cookie_domain ) ; $ correct_array = explode ( '.' , html_entity_decode ( $ _SERVER [ 'SERVER_NAME' ] ) ) ; if ( isset ( $ correct_array [ count ( $ correct_array ) - 2 ] ) && isset ( $ correct_array [ count ( $ correct_array ) - 1 ] ) ) { $ domain_array = array ( 'com' , 'net' , 'org' , 'co' , 'me' ) ; if ( in_array ( $ correct_array [ count ( $ correct_array ) - 2 ] , $ domain_array ) ) { $ correct_domain = '.' . $ correct_array [ count ( $ correct_array ) - 3 ] . '.' . $ correct_array [ count ( $ correct_array ) - 2 ] . '.' . $ correct_array [ count ( $ correct_array ) - 1 ] ; } else { $ correct_domain = '.' . $ correct_array [ count ( $ correct_array ) - 2 ] . '.' . $ correct_array [ count ( $ correct_array ) - 1 ] ; } if ( $ correct_domain != $ cookie_domain && ! $ this -> allowEmptyCookieDomain ( ) ) { Framework :: raise ( LogLevel :: NOTICE , Text :: _ ( 'BEST_COOKIE_DOMAIN' ) . ' ' . $ correct_domain , $ jname ) ; } } } $ cookie_path = $ this -> params -> get ( 'cookie_path' , - 1 ) ; if ( $ cookie_path !== - 1 ) { if ( $ cookie_path != '/' && ! $ this -> allowEmptyCookiePath ( ) ) { Framework :: raise ( LogLevel :: NOTICE , Text :: _ ( 'BEST_COOKIE_PATH' ) . ' /' , $ jname ) ; } } $ this -> debugConfigExtra ( ) ; }
Function that checks if the plugin has a valid config jerror is used for output
8,032
final public function saveParameters ( $ post , $ wizard = false ) { $ jname = $ this -> getJname ( ) ; $ result = false ; try { if ( ! empty ( $ jname ) ) { $ db = Factory :: getDBO ( ) ; if ( isset ( $ post [ 'source_url' ] ) ) { $ post [ 'source_path' ] = rtrim ( $ post [ 'source_path' ] , '/\\' ) ; $ post [ 'source_path' ] .= '/' ; if ( substr ( $ post [ 'source_url' ] , 0 , 7 ) != 'http://' && substr ( $ post [ 'source_url' ] , 0 , 8 ) != 'https://' ) { if ( substr ( $ post [ 'source_url' ] , 0 , 1 ) != '/' ) { $ post [ 'source_url' ] = 'http://' . $ post [ 'source_url' ] ; } } } if ( isset ( $ post [ 'source_path' ] ) ) { if ( ! empty ( $ post [ 'source_path' ] ) ) { $ post [ 'source_path' ] = rtrim ( $ post [ 'source_path' ] , '/\\' ) ; $ post [ 'source_path' ] .= '/' ; if ( ! is_dir ( $ post [ 'source_path' ] ) ) { Framework :: raise ( LogLevel :: WARNING , Text :: _ ( 'SOURCE_PATH_NOT_FOUND' ) ) ; } } } if ( $ wizard ) { $ query = $ db -> getQuery ( true ) -> select ( 'params' ) -> from ( '#__jfusion' ) -> where ( 'name = ' . $ db -> quote ( $ jname ) ) ; $ db -> setQuery ( $ query ) ; $ params = $ db -> loadResult ( ) ; $ params = new Registry ( $ params ) ; $ existing_params = $ params -> toArray ( ) ; if ( is_array ( $ existing_params ) ) { $ post = array_merge ( $ existing_params , $ post ) ; } } $ data = new Registry ( $ post ) ; $ query = $ db -> getQuery ( true ) -> update ( '#__jfusion' ) -> set ( 'params = ' . $ db -> quote ( $ data -> toString ( ) ) ) -> where ( 'name = ' . $ db -> quote ( $ jname ) ) ; $ db -> setQuery ( $ query ) ; $ db -> execute ( ) ; Factory :: getParams ( $ jname , true ) ; $ result = true ; } } catch ( Exception $ e ) { Framework :: raise ( LogLevel :: ERROR , $ e , $ jname ) ; } return $ result ; }
Saves the posted JFusion component variables
8,033
public static function clearInput ( $ input ) { if ( is_array ( $ input ) ) { foreach ( $ input as $ key => $ value ) { if ( ! isset ( $ value ) || $ value === '' ) { unset ( $ input [ $ key ] ) ; } } return $ input ; } return $ input ; }
This will look through the input and remove any unset values .
8,034
public static function apiRoutes ( ) { Route :: group ( [ 'namespace' => 'Kregel\\Warden\\Http\\Controllers' , 'prefix' => config ( 'kregel.warden.route' ) . '/api/v1.0' , 'as' => 'warden::api.' , 'middleware' => config ( 'kregel.warden.auth.middleware_api' ) , ] , function ( $ router ) { Route :: get ( 'media/{model}/{uuid}' , [ 'as' => 'media' , 'uses' => 'ApiController@displayMediaPage' ] ) ; Route :: get ( '{model}s' , [ 'as' => 'get-all' , 'uses' => 'ApiController@getAllModels' ] ) ; Route :: get ( '{model}' , [ 'as' => 'get-models' , 'uses' => 'ApiController@getSomeModels' ] ) ; Route :: get ( '{model}/{id}' , [ 'as' => 'get-model' , 'uses' => 'ApiController@findModel' ] ) ; Route :: post ( '{model}' , [ 'as' => 'create-model' , 'uses' => 'ApiController@postModel' ] ) ; Route :: post ( '{model}/{id}' , [ 'as' => 'update-model-post' , 'uses' => 'ApiController@putModel' ] ) ; Route :: put ( '{model}/{id}' , [ 'as' => 'update-model' , 'uses' => 'ApiController@putModel' ] ) ; Route :: delete ( 'd/{model}/{id}' , [ 'as' => 'delete-model' , 'uses' => 'ApiController@deleteModel' ] ) ; } ) ; }
Define the api routes more dynamically .
8,035
public static function webRoutes ( ) { Route :: group ( [ 'namespace' => 'Kregel\\Warden\\Http\\Controllers' , 'prefix' => config ( 'kregel.warden.route' ) , 'as' => 'warden::' , 'middleware' => config ( 'kregel.warden.auth.middleware' ) , ] , function ( $ router ) { Route :: get ( '/' , function ( ) { return view ( 'warden::base' ) ; } ) ; Route :: get ( '{model}/manage/new' , [ 'as' => 'new-model' , 'uses' => 'ModelController@getNewModel' ] ) ; Route :: get ( '{model}s/manage' , [ 'as' => 'models' , 'uses' => 'ModelController@getModelList' ] ) ; Route :: get ( '{model}/manage/{id}' , [ 'as' => 'model' , 'uses' => 'ModelController@getModel' ] ) ; } ) ; }
Define the web routes more dynamically .
8,036
public static function register ( $ useZepto = false , $ ie8Support = false ) { static :: registerCoreCss ( ) ; static :: registerCoreScripts ( $ useZepto ) ; if ( $ ie8Support ) static :: registerBlockGridIeSupport ( ) ; }
Registers all core css and js scripts for foundation
8,037
public static function registerCoreScripts ( $ useZepto = false , $ minimized = true , $ position = \ CClientScript :: POS_END ) { $ cs = \ Yii :: app ( ) -> getClientScript ( ) ; if ( $ useZepto ) { $ cs -> registerScriptFile ( static :: getAssetsUrl ( ) . '/js/vendor/zepto.js' ) ; } else { $ cs -> registerCoreScript ( 'jquery' ) ; } $ cs -> registerScriptFile ( static :: getAssetsUrl ( ) . '/js/vendor/custom.modernizr.js' , \ CClientScript :: POS_HEAD ) ; $ script = $ minimized ? '/js/foundation.min.js' : '/js/foundation/foundation.js' ; $ cs -> registerScriptFile ( static :: getAssetsUrl ( ) . $ script , $ position ) ; $ cs -> registerScript ( __CLASS__ , '$(document).foundation();' ) ; }
Registers jQuery and Foundation JavaScript .
8,038
public static function isCoreRegistered ( $ minimized = true , $ position = \ CClientScript :: POS_END ) { $ script = $ minimized ? '/js/foundation.min.js' : '/js/foundation/foundation.js' ; return \ Yii :: app ( ) -> getClientScript ( ) -> isScriptFileRegistered ( static :: getAssetsUrl ( ) . $ script , $ position ) ; }
Checks whether the core script has been registered or not
8,039
public static function registerFonts ( $ fonts = array ( ) ) { if ( empty ( $ fonts ) ) return ; foreach ( $ fonts as $ font ) { Icon :: registerIconFontSet ( $ font ) ; } }
Registers foundation fonts
8,040
public static function registerCoreCss ( ) { $ fileName = \ YII_DEBUG ? 'foundation.css' : 'foundation.min.css' ; \ Yii :: app ( ) -> clientScript -> registerCssFile ( static :: getAssetsUrl ( ) . '/css/normalize.css' ) ; \ Yii :: app ( ) -> clientScript -> registerCssFile ( static :: getAssetsUrl ( ) . '/css/' . $ fileName ) ; }
Registers the Foundation CSS .
8,041
public static function getAssetsUrl ( $ forceCopyAssets = false , $ cdn = false ) { if ( ! isset ( static :: $ assetsUrl ) ) { if ( $ cdn ) { static :: $ assetsUrl = '//cdn.jsdelivr.net/foundation/4.3.1/' ; } else { $ assetsPath = static :: getAssetsPath ( ) ; static :: $ assetsUrl = \ Yii :: app ( ) -> assetManager -> publish ( $ assetsPath , true , - 1 , $ forceCopyAssets ) ; } } return static :: $ assetsUrl ; }
Returns the url to the published assets folder .
8,042
public static function registerScriptFile ( $ asset , $ position = \ CClientScript :: POS_END ) { \ Yii :: app ( ) -> clientScript -> registerScriptFile ( static :: getAssetsUrl ( ) . "/{$asset}" , $ position ) ; }
Registers a specific js assets file
8,043
public static function registerBlockGridIeSupport ( $ position = \ CClientScript :: POS_END ) { \ Yii :: app ( ) -> getClientScript ( ) -> registerScript ( __CLASS__ , "(function($){ $(function(){ $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'}); $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'}); $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'}); $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'}); });})(jQuery); " , $ position ) ; }
Registers block - grid support for ie8 if set by its ie8Support attribute .
8,044
public function setMasterVariant ( VariantInterface $ masterVariant ) { $ masterVariant -> setMaster ( true ) ; foreach ( $ this -> variants as $ variant ) { if ( $ variant -> isMaster ( ) && $ variant !== $ masterVariant ) { $ variant -> setMaster ( false ) ; } } if ( ! $ this -> variants -> contains ( $ masterVariant ) ) { $ masterVariant -> setObject ( $ this ) ; $ this -> variants -> add ( $ masterVariant ) ; } return $ this ; }
Set the master variant
8,045
public function addVariant ( VariantInterface $ variant ) { if ( ! $ this -> hasVariant ( $ variant ) ) { $ variant -> setObject ( $ this ) ; $ this -> variants -> add ( $ variant ) ; } return $ this ; }
Adds a variant
8,046
public function removeVariant ( VariantInterface $ variant ) { if ( $ this -> hasVariant ( $ variant ) ) { $ variant -> setObject ( null ) ; $ this -> variants -> removeElement ( $ variant ) ; } return $ this ; }
Removes a variant
8,047
public function setVariabilityOptions ( Collection $ variabilityOptions ) { foreach ( $ variabilityOptions as $ variabilityOption ) { $ this -> addVariabilityOption ( $ variabilityOption ) ; } return $ this ; }
Sets all variability options
8,048
public function addVariabilityOption ( OptionInterface $ variabilityOption ) { if ( ! $ this -> hasVariabilityOption ( $ variabilityOption ) ) { $ this -> variabilityOptions -> add ( $ variabilityOption ) ; } return $ this ; }
Adds a given variability option
8,049
public function removeVariabilityOption ( OptionInterface $ variabilityOption ) { if ( $ this -> hasVariabilityOption ( $ variabilityOption ) ) { $ this -> variabilityOptions -> removeElement ( $ variabilityOption ) ; } return $ this ; }
Removes a given variability option
8,050
protected function _parseUri ( $ schemeSpecific ) { $ pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~' ; $ status = @ preg_match ( $ pattern , $ schemeSpecific , $ matches ) ; if ( $ status === false ) { require_once 'Zend/Uri/Exception.php' ; throw new Zend_Uri_Exception ( 'Internal error: scheme-specific decomposition failed' ) ; } if ( $ status === false ) { return ; } $ this -> _path = isset ( $ matches [ 4 ] ) === true ? $ matches [ 4 ] : '' ; $ this -> _query = isset ( $ matches [ 6 ] ) === true ? $ matches [ 6 ] : '' ; $ this -> _fragment = isset ( $ matches [ 8 ] ) === true ? $ matches [ 8 ] : '' ; $ combo = isset ( $ matches [ 3 ] ) === true ? $ matches [ 3 ] : '' ; $ pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~' ; $ status = @ preg_match ( $ pattern , $ combo , $ matches ) ; if ( $ status === false ) { require_once 'Zend/Uri/Exception.php' ; throw new Zend_Uri_Exception ( 'Internal error: authority decomposition failed' ) ; } if ( $ status === false ) { return ; } $ this -> _username = isset ( $ matches [ 2 ] ) === true ? $ matches [ 2 ] : '' ; $ this -> _password = isset ( $ matches [ 4 ] ) === true ? $ matches [ 4 ] : '' ; $ this -> _host = isset ( $ matches [ 5 ] ) === true ? $ matches [ 5 ] : '' ; $ this -> _port = isset ( $ matches [ 7 ] ) === true ? $ matches [ 7 ] : '' ; }
Parse the scheme - specific portion of the URI and place its parts into instance variables .
8,051
public function getUri ( ) { if ( $ this -> valid ( ) === false ) { require_once 'Zend/Uri/Exception.php' ; throw new Zend_Uri_Exception ( 'One or more parts of the URI are invalid' ) ; } $ password = strlen ( $ this -> _password ) > 0 ? ":$this->_password" : '' ; $ auth = strlen ( $ this -> _username ) > 0 ? "$this->_username$password@" : '' ; $ port = strlen ( $ this -> _port ) > 0 ? ":$this->_port" : '' ; $ query = strlen ( $ this -> _query ) > 0 ? "?$this->_query" : '' ; $ fragment = strlen ( $ this -> _fragment ) > 0 ? "#$this->_fragment" : '' ; return $ this -> _scheme . '://' . $ auth . $ this -> _host . $ port . $ this -> _path . $ query . $ fragment ; }
Returns a URI based on current values of the instance variables . If any part of the URI does not pass validation then an exception is thrown .
8,052
public function validatePath ( $ path = null ) { if ( $ path === null ) { $ path = $ this -> _path ; } if ( strlen ( $ path ) === 0 ) { return true ; } $ pattern = '/^' . $ this -> _regex [ 'path' ] . '$/' ; $ status = @ preg_match ( $ pattern , $ path ) ; if ( $ status === false ) { require_once 'Zend/Uri/Exception.php' ; throw new Zend_Uri_Exception ( 'Internal error: path validation failed' ) ; } return ( boolean ) $ status ; }
Returns true if and only if the path string passes validation . If no path is passed then the path contained in the instance variable is used .
8,053
protected function generateContent ( $ templatePath , $ templateData ) { $ template = $ this -> getTemplate ( $ templatePath ) ; $ content = $ this -> compile ( $ template , $ templateData ) ; return $ content ; }
Generate content with template data is given .
8,054
protected function getTemplate ( $ templatePath ) { $ path = base_path ( 'resources/generator-templates/' . $ templatePath . '.stub' ) ; if ( ! file_exists ( $ path ) ) { $ path = __DIR__ . '/../../templates/' . $ templatePath . '.stub' ; } return $ this -> fileHelper -> get ( $ path ) ; }
Get the template for the generator .
8,055
public function logError ( \ Exception $ e , $ detailLevel = 1 , $ level = 1 ) { if ( $ detailLevel >= 5 ) { return $ this -> log ( "\n" . 'ERROR: ' . \ Psc \ Exception :: getExceptionText ( $ e , 'text' ) ) ; } else { return $ this -> log ( "\n" . 'ERROR: Exception: ' . $ e -> getMessage ( ) , $ level ) ; } }
ab detailLevel > = 5 wird der exceptionTrace mit geloggt
8,056
private function getOnValidate ( \ ReflectionMethod $ method ) { $ valid = $ this -> reader -> getMethodAnnotation ( $ method , Valid :: class ) ; $ class = $ method -> getDeclaringClass ( ) ; $ onMethods = $ this -> findOnMethods ( $ class , $ valid ) ; if ( $ onMethods [ 0 ] && $ onMethods [ 0 ] instanceof \ ReflectionMethod ) { return $ onMethods ; } throw new ValidateMethodNotFound ( $ method -> getShortName ( ) ) ; }
Return Validate and OnFailure method
8,057
private function validate ( MethodInvocation $ invocation , \ ReflectionMethod $ onValidate , \ ReflectionMethod $ onFailure = null ) { $ validation = $ onValidate -> invokeArgs ( $ invocation -> getThis ( ) , ( array ) $ invocation -> getArguments ( ) ) ; if ( $ validation instanceof Validation && $ validation -> getMessages ( ) ) { $ validation -> setInvocation ( $ invocation ) ; $ failure = $ this -> getFailure ( $ invocation , $ validation , $ onFailure ) ; if ( $ failure instanceof \ Exception ) { throw $ failure ; } return [ false , $ failure ] ; } return [ true , null ] ; }
Validate with Validate method
8,058
private function getFailure ( MethodInvocation $ invocation , FailureInterface $ failure , \ ReflectionMethod $ onFailure = null ) { if ( $ onFailure ) { return $ onFailure -> invoke ( $ invocation -> getThis ( ) , $ failure ) ; } return $ this -> failureException ( $ invocation , $ failure ) ; }
Return result OnFailure
8,059
private function failureException ( MethodInvocation $ invocation , FailureInterface $ failure ) { $ class = new \ ReflectionClass ( $ invocation -> getThis ( ) ) ; $ className = $ class -> implementsInterface ( WeavedInterface :: class ) ? $ class -> getParentClass ( ) -> name : $ class -> name ; $ errors = json_encode ( $ failure -> getMessages ( ) ) ; $ msg = sprintf ( '%s::%s() %s' , $ className , $ invocation -> getMethod ( ) -> name , $ errors ) ; return new InvalidArgumentException ( $ msg , 400 ) ; }
Return InvalidArgumentException exception
8,060
public function render ( ElementInterface $ element ) { $ attributes = $ element -> getAttributes ( ) ; $ captcha = $ element -> getCaptcha ( ) ; if ( $ captcha === null || ! $ captcha instanceof CaptchaAdapter ) { throw new Exception \ DomainException ( sprintf ( '%s requires that the element has a "captcha" is an instance of LosReCaptcha\Captcha\ReCaptcha' , __METHOD__ ) ) ; } $ name = $ element -> getName ( ) ; $ id = isset ( $ attributes [ 'id' ] ) ? $ attributes [ 'id' ] : $ name ; $ responseName = empty ( $ name ) ? 'recaptcha_response_field' : $ name . '[recaptcha_response_field]' ; $ responseId = $ id . '-response' ; $ markup = $ captcha -> getService ( ) -> getHtml ( $ name ) ; $ hidden = $ this -> renderHiddenInput ( $ responseName , $ responseId ) ; $ js = $ this -> renderJsEvents ( $ responseId ) ; return $ hidden . $ markup . $ js ; }
Render ReCaptcha form elements
8,061
public function redirect ( array $ options = [ ] ) { $ plugin = $ this -> _request -> getParam ( 'plugin' ) ; $ controller = $ this -> _request -> getParam ( 'controller' ) ; $ _options = [ 'apply' => [ ] , 'savenew' => [ 'plugin' => $ plugin , 'controller' => $ controller , 'action' => 'add' ] , 'save' => [ 'plugin' => $ plugin , 'controller' => $ controller , 'action' => 'index' , ] ] ; $ options = Hash :: merge ( $ _options , $ options ) ; $ url = $ options [ 'save' ] ; if ( $ rAction = $ this -> _request -> getData ( 'action' ) ) { list ( , $ action ) = pluginSplit ( $ rAction ) ; $ action = Str :: low ( $ action ) ; if ( Arr :: key ( $ action , $ options ) ) { $ url = $ options [ $ action ] ; } } return $ this -> _controller -> redirect ( $ url ) ; }
Redirect by request data .
8,062
public function toggleField ( Table $ table , $ id , $ value , $ field = 'status' ) { $ this -> checkIsAjax ( ) ; $ this -> _checkToggleData ( $ id , $ value ) ; $ this -> _controller -> viewBuilder ( ) -> setLayout ( 'ajax' ) -> setTemplate ( 'toggle' ) -> setTemplatePath ( 'Common' ) ; $ entity = $ table -> get ( $ id ) ; $ entity -> set ( $ field , ! ( int ) $ value ) ; if ( $ result = $ table -> save ( $ entity ) ) { $ this -> _controller -> set ( 'entity' , $ result ) ; $ this -> _controller -> render ( 'toggle' ) ; } else { throw new \ RuntimeException ( __d ( 'core' , 'Failed toggling field {0} to {1}' , $ field , $ entity -> get ( $ field ) ) ) ; } }
Toggle table field value .
8,063
public function getExtractor ( $ key ) { if ( ! $ this -> hasExtractor ( $ key ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Address extractor with key "%s" does not exist' , $ key ) ) ; } return $ this -> extractors [ $ key ] ; }
Get the extractor for the specified key
8,064
public function validate ( $ addable ) { foreach ( $ addable -> elements as $ element ) { $ classes = class_parents ( $ element ) ; if ( in_array ( "HtmlForm\Elements\Parents\Html" , $ classes ) ) { continue ; } if ( in_array ( "HtmlForm\Abstracts\Addable" , $ classes ) ) { $ moreErrors = $ this -> validate ( $ element ) ; } else { $ class = $ this -> findclass ( $ element ) ; if ( $ class == "honeypot" ) { $ value = $ element -> getRawValue ( ) ; $ this -> honeypot ( $ value ) ; continue ; } $ elementErrors = $ element -> validate ( ) ; $ this -> errors = array_merge ( $ this -> errors , $ elementErrors ) ; } } return empty ( $ this -> errors ) ; }
Runs through the validation required by each form element .
8,065
public static function create ( $ color ) { $ rgb = array ( ) ; if ( is_array ( $ color ) ) { $ color = array_values ( $ color ) ; $ rgb [ 0 ] = $ color [ 0 ] ; $ rgb [ 1 ] = $ color [ 1 ] ; $ rgb [ 2 ] = $ color [ 2 ] ; } elseif ( is_string ( $ color ) && substr ( $ color , 0 , 1 ) == '#' ) { $ color = substr ( $ color , 1 ) ; if ( strlen ( $ color ) == 3 ) { $ rgb [ 0 ] = hexdec ( substr ( $ color , 0 , 1 ) . substr ( $ color , 0 , 1 ) ) ; $ rgb [ 1 ] = hexdec ( substr ( $ color , 1 , 1 ) . substr ( $ color , 1 , 1 ) ) ; $ rgb [ 2 ] = hexdec ( substr ( $ color , 2 , 1 ) . substr ( $ color , 2 , 1 ) ) ; } elseif ( strlen ( $ color ) == 6 ) { $ rgb [ 0 ] = hexdec ( substr ( $ color , 0 , 2 ) ) ; $ rgb [ 1 ] = hexdec ( substr ( $ color , 2 , 2 ) ) ; $ rgb [ 2 ] = hexdec ( substr ( $ color , 4 , 2 ) ) ; } } else { return false ; } return new static ( $ rgb ) ; }
parse an color
8,066
public function validationResponse ( \ Psc \ Form \ ValidatorExceptionList $ list , $ format = ServiceResponse :: JSON , MetadataGenerator $ metadataGenerator = NULL ) { if ( $ format === ServiceResponse :: JSON ) { $ body = ( object ) array ( 'errors' => array ( ) ) ; foreach ( $ list -> getExceptions ( ) as $ validatorException ) { $ body -> errors [ $ validatorException -> field ] = $ validatorException -> getMessage ( ) ; } return HTTPResponseException :: BadRequest ( json_encode ( $ body ) , NULL , array ( 'Content-Type' => 'application/json' ) ) ; } else { $ metadataGenerator = $ metadataGenerator ? : new MetadataGenerator ( ) ; return HTTPException :: BadRequest ( $ list -> getMessage ( ) , $ list , array_merge ( array ( 'Content-Type' => 'text/html' ) , $ metadataGenerator -> validationList ( $ list ) -> toHeaders ( ) ) ) ; } }
Throws an ValidationResponse
8,067
final public function findUser ( Userinfo $ userinfo ) { $ userloopup = $ this -> lookupUser ( $ userinfo ) ; if ( $ userloopup instanceof Userinfo ) { $ user = $ this -> getUser ( $ userloopup ) ; } else { $ user = $ this -> getUser ( $ userinfo ) ; if ( $ user instanceof Userinfo ) { $ this -> updateLookup ( $ user , $ userinfo ) ; } } return $ user ; }
Gets the userinfo from the JFusion integrated software . it uses the lookup function
8,068
public final function getUserIdentifier ( Userinfo & $ userinfo , $ username_col , $ email_col , $ userid_col , $ lowerEmail = true ) { $ login_identifier = $ this -> params -> get ( 'login_identifier' , 1 ) ; if ( $ this -> getJname ( ) == $ userinfo -> getJname ( ) && $ userinfo -> userid != null ) { $ login_identifier = 4 ; } elseif ( $ username_col == null ) { $ login_identifier = 2 ; } switch ( $ login_identifier ) { default : case 1 : $ identifier = $ userinfo -> username ; $ identifier_type = $ username_col ; break ; case 2 : $ identifier = $ userinfo -> email ; $ identifier_type = $ email_col ; break ; case 3 : $ pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i' ; if ( preg_match ( $ pattern , $ userinfo -> username ) ) { $ identifier_type = $ email_col ; $ identifier = $ userinfo -> email ; } else { $ identifier_type = $ username_col ; $ identifier = $ userinfo -> username ; } break ; case 4 : $ identifier_type = $ userid_col ; $ identifier = $ userinfo -> userid ; break ; } if ( $ lowerEmail && $ identifier_type == $ email_col ) { $ identifier_type = 'LOWER(' . $ identifier_type . ')' ; $ identifier = strtolower ( $ identifier ) ; } return array ( $ identifier_type , $ identifier ) ; }
Returns the identifier and identifier_type for getUser
8,069
function executeUpdateUsergroup ( Userinfo $ userinfo , Userinfo & $ existinguser ) { $ changed = false ; $ usergroups = $ this -> getCorrectUserGroups ( $ userinfo ) ; if ( ! $ this -> compareUserGroups ( $ existinguser , $ usergroups ) ) { $ this -> updateUsergroup ( $ userinfo , $ existinguser ) ; $ changed = true ; } return $ changed ; }
Function that determines if the usergroup needs to be updated and executes updateUsergroup if it does
8,070
public function compareUserGroups ( Userinfo $ userinfo , $ usergroups ) { if ( ! is_array ( $ usergroups ) ) { $ usergroups = array ( $ usergroups ) ; } $ correct = false ; $ count = 0 ; if ( count ( $ usergroups ) == count ( $ userinfo -> groups ) ) { foreach ( $ usergroups as $ group ) { if ( in_array ( $ group , $ userinfo -> groups , true ) ) { $ count ++ ; } } if ( count ( $ userinfo -> groups ) == $ count ) { $ correct = true ; } } return $ correct ; }
compare set of usergroup with a user returns true if the usergroups are correct
8,071
function getUserGroupIndex ( Userinfo $ userinfo ) { $ index = 0 ; $ master = Framework :: getMaster ( ) ; if ( $ master ) { $ mastergroups = Groups :: get ( $ master -> name ) ; foreach ( $ mastergroups as $ key => $ mastergroup ) { if ( $ mastergroup ) { if ( count ( $ mastergroup ) == count ( $ userinfo -> groups ) ) { $ count = 0 ; foreach ( $ mastergroup as $ value ) { if ( in_array ( $ value , $ userinfo -> groups , true ) ) { $ count ++ ; } } if ( count ( $ userinfo -> groups ) == $ count ) { $ index = $ key ; break ; } } } } } return $ index ; }
Function That find the correct user group index
8,072
final public function getCorrectUserGroups ( Userinfo $ userinfo ) { $ jname = $ this -> getJname ( ) ; $ group = array ( ) ; $ master = Framework :: getMaster ( ) ; if ( $ master ) { if ( $ master -> name == $ jname ) { $ group = Groups :: get ( $ master -> name , true ) ; } else { $ slavegroups = Groups :: get ( $ jname ) ; $ user = Factory :: getUser ( $ master -> name ) ; $ index = $ user -> getUserGroupIndex ( $ userinfo ) ; if ( isset ( $ slavegroups [ $ index ] ) ) { $ group = $ slavegroups [ $ index ] ; } if ( $ group === null && isset ( $ slavegroups [ 0 ] ) ) { $ group = $ slavegroups [ 0 ] ; } } } if ( ! is_array ( $ group ) ) { if ( $ group !== null ) { $ group = array ( $ group ) ; } else { $ group = array ( ) ; } } return $ group ; }
return the correct usergroups for a given user
8,073
final public function lookupUser ( Userinfo $ exsistinginfo ) { $ user = null ; if ( $ exsistinginfo ) { $ db = Factory :: getDBO ( ) ; $ query = $ db -> getQuery ( true ) -> select ( 'b.userid, b.username, b.email' ) -> from ( '#__jfusion_users AS a' ) -> innerJoin ( '#__jfusion_users AS b ON a.id = b.id' ) -> where ( 'b.jname = ' . $ db -> quote ( $ this -> getJname ( ) ) ) -> where ( 'a.jname = ' . $ db -> quote ( $ exsistinginfo -> getJname ( ) ) ) ; $ search = array ( ) ; if ( isset ( $ exsistinginfo -> userid ) ) { $ search [ ] = 'a.userid = ' . $ db -> quote ( $ exsistinginfo -> userid ) ; } if ( isset ( $ exsistinginfo -> username ) ) { $ search [ ] = 'a.username = ' . $ db -> quote ( $ exsistinginfo -> username ) ; } if ( isset ( $ exsistinginfo -> email ) ) { $ search [ ] = 'a.email = ' . $ db -> quote ( $ exsistinginfo -> email ) ; } if ( ! empty ( $ search ) ) { $ query -> where ( '( ' . implode ( ' OR ' , $ search ) . ' )' ) ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadObject ( ) ; if ( $ result ) { $ user = new Userinfo ( $ this -> getJname ( ) ) ; $ user -> bind ( $ result ) ; } } } return $ user ; }
Returns the userinfo data for JFusion plugin based on the userid
8,074
public function send ( MessageQueueInterface $ messageQueue = null ) { if ( $ messageQueue === null && $ this -> messageQueue === null ) { $ messageQueue = Yii :: $ app -> getMessageQueue ( ) ; } elseif ( $ messageQueue === null ) { $ messageQueue = $ this -> messageQueue ; } return $ messageQueue -> send ( $ this ) ; }
Sends this message queue message .
8,075
public function getFlash ( $ key ) { return $ this -> started && isset ( $ _SESSION [ $ this -> flashSessionKey ] [ $ key ] ) ? $ _SESSION [ $ this -> flashSessionKey ] [ $ key ] : null ; }
Get data from the current flash messages bag .
8,076
public function setFlash ( $ key , $ value ) { if ( ! $ this -> started ) { return $ this ; } $ _SESSION [ $ this -> nextFlashSessionKey ] [ $ key ] = $ value ; return $ this ; }
Set data to the flash messages bag for the next request .
8,077
public function toNextFlash ( ) { if ( ! $ this -> started ) { return $ this ; } $ _SESSION [ $ this -> flashSessionKey ] = isset ( $ _SESSION [ $ this -> nextFlashSessionKey ] ) ? $ _SESSION [ $ this -> nextFlashSessionKey ] : [ ] ; $ _SESSION [ $ this -> nextFlashSessionKey ] = [ ] ; return $ this ; }
Copy the next flash data to current flash . This should be done in the end of request .
8,078
public function generateCsrfToken ( ) { $ token = hash ( "sha512" , mt_rand ( 0 , mt_getrandmax ( ) ) ) ; $ _SESSION [ $ this -> csrfTokenSessionKey ] = $ token ; return $ token ; }
Generate CSRF token .
8,079
public function validateCsrfToken ( $ token ) { return ( isset ( $ _SESSION [ $ this -> csrfTokenSessionKey ] ) && $ _SESSION [ $ this -> csrfTokenSessionKey ] === $ token ) ; }
Validate with the token stored in session .
8,080
public function RelativeLink ( $ action = null ) { $ remoteObject = $ this -> ContentItem ( ) ; if ( ! is_string ( $ action ) ) { $ action = null ; } if ( $ remoteObject ) { return $ this -> LinkFor ( $ remoteObject , $ action ? $ action : 'view' ) ; } return parent :: RelativeLink ( $ action ) ; }
When linking to this external content page return a URL that ll let you view the external content item directly
8,081
public function ContentItem ( $ what = 'k' ) { if ( $ this -> requestedItem ) { return $ this -> requestedItem ; } if ( ! $ this -> ExternalContentRoot ) { return null ; } $ id = isset ( $ _REQUEST [ 'item' ] ) ? $ _REQUEST [ 'item' ] : null ; if ( ! $ id ) { $ id = $ this -> ExternalContentRoot ; } $ remoteObject = ExternalContent :: getDataObjectFor ( $ id ) ; if ( $ remoteObject ) { $ this -> requestedItem = $ remoteObject ; return $ this -> requestedItem ; } return null ; }
Get the external content item
8,082
public function view ( $ request ) { $ object = null ; if ( $ id = $ request -> param ( 'ID' ) ) { $ object = ExternalContent :: getDataObjectFor ( $ id ) ; if ( $ object instanceof ExternalContentSource ) { $ object = $ object -> getRoot ( ) ; } if ( $ object && ( $ object instanceof ExternalContentItem || $ object instanceof ExternalContentSource ) ) { $ this -> data ( ) -> setRequestedItem ( $ object ) ; $ type = $ object instanceof ExternalContentItem ? $ object -> getType ( ) : 'source' ; $ template = 'ExternalContent_' . get_class ( $ object ) . '_' . $ type ; $ viewer = new SSViewer ( array ( $ template , 'ExternalContent_' . get_class ( $ object ) , 'ExternalContent' , 'Page' ) ) ; $ action = 'view' ; $ this -> extend ( 'updateViewer' , $ action , $ viewer ) ; return $ this -> customise ( $ object ) -> renderWith ( $ viewer ) ; } } echo "Template not found for " . ( $ object ? get_class ( $ object ) . ' #' . $ object -> ID : '' ) ; }
Display an item .
8,083
public function download ( $ request ) { if ( $ request -> param ( 'ID' ) ) { $ object = ExternalContent :: getDataObjectFor ( $ request -> param ( 'ID' ) ) ; if ( $ object && $ object instanceof ExternalContentItem ) { $ object -> streamContent ( ) ; } } }
Called to download this content item and stream it directly to the browser
8,084
protected static function memoize ( Callable $ f ) { return function ( ... $ args ) use ( $ f ) { static $ cache ; if ( $ cache === null ) $ cache = [ ] ; $ key = serialize ( $ args ) ; if ( array_key_exists ( $ key , $ cache ) ) { return $ cache [ $ key ] ; } else { $ result = call_user_func_array ( $ f , $ args ) ; $ cache [ $ key ] = $ result ; return $ result ; } } ; }
Memoize a Function
8,085
public function read ( $ name ) { if ( substr ( $ name , 0 , 1 ) == '/' && file_exists ( $ name ) ) { return $ this -> read_file ( $ name ) ; } $ in_namespace = false ; if ( strpos ( $ name , '::' ) !== false ) { $ conf = explode ( '::' , $ name ) ; $ in_namespace = $ conf [ 0 ] ; $ name = $ conf [ 1 ] ; unset ( $ conf ) ; } $ main = $ default = array ( ) ; if ( ! $ in_namespace ) { $ core_conf = $ this -> path ( CCCORE_NAMESPACE . '::' . $ name , true ) ; $ app_conf = $ this -> path ( $ name , true ) ; if ( file_exists ( $ core_conf ) ) { $ default = $ this -> read_file ( $ core_conf ) ; } if ( file_exists ( $ app_conf ) ) { $ main = $ this -> read_file ( $ app_conf ) ; } } elseif ( $ in_namespace ) { $ main_conf = $ this -> path ( $ in_namespace . '::' . $ name , true ) ; $ app_conf = $ this -> path ( $ name , true ) ; if ( file_exists ( $ main_conf ) ) { $ default = $ this -> read_file ( $ main_conf ) ; } if ( file_exists ( $ app_conf ) ) { $ main = $ this -> read_file ( $ app_conf ) ; } } return CCArr :: merge ( $ default , $ main ) ; }
Read the configuration data Get the configuration data and return them as array
8,086
public function write ( $ file , $ data ) { if ( substr ( $ file , 0 , 1 ) == '/' ) { return $ this -> write_file ( $ file , $ data ) ; } $ this -> write_file ( $ this -> path ( $ file ) , $ data ) ; }
Write the configuration data
8,087
public function delete ( $ file ) { if ( substr ( $ file , 0 , 1 ) == '/' ) { return CCFile :: delete ( $ file ) ; } return CCFile :: delete ( $ this -> path ( $ file ) ) ; }
delete the configuration data
8,088
protected function path ( $ name , $ env = false ) { $ conf = CCPath :: get ( $ name , \ CCDIR_CONFIG , static :: EXT ) ; if ( ! $ env ) { return $ conf ; } $ env_conf = CCPath :: get ( $ name , \ CCDIR_CONFIG . ClanCats :: environment ( ) . '/' , static :: EXT ) ; if ( file_exists ( $ env_conf ) ) { return $ env_conf ; } return $ conf ; }
generates a path for a config name
8,089
public function add ( string $ name , callable $ callback ) : self { if ( $ this -> exists ( $ name ) ) { throw new LogicException ( 'The helper function name "' . $ name . '" is already registered.' ) ; } $ this -> helpers [ $ name ] = $ callback ; return $ this ; }
Add a new template function .
8,090
public function remove ( string $ name ) : self { if ( ! $ this -> exists ( $ name ) ) { throw new LogicException ( 'The template function "' . $ name . '" was not found.' ) ; } unset ( $ this -> helpers [ $ name ] ) ; return $ this ; }
Remove a template function .
8,091
public function isRoleScopePresentOnce ( ExecutionContextInterface $ context ) { $ roleScopesId = array_map ( function ( RoleScope $ roleScope ) { return $ roleScope -> getId ( ) ; } , $ this -> getRoleScopes ( ) -> toArray ( ) ) ; $ countedIds = array_count_values ( $ roleScopesId ) ; foreach ( $ countedIds as $ id => $ nb ) { if ( $ nb > 1 ) { $ context -> buildViolation ( "A permission is already present " . "for the same role and scope" ) -> addViolation ( ) ; } } }
Test that a role scope is associated only once with the permission group
8,092
protected static function macro_og ( $ tags , $ content = null ) { if ( ! is_array ( $ tags ) ) { $ tags = array ( $ tags => $ content ) ; } $ buffer = "" ; foreach ( $ tags as $ key => $ content ) { $ buffer .= '<meta property="og:' . $ key . '" content="' . $ content . '" />' ; } return $ buffer ; }
OG Macro - Generates open grapth tags
8,093
public static function uri ( $ uri , $ name = null ) { if ( strpos ( $ uri , '://' ) === false ) { if ( substr ( $ uri , 0 , 1 ) != '/' ) { $ uri = CCUrl :: to ( static :: holder ( $ name ) -> path . $ uri ) ; } else { $ uri = CCUrl :: to ( substr ( $ uri , 1 ) ) ; } } return $ uri ; }
Get the uri to an asset
8,094
public static function holder ( $ name = null ) { if ( ! isset ( $ name ) ) { $ name = static :: $ _default ; } if ( ! isset ( static :: $ instances [ $ name ] ) ) { static :: $ instances [ $ name ] = new CCAsset_Holder ( ) ; } return static :: $ instances [ $ name ] ; }
Get an asset holder instance .
8,095
public static function code ( $ type , $ name = null ) { $ buffer = "" ; foreach ( static :: holder ( $ name ) -> get ( $ type ) as $ item ) { $ buffer .= call_user_func ( array ( '\\CCAsset' , $ type ) , $ item , $ name ) ; } return $ buffer ; }
Get all assets of a specific type in a holder and run them trough the maching macros .
8,096
public function add ( Task $ task ) : void { $ this -> index ++ ; Util :: put ( $ this -> storage ( ) . $ this -> index . '.queue' , serialize ( $ task ) ) ; $ this -> updateIterator ( ) ; Util :: put ( $ this -> storage ( ) . '_index' , $ this -> index ) ; }
Add new task to queue top
8,097
public function pop ( int $ num ) : Collection { $ ret = new Collection ( ) ; foreach ( $ this -> iterator as $ item ) { if ( ! $ num -- ) return $ ret ; $ ret [ ] = unserialize ( file_get_contents ( $ item ) ) ; unlink ( $ item ) ; } $ this -> updateIterator ( ) ; return $ ret ; }
Get the oldest items from the queue
8,098
public static function getValueSet ( $ colname ) { $ valueSets = RemoteAppPeer :: getValueSets ( ) ; if ( ! isset ( $ valueSets [ $ colname ] ) ) { throw new PropelException ( sprintf ( 'Column "%s" has no ValueSet.' , $ colname ) ) ; } return $ valueSets [ $ colname ] ; }
Gets the list of values for an ENUM column
8,099
public static function getSqlValueForEnum ( $ colname , $ enumVal ) { $ values = RemoteAppPeer :: getValueSet ( $ colname ) ; if ( ! in_array ( $ enumVal , $ values ) ) { throw new PropelException ( sprintf ( 'Value "%s" is not accepted in this enumerated column' , $ colname ) ) ; } return array_search ( $ enumVal , $ values ) ; }
Gets the SQL value for the ENUM column value