idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
46,400
|
public function getId ( ) { $ current = $ this -> model -> get ( 'asset_id' , null ) ; $ parentId = $ this -> getAssetParentId ( ) ; $ name = $ this -> getAssetName ( ) ; $ title = $ this -> getAssetTitle ( ) ; $ title = $ title ? : $ name ; $ asset = Model :: oneByName ( $ name ) ; $ this -> model -> set ( 'asset_id' , $ asset -> get ( 'id' ) ) ; $ asset -> set ( 'parent_id' , $ parentId ) ; $ asset -> set ( 'name' , $ name ) ; $ asset -> set ( 'title' , $ title ) ; if ( $ this -> model -> assetRules instanceof \ JAccessRules || $ this -> model -> assetRules instanceof \ Hubzero \ Access \ Rules ) { $ asset -> set ( 'rules' , ( string ) $ this -> model -> assetRules ) ; } if ( ! $ this -> model -> get ( 'asset_id' , null ) || $ asset -> parent_id != $ parentId ) { $ parent = Model :: one ( $ parentId ) ; if ( ! $ asset -> saveAsLastChildOf ( $ parent ) ) { return false ; } } elseif ( ! $ asset -> save ( ) ) { return false ; } if ( $ this -> model -> isNew ( ) ) { $ me = $ this ; \ Event :: listen ( function ( $ event ) use ( $ asset , $ me ) { $ asset -> set ( 'name' , $ me -> getAssetName ( ) ) ; $ asset -> save ( ) ; } , $ this -> model -> getTableName ( ) . '_new' ) ; } return ( int ) $ asset -> get ( 'id' ) ; }
|
Gets the asset id for the object instance
|
46,401
|
public function delete ( ) { $ asset = Model :: oneByName ( $ this -> getAssetName ( ) ) ; if ( $ asset -> get ( 'id' ) ) { if ( ! $ asset -> destroy ( ) ) { return false ; } } return true ; }
|
Deletes the current asset entry
|
46,402
|
private function getAssetParentId ( ) { $ assetId = null ; $ asset = Model :: oneByName ( 'com_' . $ this -> model -> getNamespace ( ) ) ; if ( $ asset -> get ( 'id' ) ) { $ assetId = ( int ) $ asset -> get ( 'id' ) ; } return ( $ assetId ) ? $ assetId : $ this -> getRootId ( ) ; }
|
Gets the parent asset id for the record
|
46,403
|
public function toArray ( ) { $ result = array ( ) ; $ cvars = get_class_vars ( __CLASS__ ) ; foreach ( $ cvars as $ key => $ value ) { if ( $ key { 0 } == '_' ) { continue ; } $ current = $ this -> __get ( $ key ) ; $ result [ $ key ] = $ current ; } return $ result ; }
|
Output data as an array
|
46,404
|
public function find ( $ name ) { $ hztp = new self ( ) ; if ( is_numeric ( $ name ) ) { $ hztp -> id = $ name ; } else { $ hztp -> name = $ name ; } if ( $ hztp -> read ( ) == false ) { return false ; } return $ hztp ; }
|
Find a project
|
46,405
|
public static function find_or_create ( $ name ) { $ hztp = new self ( ) ; if ( is_numeric ( $ name ) ) { $ hztp -> id = $ name ; } else { $ hztp -> name = $ name ; } if ( $ hztp -> read ( ) == false ) { if ( $ hztp -> create ( ) == false ) { return false ; } } return $ hztp ; }
|
Find a project . Create it if one doesn t exist .
|
46,406
|
public function __isset ( $ property = null ) { if ( ! property_exists ( __CLASS__ , $ property ) || $ property { 0 } == '_' ) { if ( empty ( $ property ) ) { $ property = '(null)' ; } $ this -> _error ( "Cannot access property " . __CLASS__ . "::$" . $ property , E_USER_ERROR ) ; die ( ) ; } return isset ( $ this -> $ property ) ; }
|
Check if a property is set
|
46,407
|
private function _error ( $ message , $ level = E_USER_NOTICE ) { $ caller = next ( debug_backtrace ( ) ) ; switch ( $ level ) { case E_USER_NOTICE : echo "Notice: " ; break ; case E_USER_ERROR : echo "Fatal error: " ; break ; default : echo "Unknown error: " ; break ; } echo $ message . ' in ' . $ caller [ 'file' ] . ' on line ' . $ caller [ 'line' ] . "\n" ; }
|
Echo an error message
|
46,408
|
public function add_user_permission ( $ user , $ action ) { $ db = \ App :: get ( 'db' ) ; if ( $ user == 'anonymous' ) { $ user = '0' ; } if ( ! is_numeric ( $ user ) ) { $ query = "SELECT id FROM `#__users` WHERE username=" . $ db -> quote ( $ user ) . ";" ; $ db -> setQuery ( $ query ) ; $ user_id = $ db -> loadResult ( ) ; if ( $ user_id === false ) { $ this -> _error ( "Unknown user $user" ) ; return false ; } } else { $ user_id = $ user ; } $ quoted_project_id = $ db -> quote ( $ this -> id ) ; $ quoted_user_id = $ db -> quote ( $ user_id ) ; $ values = '' ; foreach ( ( array ) $ action as $ a ) { if ( ! empty ( $ values ) ) { $ values .= ',' ; } $ values .= "($quoted_project_id,$quoted_user_id," . $ db -> quote ( $ a ) . ")" ; } $ query = "INSERT IGNORE INTO `#__trac_user_permission` (trac_project_id,user_id,action) VALUES " . $ values . ";" ; $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; }
|
Add permission to a user
|
46,409
|
public function remove_group_permission ( $ group , $ action ) { $ db = \ App :: get ( 'db' ) ; $ all = false ; if ( $ group == 'authenticated' ) { $ group = '0' ; } if ( ! is_numeric ( $ group ) ) { $ query = "SELECT gidNumber FROM `#__xgroups` WHERE cn=" . $ db -> quote ( $ group ) . ";" ; $ db -> setQuery ( $ query ) ; $ group_id = $ db -> loadResult ( ) ; if ( $ group_id === null ) { $ this -> _error ( "Unknown group $group" ) ; return false ; } } $ quoted_project_id = $ db -> quote ( $ this -> id ) ; $ quoted_group_id = $ db -> quote ( $ group_id ) ; $ values = '' ; foreach ( ( array ) $ action as $ a ) { if ( $ a == '*' ) { $ all = true ; } if ( ! empty ( $ values ) ) { $ values .= ',' ; } $ values .= $ db -> quote ( $ a ) ; } $ query = "DELETE FROM `#__trac_group_permission` WHERE trac_project_id=$quoted_project_id AND group_id=$quoted_group_id" ; if ( ! $ all ) { $ query .= " AND action IN (" . $ values . ");" ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; }
|
Remove permission form a group
|
46,410
|
public function get_user_permission ( $ user ) { $ db = \ App :: get ( 'db' ) ; $ quoted_project_id = $ db -> quote ( $ this -> id ) ; if ( $ user == "anonymous" ) { $ user = '0' ; } $ quoted_user = $ db -> quote ( $ user ) ; if ( is_numeric ( $ user ) ) { $ query = "SELECT action FROM `#__trac_user_permission` AS up WHERE up.trac_project_id=$quoted_project_id AND up.user_id=$quoted_user;" ; } else { $ query = "SELECT action FROM `#__trac_user_permission` AS up, `#__users` AS u WHERE up.trac_project_id=$quoted_project_id AND u.id=up.user_id AND u.username=$quoted_user;" ; } $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; return $ result ; }
|
Get permissions for a user
|
46,411
|
public function get_group_permission ( $ group ) { $ db = \ App :: get ( 'db' ) ; $ quoted_project_id = $ db -> quote ( $ this -> id ) ; if ( $ group == 'authenticated' ) { $ group = '0' ; } $ quoted_group = $ db -> quote ( $ group ) ; if ( is_numeric ( $ group ) ) { $ query = "SELECT action FROM `#__trac_group_permission` AS gp WHERE gp.trac_project_id=$quoted_project_id AND gp.group_id=$quoted_group;" ; } else { $ query = "SELECT action FROM `#__trac_group_permission` AS gp, `#__xgroups` AS g WHERE gp.trac_project_id=$quoted_project_id AND g.gidNumber=gp.group_id AND g.cn=$quoted_group;" ; } $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; return $ result ; }
|
Get permissions for a group
|
46,412
|
public static function getInstance ( $ editor = 'none' ) { $ signature = serialize ( $ editor ) ; if ( empty ( self :: $ instances [ $ signature ] ) ) { self :: $ instances [ $ signature ] = new self ( $ editor ) ; } return self :: $ instances [ $ signature ] ; }
|
Returns the global Editor object only creating it if it doesn t already exist .
|
46,413
|
public function initialise ( ) { if ( is_null ( $ this -> editor ) ) { return ; } $ return = '' ; $ results [ ] = $ this -> editor -> onInit ( ) ; foreach ( $ results as $ result ) { if ( trim ( $ result ) ) { $ return = $ result ; } } $ document = \ App :: get ( 'document' ) ; if ( $ document -> getType ( ) != 'html' ) { return ; } $ document -> addCustomTag ( $ return ) ; }
|
Initialise the editor
|
46,414
|
public function display ( $ name , $ html , $ width , $ height , $ col , $ row , $ buttons = true , $ id = null , $ asset = null , $ author = null , $ params = array ( ) ) { $ this -> asset = $ asset ; $ this -> author = $ author ; $ this -> load ( $ params ) ; if ( is_null ( $ this -> editor ) ) { return ; } $ width = str_replace ( ';' , '' , $ width ) ; $ height = str_replace ( ';' , '' , $ height ) ; $ id = $ id ? : $ name ; $ return = null ; $ results [ ] = $ this -> editor -> onDisplay ( $ name , $ html , $ width , $ height , $ col , $ row , $ buttons , $ id , $ asset , $ author , $ params ) ; foreach ( $ results as $ result ) { if ( trim ( $ result ) ) { $ return .= $ result ; } } return $ return ; }
|
Display the editor area .
|
46,415
|
public function save ( $ editor ) { $ this -> load ( ) ; if ( is_null ( $ this -> editor ) ) { return ; } $ return = '' ; $ results [ ] = $ this -> editor -> onSave ( $ editor ) ; foreach ( $ results as $ result ) { if ( trim ( $ result ) ) { $ return .= $ result ; } } return $ return ; }
|
Save the editor content
|
46,416
|
public function getContent ( $ editor ) { $ this -> load ( ) ; $ return = '' ; $ results [ ] = $ this -> editor -> onGetContent ( $ editor ) ; foreach ( $ results as $ result ) { if ( trim ( $ result ) ) { $ return .= $ result ; } } return $ return ; }
|
Get the editor contents
|
46,417
|
public function setContent ( $ editor , $ html ) { $ this -> load ( ) ; $ return = '' ; $ results [ ] = $ this -> editor -> onSetContent ( $ editor , $ html ) ; foreach ( $ results as $ result ) { if ( trim ( $ result ) ) { $ return .= $ result ; } } return $ return ; }
|
Set the editor contents
|
46,418
|
protected function load ( $ config = array ( ) ) { if ( ! is_null ( $ this -> editor ) ) { return ; } $ name = ( string ) preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ this -> name ) ; $ name = ltrim ( $ name , '.' ) ; $ path = PATH_APP . '/plugins/editors/' . $ name . '/' . $ name . '.php' ; if ( ! is_file ( $ path ) ) { $ path = PATH_CORE . '/plugins/editors/' . $ name . '/' . $ name . '.php' ; if ( ! is_file ( $ path ) ) { \ Notify :: error ( Lang :: txt ( 'JLIB_HTML_EDITOR_CANNOT_LOAD' ) ) ; return false ; } } require_once $ path ; $ plugin = Plugin :: byType ( 'editors' , $ this -> name ) ; $ params = new Registry ( $ plugin -> params ) ; $ params -> merge ( $ config ) ; $ plugin -> params = $ params ; $ name = 'plgEditor' . $ this -> name ; if ( $ this -> editor = new $ name ( $ this , ( array ) $ plugin ) ) { $ this -> initialise ( ) ; Plugin :: import ( 'editors-xtd' ) ; } }
|
Load the editor
|
46,419
|
public function automaticAuthenticator ( $ data ) { $ alias = $ data [ 'authenticator' ] ; $ alias = strip_tags ( $ alias ) ; $ alias = trim ( $ alias ) ; if ( strlen ( $ alias ) > 255 ) { $ alias = substr ( $ alias . ' ' , 0 , 255 ) ; $ alias = substr ( $ alias , 0 , strrpos ( $ alias , ' ' ) ) ; } return preg_replace ( "/[^a-zA-Z0-9]/" , '' , strtolower ( $ alias ) ) ; }
|
Generates automatic authenticator field value
|
46,420
|
public static function getInstance ( $ type , $ authenticator , $ domain ) { $ query = self :: all ( ) -> whereEquals ( 'type' , $ type ) -> whereEquals ( 'authenticator' , $ authenticator ) ; if ( $ domain ) { $ query -> whereEquals ( 'domain' , $ domain ) ; } $ row = $ query -> row ( ) ; if ( ! $ row || ! $ row -> get ( 'id' ) ) { return false ; } return $ row ; }
|
Get a Domain instance
|
46,421
|
public static function find_or_create ( $ type , $ authenticator , $ domain = null ) { $ query = self :: all ( ) -> whereEquals ( 'type' , $ type ) -> whereEquals ( 'authenticator' , $ authenticator ) ; if ( $ domain ) { $ query -> whereEquals ( 'domain' , $ domain ) ; } $ row = $ query -> row ( ) ; if ( ! $ row || ! $ row -> get ( 'id' ) ) { $ row = self :: blank ( ) ; $ row -> set ( 'type' , $ type ) ; $ row -> set ( 'authenticator' , $ authenticator ) ; if ( $ domain ) { $ row -> set ( 'domain' , $ domain ) ; } $ row -> save ( ) ; } if ( ! $ row -> get ( 'id' ) ) { return false ; } return $ row ; }
|
Fine a specific record or create it if not found
|
46,422
|
public function escape ( $ var ) { if ( in_array ( $ this -> _escape , array ( 'htmlspecialchars' , 'htmlentities' ) ) ) { return call_user_func ( $ this -> _escape , $ var , ENT_COMPAT , $ this -> _charset ) ; } return call_user_func ( $ this -> _escape , $ var ) ; }
|
Escapes a value for output in a view script .
|
46,423
|
public static function locate ( $ address ) { $ ip = false ; if ( filter_var ( $ address , FILTER_VALIDATE_IP ) ) { $ ip = true ; } $ adapter = new \ Geocoder \ HttpAdapter \ CurlHttpAdapter ( ) ; $ p = array ( ) ; if ( $ providers = \ Event :: trigger ( 'geocode.onGeocodeProvider' , array ( 'geocode.locate' , $ adapter , $ ip ) ) ) { foreach ( $ providers as $ provider ) { if ( $ provider ) { $ p [ ] = $ provider ; } } } if ( ! count ( $ p ) ) { return '' ; } $ geocoder = new \ Geocoder \ Geocoder ( ) ; $ geocoder -> registerProvider ( new \ Geocoder \ Provider \ ChainProvider ( $ p ) ) ; return $ geocoder -> geocode ( $ address ) ; }
|
Geo - locate an address
|
46,424
|
public static function getGeoDBO ( ) { static $ instance ; if ( ! is_object ( $ instance ) ) { $ geodb_params = \ Component :: params ( 'com_system' ) ; $ options = array ( ) ; $ options [ 'driver' ] = $ geodb_params -> get ( 'geodb_driver' , 'pdo' ) ; $ options [ 'host' ] = $ geodb_params -> get ( 'geodb_host' , 'localhost' ) ; $ options [ 'port' ] = $ geodb_params -> get ( 'geodb_port' , '' ) ; $ options [ 'user' ] = $ geodb_params -> get ( 'geodb_user' , '' ) ; $ options [ 'password' ] = $ geodb_params -> get ( 'geodb_password' , '' ) ; $ options [ 'database' ] = $ geodb_params -> get ( 'geodb_database' , '' ) ; $ options [ 'prefix' ] = $ geodb_params -> get ( 'geodb_prefix' , '' ) ; if ( empty ( $ options [ 'database' ] ) || empty ( $ options [ 'user' ] ) || empty ( $ options [ 'password' ] ) ) { return null ; } try { $ instance = \ Hubzero \ Database \ Driver :: getInstance ( $ options ) ; } catch ( \ Exception $ e ) { $ instance = false ; } } if ( ! $ instance || ( $ instance instanceof Exception ) || ! $ instance -> getConnection ( ) ) { return null ; } return $ instance ; }
|
Get the geo database
|
46,425
|
public static function getCountriesByContinent ( $ continent = '' ) { if ( ! $ continent || ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return array ( ) ; } $ gdb -> setQuery ( "SELECT DISTINCT country FROM country_continent WHERE LOWER(continent) =" . $ gdb -> quote ( strtolower ( $ continent ) ) ) ; return $ gdb -> loadColumn ( ) ; }
|
Get a list of countries by continent
|
46,426
|
public static function getContinentByCountry ( $ country = '' ) { if ( ! $ country || ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return array ( ) ; } $ gdb -> setQuery ( "SELECT DISTINCT continent FROM country_continent WHERE LOWER(country) ='" . strtolower ( $ country ) . "'" ) ; return $ gdb -> loadColumn ( ) ; }
|
Get continent by the country
|
46,427
|
public static function getCodesByNames ( $ names = array ( ) ) { if ( ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return array ( ) ; } $ names = array_map ( 'strtolower' , $ names ) ; foreach ( $ names as $ k => $ name ) { $ names [ $ k ] = $ gdb -> quote ( $ name ) ; } $ gdb -> setQuery ( "SELECT DISTINCT name, code FROM countries WHERE LOWER(name) IN (" . implode ( "," , $ names ) . ")" ) ; $ values = $ gdb -> loadAssocList ( 'name' ) ; if ( ! is_array ( $ values ) ) { $ values = array ( ) ; } return $ values ; }
|
Get a list of country codes by names
|
46,428
|
public static function ipcountry ( $ ip = '' ) { $ country = '' ; if ( $ ip ) { if ( ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return $ country ; } $ sql = "SELECT LOWER(countrySHORT) FROM ipcountry WHERE ipFROM <= INET_ATON(" . $ gdb -> quote ( $ ip ) . ") AND ipTO >= INET_ATON(" . $ gdb -> quote ( $ ip ) . ")" ; $ gdb -> setQuery ( $ sql ) ; $ country = stripslashes ( $ gdb -> loadResult ( ) ) ; } return $ country ; }
|
Get the country based on IP address
|
46,429
|
public static function is_d1nation ( $ country ) { $ d1nation = false ; if ( $ country ) { if ( ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return $ d1nation ; } $ gdb -> setQuery ( "SELECT COUNT(*) FROM countrygroup WHERE LOWER(countrycode) = LOWER(" . $ gdb -> quote ( $ country ) . ") AND countrygroup = 'D1'" ) ; $ c = $ gdb -> loadResult ( ) ; if ( $ c > 0 ) { $ d1nation = true ; } } return $ d1nation ; }
|
Is a country an D1 nation?
|
46,430
|
public static function is_e1nation ( $ country ) { $ e1nation = false ; if ( $ country ) { if ( ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return $ e1nation ; } $ gdb -> setQuery ( "SELECT COUNT(*) FROM countrygroup WHERE LOWER(countrycode) = LOWER(" . $ gdb -> quote ( $ country ) . ") AND countrygroup = 'E1'" ) ; $ c = $ gdb -> loadResult ( ) ; if ( $ c > 0 ) { $ e1nation = true ; } } return $ e1nation ; }
|
Is a country an E1 nation?
|
46,431
|
public static function is_iplocation ( $ ip , $ location ) { $ iplocation = false ; if ( $ ip && $ location ) { if ( ! ( $ gdb = self :: getGeoDBO ( ) ) ) { return $ iplocation ; } $ sql = "SELECT COUNT(*) FROM iplocation WHERE ipfrom <= INET_ATON(" . $ gdb -> quote ( $ ip ) . ") AND ipto >= INET_ATON(" . $ gdb -> quote ( $ ip ) . ") AND LOWER(location) = LOWER(" . $ gdb -> quote ( $ location ) . ")" ; $ gdb -> setQuery ( $ sql ) ; $ c = $ gdb -> loadResult ( ) ; if ( $ c > 0 ) { $ iplocation = true ; } } return $ iplocation ; }
|
Check if an IP is in a certain location
|
46,432
|
public function incrementSpamCount ( ) { $ current = $ this -> get ( 'spam_count' , 0 ) ; $ this -> set ( 'spam_count' , ( $ current + 1 ) ) ; $ this -> set ( 'user_id' , \ User :: get ( 'id' ) ) ; $ this -> save ( ) ; $ current = Session :: get ( 'spam_count' , 0 ) ; Session :: set ( 'spam_count' , ( $ current + 1 ) ) ; }
|
Increments user spam count both globally and in current session
|
46,433
|
public function isJailed ( ) { if ( $ this -> get ( 'user_id' , false ) ) { $ params = Plugin :: params ( 'system' , 'spamjail' ) ; $ sessionCount = $ params -> get ( 'session_count' , 5 ) ; $ lifetimeCount = $ params -> get ( 'user_count' , 10 ) ; if ( Session :: get ( 'spam_count' , 0 ) > $ sessionCount || $ this -> get ( 'spam_count' , 0 ) > $ lifetimeCount ) { return true ; } } return false ; }
|
Checks to see if user is jailed
|
46,434
|
public function getRecords ( $ filters = array ( ) ) { $ entries = self :: all ( ) ; $ c = $ entries -> getTableName ( ) ; $ e = '#__extensions' ; $ entries -> select ( $ c . '.*,' . $ e . '.name' ) -> join ( $ e , $ e . '.element' , $ c . '.component' , 'inner' ) -> whereEquals ( $ e . '.type' , 'component' ) ; if ( isset ( $ filters [ 'component' ] ) && $ filters [ 'component' ] ) { $ entries -> whereEquals ( $ e . '.element' , $ filters [ 'component' ] ) ; } return $ entries -> ordered ( $ c . '.component' , 'asc' ) -> rows ( ) ; }
|
Defines a belongs to one relationship between newsletter and story
|
46,435
|
public function rebuild ( $ parent_id = 0 , $ left = 0 ) { $ children = self :: all ( ) -> select ( 'id' ) -> whereEquals ( 'parent_id' , ( int ) $ parent_id ) -> order ( 'parent_id' , 'asc' ) -> rows ( ) ; $ right = $ left + 1 ; foreach ( $ children as $ child ) { $ right = $ this -> rebuild ( $ child -> get ( 'id' ) , $ right ) ; if ( $ right === false ) { return false ; } } $ query = $ this -> getQuery ( ) -> update ( $ this -> getTableName ( ) ) -> set ( array ( 'lft' => ( int ) $ left , 'rgt' => ( int ) $ right ) ) -> whereEquals ( 'id' , ( int ) $ parent_id ) ; if ( ! $ query -> execute ( ) ) { return false ; } return $ right + 1 ; }
|
Method to recursively rebuild the nested set tree .
|
46,436
|
public static function syncAllGroups ( ) { $ db = \ App :: get ( 'db' ) ; $ query = "SELECT gidNumber FROM `#__xgroups`;" ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; if ( $ result === false ) { return false ; } foreach ( $ result as $ row ) { self :: syncGroup ( $ row ) ; if ( is_array ( self :: $ errors [ 'fatal' ] ) && ! empty ( self :: $ errors [ 'fatal' ] [ 0 ] ) ) { return self :: $ errors ; } } if ( ! empty ( self :: $ errors [ 'fatal' ] [ 0 ] ) || ! empty ( self :: $ errors [ 'warning' ] [ 0 ] ) ) { return self :: $ errors ; } else { return self :: $ success ; } }
|
Sync all groups
|
46,437
|
public static function syncAllUsers ( ) { $ db = \ App :: get ( 'db' ) ; $ query = "SELECT id FROM `#__users`;" ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadColumn ( ) ; if ( $ result === false ) { return false ; } foreach ( $ result as $ row ) { self :: syncUser ( $ row ) ; if ( is_array ( self :: $ errors [ 'fatal' ] ) && ! empty ( self :: $ errors [ 'fatal' ] [ 0 ] ) ) { return self :: $ errors ; } } if ( ! empty ( self :: $ errors [ 'fatal' ] [ 0 ] ) || ! empty ( self :: $ errors [ 'warning' ] [ 0 ] ) ) { return self :: $ errors ; } else { return self :: $ success ; } }
|
Sync all users
|
46,438
|
public function getName ( ) { if ( empty ( $ this -> _name ) ) { $ this -> _name = \ App :: get ( 'request' ) -> getCmd ( 'controller' ) ; if ( ! $ this -> _name ) { $ r = null ; if ( ! preg_match ( '/View((view)*(.*(view)?.*))$/i' , get_class ( $ this ) , $ r ) ) { throw new Exception ( 'Cannot get or parse view class name.' , 500 ) ; } if ( strpos ( $ r [ 3 ] , 'view' ) ) { throw new Exception ( 'Classname contains the substring "view" which causes problems when extracting the classname.' , 500 ) ; } $ this -> _name = strtolower ( $ r [ 3 ] ) ; } } return $ this -> _name ; }
|
Method to get the view name
|
46,439
|
public function setLayout ( $ layout ) { if ( strpos ( $ layout , ':' ) === false ) { $ this -> _layout = $ layout ; } else { $ temp = explode ( ':' , $ layout ) ; $ this -> _layout = $ temp [ 1 ] ; $ this -> _layoutTemplate = $ temp [ 0 ] ; } return $ this ; }
|
Sets the layout name to use
|
46,440
|
public function setLayoutExt ( $ value ) { if ( $ value = preg_replace ( '/[^A-Za-z0-9]/' , '' , trim ( $ value ) ) ) { $ this -> _layoutExt = $ value ; } return $ this ; }
|
Allows a different extension for the layout files to be used
|
46,441
|
protected function createFileName ( $ type , $ parts = array ( ) ) { $ filename = strtolower ( $ parts [ 'name' ] ) ; $ ext = 'php' ; if ( $ type == 'template' ) { $ ext = $ this -> _layoutExt ; } return $ filename . '.' . $ ext ; }
|
Create the filename for a resource
|
46,442
|
public function bind ( $ data ) { if ( ! ( $ this -> xml instanceof SimpleXMLElement ) ) { return false ; } if ( ! is_object ( $ data ) && ! is_array ( $ data ) ) { return false ; } if ( is_object ( $ data ) ) { if ( $ data instanceof Registry ) { $ data = $ data -> toArray ( ) ; } elseif ( $ data instanceof Obj ) { $ data = $ data -> getProperties ( ) ; } else { $ data = ( array ) $ data ; } } foreach ( $ data as $ k => $ v ) { if ( $ this -> findField ( $ k ) ) { $ this -> data -> set ( $ k , $ v ) ; } elseif ( is_object ( $ v ) || Arr :: isAssociative ( $ v ) ) { $ this -> bindLevel ( $ k , $ v ) ; } } return true ; }
|
Method to bind data to the form .
|
46,443
|
protected function bindLevel ( $ group , $ data ) { settype ( $ data , 'array' ) ; foreach ( $ data as $ k => $ v ) { if ( $ this -> findField ( $ k , $ group ) ) { $ this -> data -> set ( $ group . '.' . $ k , $ v ) ; } elseif ( is_object ( $ v ) || Arr :: isAssociative ( $ v ) ) { $ this -> bindLevel ( $ group . '.' . $ k , $ v ) ; } } }
|
Method to bind data to the form for the group level .
|
46,444
|
public function getGroup ( $ group , $ nested = false ) { $ fields = array ( ) ; $ elements = $ this -> findFieldsByGroup ( $ group , $ nested ) ; if ( empty ( $ elements ) ) { return $ fields ; } foreach ( $ elements as $ element ) { $ attrs = $ element -> xpath ( 'ancestor::fields[@name]/@name' ) ; $ groups = array_map ( 'strval' , $ attrs ? $ attrs : array ( ) ) ; $ group = implode ( '.' , $ groups ) ; if ( $ field = $ this -> loadField ( $ element , $ group ) ) { $ fields [ $ field -> id ] = $ field ; } } return $ fields ; }
|
Method to get an array of Field objects in a given field group by name .
|
46,445
|
public function getLabel ( $ name , $ group = null ) { if ( $ field = $ this -> getField ( $ name , $ group ) ) { return $ field -> label ; } return '' ; }
|
Method to get the label for a field input .
|
46,446
|
public function getValue ( $ name , $ group = null , $ default = null ) { if ( $ group ) { $ return = $ this -> data -> get ( $ group . '.' . $ name , $ default ) ; } else { $ return = $ this -> data -> get ( $ name , $ default ) ; } return $ return ; }
|
Method to get the value of a field .
|
46,447
|
public function reset ( $ xml = false ) { unset ( $ this -> data ) ; $ this -> data = new Registry ; if ( $ xml ) { unset ( $ this -> xml ) ; $ this -> xml = new SimpleXMLElement ( '<form></form>' ) ; } return true ; }
|
Method to reset the form data store and optionally the form XML definition .
|
46,448
|
public function setFields ( & $ elements , $ group = null , $ replace = true ) { if ( ! ( $ this -> xml instanceof SimpleXMLElement ) ) { return false ; } foreach ( $ elements as $ element ) { if ( ! ( $ element instanceof SimpleXMLElement ) ) { return false ; } } $ return = true ; foreach ( $ elements as $ element ) { if ( ! $ this -> setField ( $ element , $ group , $ replace ) ) { $ return = false ; } } $ this -> syncPaths ( ) ; return $ return ; }
|
Method to set some field XML elements to the form definition . If the replace flag is set then the fields will be set whether they already exists or not . If it isn t set then the fields will not be replaced if they already exist .
|
46,449
|
public function setValue ( $ name , $ group = null , $ value = null ) { if ( ! $ this -> findField ( $ name , $ group ) ) { return false ; } if ( $ group ) { $ this -> data -> set ( $ group . '.' . $ name , $ value ) ; } else { $ this -> data -> set ( $ name , $ value ) ; } return true ; }
|
Method to set the value of a field . If the field does not exist in the form then the method will return false .
|
46,450
|
public static function getXML ( $ data , $ isFile = true ) { libxml_use_internal_errors ( true ) ; if ( $ isFile ) { $ xml = simplexml_load_file ( $ data ) ; } else { $ xml = simplexml_load_string ( $ data ) ; } return $ xml ; }
|
Reads a XML file .
|
46,451
|
public function getSentMessages ( $ filters = array ( ) ) { $ entries = $ this -> buildQuery ( $ filters ) ; $ entries -> order ( $ entries -> getTableName ( ) . '.created' , 'desc' ) ; if ( isset ( $ filters [ 'limit' ] ) && $ filters [ 'limit' ] != 0 ) { $ entries -> limit ( $ filters [ 'limit' ] ) -> start ( $ filters [ 'start' ] ) ; } return $ entries -> rows ( ) ; }
|
Get sent messages
|
46,452
|
public function transformMessage ( ) { $ UrlPtrn = "[^=\"\'](https?:|mailto:|ftp:|gopher:|news:|file:)" . "([^ |\\/\"\']*\\/)*([^ |\\t\\n\\/\"\']*[A-Za-z0-9\\/?=&~_])" ; $ message = str_replace ( "\n" , "\n " , stripslashes ( $ this -> get ( 'message' ) ) ) ; $ message = preg_replace_callback ( "/$UrlPtrn/" , array ( $ this , 'autolink' ) , $ message ) ; $ message = nl2br ( $ message ) ; $ message = str_replace ( "\t" , ' ' , $ message ) ; return $ message ; }
|
Transform and prepare content
|
46,453
|
protected function autolink ( $ matches ) { $ href = $ matches [ 0 ] ; if ( substr ( $ href , 0 , 1 ) == '!' ) { return substr ( $ href , 1 ) ; } $ href = str_replace ( '"' , '' , $ href ) ; $ href = str_replace ( "'" , '' , $ href ) ; $ href = str_replace ( '”' , '' , $ href ) ; $ h = array ( 'h' , 'm' , 'f' , 'g' , 'n' ) ; if ( ! in_array ( substr ( $ href , 0 , 1 ) , $ h ) ) { $ href = substr ( $ href , 1 ) ; } $ name = trim ( $ href ) ; if ( substr ( $ name , 0 , 7 ) == 'mailto:' ) { $ name = substr ( $ name , 7 , strlen ( $ name ) ) ; $ name = Str :: obfuscate ( $ name ) ; $ href = 'mailto:' . $ name ; } $ l = sprintf ( ' <a class="ext-link" href="%s" rel="external">%s</a>' , $ href , $ name ) ; return $ l ; }
|
Auto - link mailto ftp and http strings in text
|
46,454
|
public static function values ( ) { $ pc = self :: all ( ) -> rows ( ) ; $ config = new Obj ; foreach ( $ pc as $ p ) { $ config -> set ( $ p -> get ( 'alias' ) , $ p -> get ( 'points' ) ) ; } return $ config ; }
|
Constructor Loads points configuration
|
46,455
|
public function listContents ( $ recursive = false ) { return $ this -> hasAdapterOrFail ( ) -> adapter -> listContents ( $ this -> getPath ( ) , $ recursive ) ; }
|
Lists directory contents
|
46,456
|
public function getSubDirs ( $ depth = 0 ) { $ dirs = [ ] ; $ contents = $ this -> hasAdapterOrFail ( ) -> adapter -> listContents ( $ this -> getPath ( ) , false ) ; foreach ( $ contents as $ item ) { if ( $ item -> isDir ( ) ) { $ thisDir = new stdClass ( ) ; $ thisDir -> depth = $ depth ; $ thisDir -> subdirs = $ item -> getSubDirs ( $ depth + 1 ) ; $ thisDir -> name = $ item -> getDisplayName ( ) ; $ thisDir -> path = $ item -> getPath ( ) ; $ dirs [ ] = $ thisDir ; } } return $ dirs ; }
|
Gets a list of directory objects with a depth for walking a directory structure
|
46,457
|
public function logger ( $ name = null ) { $ name = $ name ? : $ this -> getDefaultLog ( ) ; if ( ! isset ( $ this -> loggers [ $ name ] ) ) { $ this -> loggers [ $ name ] = $ this -> createLog ( $ name ) ; } return $ this -> loggers [ $ name ] ; }
|
Get a logger instance .
|
46,458
|
protected function createLog ( $ name ) { if ( isset ( $ this -> setup [ $ name ] ) ) { $ config = array_merge ( $ this -> defaults , $ this -> setup [ $ name ] ) ; if ( ! $ config [ 'path' ] ) { throw new InvalidArgumentException ( "Log path not specified for [$name]." ) ; } if ( ! $ config [ 'file' ] ) { throw new InvalidArgumentException ( "Log file name not specified for [$name]." ) ; } $ log = new Writer ( new Monolog ( $ name ) , $ config [ 'dispatcher' ] ) ; $ log -> useFiles ( $ config [ 'path' ] . DIRECTORY_SEPARATOR . $ config [ 'file' ] , $ config [ 'level' ] , $ config [ 'format' ] , $ config [ 'dateFormat' ] , $ config [ 'permissions' ] ) ; return $ log ; } throw new InvalidArgumentException ( "Log [$name] has no configuration values." ) ; }
|
Create a new log instance .
|
46,459
|
public function getHeadData ( ) { $ data = array ( ) ; $ data [ 'title' ] = $ this -> title ; $ data [ 'description' ] = $ this -> description ; $ data [ 'link' ] = $ this -> link ; $ data [ 'metaTags' ] = $ this -> _metaTags ; $ data [ 'links' ] = $ this -> _links ; $ data [ 'styleSheets' ] = $ this -> _styleSheets ; $ data [ 'style' ] = $ this -> _style ; $ data [ 'scripts' ] = $ this -> _scripts ; $ data [ 'script' ] = $ this -> _script ; $ data [ 'custom' ] = $ this -> _custom ; return $ data ; }
|
Get the HTML document head data
|
46,460
|
public function setHeadData ( $ data ) { if ( empty ( $ data ) || ! is_array ( $ data ) ) { return ; } $ this -> title = ( isset ( $ data [ 'title' ] ) && ! empty ( $ data [ 'title' ] ) ) ? $ data [ 'title' ] : $ this -> title ; $ this -> description = ( isset ( $ data [ 'description' ] ) && ! empty ( $ data [ 'description' ] ) ) ? $ data [ 'description' ] : $ this -> description ; $ this -> link = ( isset ( $ data [ 'link' ] ) && ! empty ( $ data [ 'link' ] ) ) ? $ data [ 'link' ] : $ this -> link ; $ this -> _metaTags = ( isset ( $ data [ 'metaTags' ] ) && ! empty ( $ data [ 'metaTags' ] ) ) ? $ data [ 'metaTags' ] : $ this -> _metaTags ; $ this -> _links = ( isset ( $ data [ 'links' ] ) && ! empty ( $ data [ 'links' ] ) ) ? $ data [ 'links' ] : $ this -> _links ; $ this -> _styleSheets = ( isset ( $ data [ 'styleSheets' ] ) && ! empty ( $ data [ 'styleSheets' ] ) ) ? $ data [ 'styleSheets' ] : $ this -> _styleSheets ; $ this -> _style = ( isset ( $ data [ 'style' ] ) && ! empty ( $ data [ 'style' ] ) ) ? $ data [ 'style' ] : $ this -> _style ; $ this -> _scripts = ( isset ( $ data [ 'scripts' ] ) && ! empty ( $ data [ 'scripts' ] ) ) ? $ data [ 'scripts' ] : $ this -> _scripts ; $ this -> _script = ( isset ( $ data [ 'script' ] ) && ! empty ( $ data [ 'script' ] ) ) ? $ data [ 'script' ] : $ this -> _script ; $ this -> _custom = ( isset ( $ data [ 'custom' ] ) && ! empty ( $ data [ 'custom' ] ) ) ? $ data [ 'custom' ] : $ this -> _custom ; return $ this ; }
|
Set the HTML document head data
|
46,461
|
public function getBuffer ( $ type = null , $ name = null , $ attribs = array ( ) ) { if ( $ type === null ) { return parent :: $ _buffer ; } $ result = null ; if ( isset ( parent :: $ _buffer [ $ type ] [ $ name ] ) ) { return parent :: $ _buffer [ $ type ] [ $ name ] ; } if ( $ result === false ) { return null ; } $ renderer = $ this -> loadRenderer ( $ type ) ; $ this -> setBuffer ( $ renderer -> render ( $ name , $ attribs , $ result ) , $ type , $ name ) ; return parent :: $ _buffer [ $ type ] [ $ name ] ; }
|
Get the contents of a document include
|
46,462
|
public function setBuffer ( $ content , $ options = array ( ) ) { if ( func_num_args ( ) > 1 && ! is_array ( $ options ) ) { $ args = func_get_args ( ) ; $ options = array ( ) ; $ options [ 'type' ] = $ args [ 1 ] ; $ options [ 'name' ] = ( isset ( $ args [ 2 ] ) ) ? $ args [ 2 ] : null ; } parent :: $ _buffer [ $ options [ 'type' ] ] [ $ options [ 'name' ] ] = $ content ; return $ this ; }
|
Set the contents a document includes
|
46,463
|
public function countMenuChildren ( ) { static $ children ; if ( ! isset ( $ children ) ) { $ menu = \ App :: get ( 'menu' ) ; $ active = $ menu -> getActive ( ) ; if ( $ active ) { $ dbo = \ App :: get ( 'db' ) ; $ query = $ dbo -> getQuery ( ) ; $ query -> select ( 'id' , null , true ) -> from ( '#__menu' ) -> whereEquals ( 'parent_id' , $ active -> id ) -> whereEquals ( 'published' , '1' ) ; $ dbo -> setQuery ( $ query -> toString ( ) ) ; $ children = $ dbo -> loadResult ( ) ; } else { $ children = 0 ; } } return $ children ; }
|
Count the number of child menu items
|
46,464
|
protected function _fetchTemplate ( $ params = array ( ) ) { $ directory = isset ( $ params [ 'directory' ] ) ? $ params [ 'directory' ] : PATH_CORE . '/templates' ; $ template = isset ( $ params [ 'template' ] ) ? preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ params [ 'template' ] ) : 'system' ; $ file = isset ( $ params [ 'file' ] ) ? preg_replace ( '/[^A-Z0-9_\.-]/i' , '' , $ params [ 'file' ] ) : 'index.php' ; if ( ! file_exists ( $ directory . DS . $ template . DS . $ file ) ) { $ directory = PATH_CORE . '/templates' ; $ template = 'system' ; $ params [ 'baseurl' ] = str_replace ( '/app' , '/core' , $ params [ 'baseurl' ] ) ; } $ lang = \ App :: get ( 'language' ) ; $ lang -> load ( 'tpl_' . $ template , PATH_APP . DS . 'bootstrap' . DS . \ App :: get ( 'client' ) -> name , null , false , true ) || $ lang -> load ( 'tpl_' . $ template , $ directory . DS . $ template , null , false , true ) ; $ this -> template = $ template ; $ this -> baseurl = isset ( $ params [ 'baseurl' ] ) ? $ params [ 'baseurl' ] : rtrim ( \ Request :: root ( true ) , '/' ) ; $ this -> params = isset ( $ params [ 'params' ] ) ? $ params [ 'params' ] : new Registry ; $ this -> _template = $ this -> _loadTemplate ( $ directory . DS . $ template , $ file ) ; return $ this ; }
|
Fetch the template and initialise the params
|
46,465
|
protected function _parseTemplate ( ) { $ matches = array ( ) ; if ( preg_match_all ( '#<jdoc:include\ type="([^"]+)" (.*)\/>#iU' , $ this -> _template , $ matches ) ) { $ template_tags_first = array ( ) ; $ template_tags_last = array ( ) ; for ( $ i = count ( $ matches [ 0 ] ) - 1 ; $ i >= 0 ; $ i -- ) { $ type = $ matches [ 1 ] [ $ i ] ; $ attribs = empty ( $ matches [ 2 ] [ $ i ] ) ? array ( ) : $ this -> parseAttributes ( $ matches [ 2 ] [ $ i ] ) ; $ name = isset ( $ attribs [ 'name' ] ) ? $ attribs [ 'name' ] : null ; if ( $ type == 'module' || $ type == 'modules' ) { $ template_tags_first [ $ matches [ 0 ] [ $ i ] ] = array ( 'type' => $ type , 'name' => $ name , 'attribs' => $ attribs ) ; } else { $ template_tags_last [ $ matches [ 0 ] [ $ i ] ] = array ( 'type' => $ type , 'name' => $ name , 'attribs' => $ attribs ) ; } } $ template_tags_last = array_reverse ( $ template_tags_last ) ; $ this -> _template_tags = $ template_tags_first + $ template_tags_last ; } return $ this ; }
|
Parse a document template
|
46,466
|
protected function _renderTemplate ( ) { $ replace = array ( ) ; $ with = array ( ) ; foreach ( $ this -> _template_tags as $ jdoc => $ args ) { $ replace [ ] = $ jdoc ; $ with [ ] = $ this -> getBuffer ( $ args [ 'type' ] , $ args [ 'name' ] , $ args [ 'attribs' ] ) ; } return str_replace ( $ replace , $ with , $ this -> _template ) ; }
|
Render pre - parsed template
|
46,467
|
public function through ( $ layers ) { $ this -> layers = array_merge ( $ this -> layers , $ layers ) ; $ this -> layers = array_values ( array_reverse ( $ this -> layers ) ) ; return $ this ; }
|
Set layers on stack
|
46,468
|
public function next ( Request $ request ) { $ this -> position ++ ; $ layer = $ this -> layers [ $ this -> position ] ; return $ layer -> handle ( $ request ) ; }
|
Call next layer in stack
|
46,469
|
public static function publishedOptions ( $ config = array ( ) ) { $ options = array ( ) ; if ( ! array_key_exists ( 'published' , $ config ) || $ config [ 'published' ] ) { $ options [ ] = Select :: option ( '1' , 'JPUBLISHED' ) ; } if ( ! array_key_exists ( 'unpublished' , $ config ) || $ config [ 'unpublished' ] ) { $ options [ ] = Select :: option ( '0' , 'JUNPUBLISHED' ) ; } if ( ! array_key_exists ( 'archived' , $ config ) || $ config [ 'archived' ] ) { $ options [ ] = Select :: option ( '2' , 'JARCHIVED' ) ; } if ( ! array_key_exists ( 'trash' , $ config ) || $ config [ 'trash' ] ) { $ options [ ] = Select :: option ( '-2' , 'JTRASHED' ) ; } if ( ! array_key_exists ( 'all' , $ config ) || $ config [ 'all' ] ) { $ options [ ] = Select :: option ( '*' , 'JALL' ) ; } return $ options ; }
|
Returns an array of standard published state filter options .
|
46,470
|
protected static function _checkedOut ( & $ row , $ tooltip = 1 ) { $ hover = '<span class="checkedout">' ; if ( $ tooltip && isset ( $ row -> checked_out_time ) ) { $ text = addslashes ( htmlspecialchars ( $ row -> editor , ENT_COMPAT , 'UTF-8' ) ) ; $ date = with ( new Date ( $ row -> checked_out_time ) ) -> toLocal ( Lang :: txt ( 'DATE_FORMAT_LC1' ) ) ; $ time = with ( new Date ( $ row -> checked_out_time ) ) -> toLocal ( 'H:i' ) ; $ hover = '<span class="editlinktip hasTip" title="' . Lang :: txt ( 'JLIB_HTML_CHECKED_OUT' ) . '::' . $ text . '<br />' . $ date . '<br />' . $ time . '">' ; } return $ hover . Lang :: txt ( 'JLIB_HTML_CHECKED_OUT' ) . '</span>' ; }
|
Method to create a checked out icon with optional overlib in a grid .
|
46,471
|
public static function checkedout ( $ i , $ editorName , $ time , $ prefix = '' , $ enabled = false , $ checkbox = 'cb' ) { if ( is_array ( $ prefix ) ) { $ options = $ prefix ; $ enabled = array_key_exists ( 'enabled' , $ options ) ? $ options [ 'enabled' ] : $ enabled ; $ checkbox = array_key_exists ( 'checkbox' , $ options ) ? $ options [ 'checkbox' ] : $ checkbox ; $ prefix = array_key_exists ( 'prefix' , $ options ) ? $ options [ 'prefix' ] : '' ; } $ text = addslashes ( htmlspecialchars ( $ editorName , ENT_COMPAT , 'UTF-8' ) ) ; $ date = addslashes ( htmlspecialchars ( with ( new Date ( $ time ) ) -> toLocal ( Lang :: txt ( 'DATE_FORMAT_LC' ) ) , ENT_COMPAT , 'UTF-8' ) ) ; $ time = addslashes ( htmlspecialchars ( with ( new Date ( $ time ) ) -> toLocal ( 'H:i' ) , ENT_COMPAT , 'UTF-8' ) ) ; $ active_title = Lang :: txt ( 'JLIB_HTML_CHECKIN' ) . '::' . $ text . '<br />' . $ date . '<br />' . $ time ; $ inactive_title = Lang :: txt ( 'JLIB_HTML_CHECKED_OUT' ) . '::' . $ text . '<br />' . $ date . '<br />' . $ time ; return self :: action ( $ i , 'checkin' , $ prefix , Lang :: txt ( 'JLIB_HTML_CHECKED_OUT' ) , $ active_title , $ inactive_title , true , 'checkedout' , 'checkedout' , $ enabled , false , $ checkbox ) ; }
|
Returns a checked - out icon
|
46,472
|
public static function state ( $ states , $ value , $ i , $ prefix = '' , $ enabled = true , $ translate = true , $ checkbox = 'cb' ) { if ( is_array ( $ prefix ) ) { $ options = $ prefix ; $ enabled = array_key_exists ( 'enabled' , $ options ) ? $ options [ 'enabled' ] : $ enabled ; $ translate = array_key_exists ( 'translate' , $ options ) ? $ options [ 'translate' ] : $ translate ; $ checkbox = array_key_exists ( 'checkbox' , $ options ) ? $ options [ 'checkbox' ] : $ checkbox ; $ prefix = array_key_exists ( 'prefix' , $ options ) ? $ options [ 'prefix' ] : '' ; } $ state = Arr :: getValue ( $ states , ( int ) $ value , $ states [ 0 ] ) ; $ task = array_key_exists ( 'task' , $ state ) ? $ state [ 'task' ] : $ state [ 0 ] ; $ text = array_key_exists ( 'text' , $ state ) ? $ state [ 'text' ] : ( array_key_exists ( 1 , $ state ) ? $ state [ 1 ] : '' ) ; $ active_title = array_key_exists ( 'active_title' , $ state ) ? $ state [ 'active_title' ] : ( array_key_exists ( 2 , $ state ) ? $ state [ 2 ] : '' ) ; $ inactive_title = array_key_exists ( 'inactive_title' , $ state ) ? $ state [ 'inactive_title' ] : ( array_key_exists ( 3 , $ state ) ? $ state [ 3 ] : '' ) ; $ tip = array_key_exists ( 'tip' , $ state ) ? $ state [ 'tip' ] : ( array_key_exists ( 4 , $ state ) ? $ state [ 4 ] : false ) ; $ active_class = array_key_exists ( 'active_class' , $ state ) ? $ state [ 'active_class' ] : ( array_key_exists ( 5 , $ state ) ? $ state [ 5 ] : '' ) ; $ inactive_class = array_key_exists ( 'inactive_class' , $ state ) ? $ state [ 'inactive_class' ] : ( array_key_exists ( 6 , $ state ) ? $ state [ 6 ] : '' ) ; return self :: action ( $ i , $ task , $ prefix , $ text , $ active_title , $ inactive_title , $ tip , $ active_class , $ inactive_class , $ enabled , $ translate , $ checkbox ) ; }
|
Returns a state on a grid
|
46,473
|
public function setError ( $ error , $ key = null ) { if ( $ error instanceof Exception ) { $ this -> error = $ error ; return true ; } return false ; }
|
Set error object
|
46,474
|
private function rooted ( $ path ) { if ( substr ( $ path , 0 , strlen ( PATH_ROOT ) ) == PATH_ROOT ) { $ path = 'ROOT' . substr ( $ path , strlen ( PATH_ROOT ) ) ; } return $ path ; }
|
Strip root path off to shorten lines some
|
46,475
|
public function addListenerLoader ( LoaderInterface $ loader ) { if ( ! isset ( $ this -> loaders [ $ loader -> getName ( ) ] ) ) { $ this -> loaders [ $ loader -> getName ( ) ] = $ loader ; } return $ this ; }
|
Count the number of registered event .
|
46,476
|
public function removeListenerLoader ( $ loader ) { if ( $ loader instanceof LoaderInterface ) { $ loader = $ loader -> getName ( ) ; } if ( isset ( $ this -> loaders [ $ loader ] ) ) { unset ( $ this -> loaders [ $ loader ] ) ; } return $ this ; }
|
Remove a listener laoder from this dispatcher .
|
46,477
|
public function addListeners ( $ listeners , array $ events = array ( ) ) { if ( is_string ( $ listeners ) ) { $ loaded = array ( ) ; foreach ( $ this -> getListenerLoaders ( ) as $ loader ) { $ loaded += $ loader -> loadListeners ( $ listeners ) ; } $ listeners = $ loaded ; } foreach ( $ listeners as $ listener ) { if ( ! $ this -> hasListener ( $ listener ) ) { $ this -> addListener ( $ listener , $ events ) ; } } return $ this ; }
|
Add multiple listeners to this dispatcher . If a string is passed it will loop through the list of listener loaders .
|
46,478
|
public function getListenerPriority ( $ listener , $ event ) { $ event = $ this -> resolveEventName ( $ event ) ; if ( isset ( $ this -> listeners [ $ event ] ) ) { return $ this -> listeners [ $ event ] -> getPriority ( $ listener ) ; } return null ; }
|
Get the priority of the given listener for the given event .
|
46,479
|
public function getListeners ( $ event = null ) { $ event = $ this -> resolveEventName ( $ event ) ; if ( $ event ) { if ( isset ( $ this -> listeners [ $ event ] ) ) { return $ this -> listeners [ $ event ] -> getAll ( ) ; } return array ( ) ; } return $ this -> listeners ; }
|
Get the listeners registered to the given event .
|
46,480
|
public function removeListener ( $ listener , $ event = null ) { if ( $ event ) { $ event = $ this -> resolveEventName ( $ event ) ; if ( isset ( $ this -> listeners [ $ event ] ) ) { $ this -> listeners [ $ event ] -> remove ( $ listener ) ; } } else { foreach ( $ this -> listeners as $ queue ) { $ queue -> remove ( $ listener ) ; } } return $ this ; }
|
Remove the given listener from this dispatcher . If no event is specified it will be removed from all events it is listening to .
|
46,481
|
public function setDefault ( $ id , $ language = '' ) { if ( isset ( $ this -> _items [ $ id ] ) ) { $ this -> _default [ $ language ] = $ id ; return true ; } return false ; }
|
Set the default item by id and language code .
|
46,482
|
public function setActive ( $ id ) { if ( isset ( $ this -> _items [ $ id ] ) ) { $ this -> _active = $ id ; $ result = & $ this -> _items [ $ id ] ; return $ result ; } return null ; }
|
Set the default item by id
|
46,483
|
public function getActive ( ) { if ( $ this -> _active ) { $ item = & $ this -> _items [ $ this -> _active ] ; return $ item ; } return null ; }
|
Get menu item by id .
|
46,484
|
public function authorise ( $ id ) { $ menu = $ this -> getItem ( $ id ) ; if ( $ menu ) { return in_array ( ( int ) $ menu -> access , $ this -> get ( 'access' , array ( 0 ) ) ) ; } return true ; }
|
Method to check object authorization against an access control object and optionally an access extension object
|
46,485
|
public function validateRequest ( RequestInterface $ request , ResponseInterface $ response ) { if ( ! is_null ( $ request -> headers ( 'PHP_AUTH_USER' ) ) && ! is_null ( $ request -> headers ( 'PHP_AUTH_PW' ) ) ) { $ clientData = array ( 'client_id' => $ request -> headers ( 'PHP_AUTH_USER' ) , 'client_secret' => $ request -> headers ( 'PHP_AUTH_PW' ) ) ; } if ( $ this -> config [ 'allow_credentials_in_request_body' ] ) { if ( ! is_null ( $ request -> request ( 'client_id' ) ) ) { $ clientData = array ( 'client_id' => $ request -> request ( 'client_id' ) , 'client_secret' => $ request -> request ( 'client_secret' ) ) ; } } if ( ! isset ( $ clientData [ 'client_id' ] ) || $ clientData [ 'client_id' ] == '' ) { $ message = $ this -> config [ 'allow_credentials_in_request_body' ] ? ' or body' : '' ; $ response -> setError ( 400 , 'invalid_client' , 'Client credentials were not found in the headers' . $ message ) ; return false ; } if ( ! isset ( $ clientData [ 'client_secret' ] ) || $ clientData [ 'client_secret' ] == '' ) { if ( ! $ this -> config [ 'allow_public_clients' ] ) { $ response -> setError ( 400 , 'invalid_client' , 'client credentials are required' ) ; return false ; } if ( ! $ this -> storage -> isPublicClient ( $ clientData [ 'client_id' ] ) ) { $ response -> setError ( 400 , 'invalid_client' , 'This client is invalid or must authenticate using a client secret' ) ; return false ; } } elseif ( $ this -> storage -> checkClientCredentials ( $ clientData [ 'client_id' ] , $ clientData [ 'client_secret' ] ) === false ) { $ response -> setError ( 400 , 'invalid_client' , 'The client credentials are invalid' ) ; return false ; } $ this -> clientData = $ clientData ; return true ; }
|
Validate request via client
|
46,486
|
public static function level ( $ name , $ selected , $ attribs = '' , $ params = true , $ id = false ) { $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'a.id' , 'value' ) -> select ( 'a.title' , 'text' ) -> from ( '#__viewlevels' , 'a' ) -> group ( 'a.id' ) -> group ( 'a.title' ) -> group ( 'a.ordering' ) -> order ( 'a.ordering' , 'asc' ) -> order ( 'title' , 'asc' ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ options = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) , 500 , E_WARNING ) ; return null ; } if ( is_array ( $ params ) ) { $ options = array_merge ( $ params , $ options ) ; } elseif ( $ params ) { array_unshift ( $ options , Select :: option ( '' , Lang :: txt ( 'JOPTION_ACCESS_SHOW_ALL_LEVELS' ) ) ) ; } return Select :: genericlist ( $ options , $ name , array ( 'list.attr' => $ attribs , 'list.select' => $ selected , 'id' => $ id ) ) ; }
|
Displays a list of the available access view levels
|
46,487
|
public static function usergroup ( $ name , $ selected , $ attribs = '' , $ allowAll = true ) { $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'a.id' , 'value' ) -> select ( 'a.title' , 'text' ) -> select ( 'COUNT(DISTINCT b.id)' , 'level' ) -> from ( '#__usergroups' , 'a' ) -> joinRaw ( '#__usergroups AS b' , 'a.lft > b.lft AND a.rgt < b.rgt' , 'left' ) -> group ( 'a.id' ) -> group ( 'a.title' ) -> group ( 'a.lft' ) -> group ( 'a.rgt' ) -> order ( 'a.lft' , 'asc' ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ options = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) , 500 , E_WARNING ) ; return null ; } for ( $ i = 0 , $ n = count ( $ options ) ; $ i < $ n ; $ i ++ ) { $ options [ $ i ] -> text = str_repeat ( '- ' , $ options [ $ i ] -> level ) . $ options [ $ i ] -> text ; } if ( $ allowAll ) { array_unshift ( $ options , Select :: option ( '' , Lang :: txt ( 'JOPTION_ACCESS_SHOW_ALL_GROUPS' ) ) ) ; } return Select :: genericlist ( $ options , $ name , array ( 'list.attr' => $ attribs , 'list.select' => $ selected ) ) ; }
|
Displays a list of the available user groups .
|
46,488
|
public static function usergroups ( $ name , $ selected , $ checkSuperAdmin = false ) { static $ count ; $ count ++ ; $ isSuperAdmin = \ User :: authorise ( 'core.admin' ) ; $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'a.*' ) -> select ( 'COUNT(DISTINCT b.id)' , 'level' ) -> from ( '#__usergroups' , 'a' ) -> joinRaw ( '#__usergroups AS b' , 'a.lft > b.lft AND a.rgt < b.rgt' , 'left' ) -> group ( 'a.id' ) -> group ( 'a.title' ) -> group ( 'a.lft' ) -> group ( 'a.rgt' ) -> group ( 'a.parent_id' ) -> order ( 'a.lft' , 'asc' ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ groups = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) , 500 , E_WARNING ) ; return null ; } $ html = array ( ) ; $ html [ ] = '<ul class="checklist usergroups">' ; for ( $ i = 0 , $ n = count ( $ groups ) ; $ i < $ n ; $ i ++ ) { $ item = & $ groups [ $ i ] ; if ( ( ! $ checkSuperAdmin ) || $ isSuperAdmin || ( ! \ Hubzero \ Access \ Access :: checkGroup ( $ item -> id , 'core.admin' ) ) ) { $ eid = $ count . 'group_' . $ item -> id ; $ checked = '' ; if ( $ selected ) { $ checked = in_array ( $ item -> id , $ selected ) ? ' checked="checked"' : '' ; } $ rel = ( $ item -> parent_id > 0 ) ? ' rel="' . $ count . 'group_' . $ item -> parent_id . '"' : '' ; $ html [ ] = ' <li>' ; $ html [ ] = ' <input type="checkbox" name="' . $ name . '[]" value="' . $ item -> id . '" id="' . $ eid . '"' . $ checked . $ rel . ' />' ; $ html [ ] = ' <label for="' . $ eid . '">' ; $ html [ ] = ' ' . str_repeat ( '<span class="gi">|—</span>' , $ item -> level ) . $ item -> title ; $ html [ ] = ' </label>' ; $ html [ ] = ' </li>' ; } } $ html [ ] = '</ul>' ; return implode ( "\n" , $ html ) ; }
|
Returns a UL list of user groups with check boxes
|
46,489
|
public static function actions ( $ name , $ selected , $ component , $ section = 'global' ) { static $ count ; $ count ++ ; $ path = PATH_APP . '/components/' . $ component . '/config/access.xml' ; if ( ! file_exists ( $ path ) ) { $ path = PATH_CORE . '/components/' . $ component . '/config/access.xml' ; } $ actions = \ Hubzero \ Access \ Access :: getActionsFromFile ( $ path , "/access/section[@name='" . $ section . "']/" ) ; if ( empty ( $ actions ) ) { $ actions = array ( ) ; } $ html = array ( ) ; $ html [ ] = '<ul class="checklist access-actions">' ; for ( $ i = 0 , $ n = count ( $ actions ) ; $ i < $ n ; $ i ++ ) { $ item = & $ actions [ $ i ] ; $ eid = $ count . 'action_' . $ item -> id ; $ checked = in_array ( $ item -> id , $ selected ) ? ' checked="checked"' : '' ; $ html [ ] = ' <li>' ; $ html [ ] = ' <input type="checkbox" name="' . $ name . '[]" value="' . $ item -> id . '" id="' . $ eid . '"' . $ checked . ' />' ; $ html [ ] = ' <label for="' . $ eid . '">' . Lang :: txt ( $ item -> title ) . '</label>' ; $ html [ ] = ' </li>' ; } $ html [ ] = '</ul>' ; return implode ( "\n" , $ html ) ; }
|
Returns a UL list of actions with check boxes
|
46,490
|
public static function assetgroups ( $ config = array ( ) ) { if ( empty ( self :: $ asset_groups ) ) { $ db = App :: get ( 'db' ) ; $ query = $ db -> getQuery ( ) -> select ( 'a.id' , 'value' ) -> select ( 'a.title' , 'text' ) -> from ( '#__viewlevels' , 'a' ) -> group ( 'a.id' ) -> group ( 'a.title' ) -> group ( 'a.ordering' ) -> order ( 'a.ordering' , 'asc' ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; self :: $ asset_groups = $ db -> loadObjectList ( ) ; if ( $ db -> getErrorNum ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) , 500 , E_WARNING ) ; return false ; } } return self :: $ asset_groups ; }
|
Gets a list of the asset groups as an array of options .
|
46,491
|
public static function assetgrouplist ( $ name , $ selected , $ attribs = null , $ config = array ( ) ) { static $ count ; $ options = self :: assetgroups ( ) ; if ( isset ( $ config [ 'title' ] ) ) { array_unshift ( $ options , Select :: option ( '' , $ config [ 'title' ] ) ) ; } return Select :: genericlist ( $ options , $ name , array ( 'id' => isset ( $ config [ 'id' ] ) ? $ config [ 'id' ] : 'assetgroups_' . ++ $ count , 'list.attr' => ( is_null ( $ attribs ) ? 'class="inputbox" size="3"' : $ attribs ) , 'list.select' => ( int ) $ selected ) ) ; }
|
Displays a Select list of the available asset groups
|
46,492
|
protected function getInput ( ) { $ rows = ( int ) $ this -> element [ 'rows' ] ; $ cols = ( int ) $ this -> element [ 'cols' ] ; $ height = ( ( string ) $ this -> element [ 'height' ] ) ? ( string ) $ this -> element [ 'height' ] : '250' ; $ width = ( ( string ) $ this -> element [ 'width' ] ) ? ( string ) $ this -> element [ 'width' ] : '100%' ; $ assetField = $ this -> element [ 'asset_field' ] ? ( string ) $ this -> element [ 'asset_field' ] : 'asset_id' ; $ authorField = $ this -> element [ 'created_by_field' ] ? ( string ) $ this -> element [ 'created_by_field' ] : 'created_by' ; $ asset = $ this -> form -> getValue ( $ assetField ) ? $ this -> form -> getValue ( $ assetField ) : ( string ) $ this -> element [ 'asset_id' ] ; $ buttons = ( string ) $ this -> element [ 'buttons' ] ; if ( $ buttons == 'true' || $ buttons == 'yes' || $ buttons == '1' ) { $ buttons = true ; } elseif ( $ buttons == 'false' || $ buttons == 'no' || $ buttons == '0' ) { $ buttons = false ; } else { $ buttons = explode ( ',' , $ buttons ) ; } $ hide = ( ( string ) $ this -> element [ 'hide' ] ) ? explode ( ',' , ( string ) $ this -> element [ 'hide' ] ) : array ( ) ; $ editor = $ this -> getEditor ( ) ; return $ editor -> display ( $ this -> name , htmlspecialchars ( $ this -> value , ENT_COMPAT , 'UTF-8' ) , $ width , $ height , $ cols , $ rows , $ buttons ? ( is_array ( $ buttons ) ? array_merge ( $ buttons , $ hide ) : $ hide ) : false , $ this -> id , $ asset , $ this -> form -> getValue ( $ authorField ) ) ; }
|
Method to get the field input markup for the editor area
|
46,493
|
protected function getEditor ( ) { if ( empty ( $ this -> editor ) ) { $ editor = null ; $ type = trim ( ( string ) $ this -> element [ 'editor' ] ) ; if ( $ type ) { $ types = explode ( '|' , $ type ) ; $ db = App :: get ( 'db' ) ; foreach ( $ types as $ element ) { $ query = $ db -> getQuery ( ) -> select ( 'element' ) -> from ( '#__extensions' ) -> whereEquals ( 'element' , $ element ) -> whereEquals ( 'folder' , 'editors' ) -> whereEquals ( 'enabled' , '1' ) -> limit ( 1 ) -> start ( 0 ) ; $ db -> setQuery ( $ query -> toString ( ) ) ; $ editor = $ db -> loadResult ( ) ; if ( $ editor ) { break ; } } } $ this -> editor = $ editor ? Wysiwyg :: getInstance ( $ editor ) : App :: get ( 'editor' ) ; } return $ this -> editor ; }
|
Method to get a Editor object based on the form field .
|
46,494
|
public function automaticDate ( $ data ) { if ( ! isset ( $ data [ 'date' ] ) ) { $ dt = new \ Hubzero \ Utility \ Date ( 'now' ) ; $ data [ 'date' ] = $ dt -> toSql ( ) ; } return $ data [ 'date' ] ; }
|
Generates automatic date value
|
46,495
|
public static function getRecord ( $ itemid = 0 , $ action = '' , $ category = '' , $ created = '' , $ log = '' ) { $ model = self :: all ( ) -> select ( 'id' ) ; if ( $ category ) { $ model -> whereEquals ( 'category' , $ category ) ; } if ( $ itemid ) { $ model -> whereEquals ( 'itemid' , $ itemid ) ; } if ( $ action ) { $ model -> whereEquals ( 'action' , $ action ) ; } if ( $ created ) { $ model -> whereLike ( 'date' , $ created . '%' ) ; } if ( $ log ) { $ model -> whereEquals ( 'log' , $ log ) ; } $ row = $ model -> row ( ) ; return $ row -> get ( 'id' ) ; }
|
Get the ID of a record matching the data passed
|
46,496
|
public function boot ( ) { if ( ( $ this -> app -> isSite ( ) && $ this -> app [ 'config' ] -> get ( 'force_ssl' ) == 2 ) || ( $ this -> app -> isAdmin ( ) && $ this -> app [ 'config' ] -> get ( 'force_ssl' ) >= 1 ) ) { if ( ! $ this -> app [ 'request' ] -> isSecure ( ) ) { $ uri = str_replace ( 'http:' , 'https:' , $ this -> app [ 'request' ] -> getUri ( ) ) ; $ redirect = new RedirectResponse ( $ uri ) ; $ redirect -> setRequest ( $ this -> app [ 'request' ] ) ; $ redirect -> send ( ) ; $ this -> app -> close ( ) ; } } }
|
Force SSL if site is configured to and the connection is not secure .
|
46,497
|
protected function getOptions ( ) { $ options = array ( ) ; $ key = $ this -> element [ 'key_field' ] ? ( string ) $ this -> element [ 'key_field' ] : 'value' ; $ value = $ this -> element [ 'value_field' ] ? ( string ) $ this -> element [ 'value_field' ] : ( string ) $ this -> element [ 'name' ] ; $ translate = $ this -> element [ 'translate' ] ? ( string ) $ this -> element [ 'translate' ] : false ; $ query = ( string ) $ this -> element [ 'query' ] ; $ db = App :: get ( 'db' ) ; $ db -> setQuery ( $ query ) ; $ items = $ db -> loadObjectlist ( ) ; if ( $ db -> getErrorNum ( ) ) { return $ options ; } if ( ! empty ( $ items ) ) { foreach ( $ items as $ item ) { if ( $ translate == true ) { $ options [ ] = Dropdown :: option ( $ item -> $ key , App :: get ( 'language' ) -> txt ( $ item -> $ value ) ) ; } else { $ options [ ] = Dropdown :: option ( $ item -> $ key , $ item -> $ value ) ; } } } $ options = array_merge ( parent :: getOptions ( ) , $ options ) ; return $ options ; }
|
Method to get the custom field options . Use the query attribute to supply a query to generate the list .
|
46,498
|
public function mergeCollection ( $ input ) { if ( is_array ( $ input ) ) { foreach ( $ input as $ actions ) { $ this -> merge ( $ actions ) ; } } }
|
Method to merge a collection of Rules .
|
46,499
|
public function merge ( $ actions ) { if ( is_string ( $ actions ) ) { $ actions = json_decode ( $ actions , true ) ; } if ( is_array ( $ actions ) ) { foreach ( $ actions as $ action => $ identities ) { $ this -> mergeAction ( $ action , $ identities ) ; } } elseif ( $ actions instanceof Rules ) { $ data = $ actions -> getData ( ) ; foreach ( $ data as $ name => $ identities ) { $ this -> mergeAction ( $ name , $ identities ) ; } } }
|
Method to merge actions with this object .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.