idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
900
|
private function parseRow ( \ stdClass $ dataRow , NodePath $ nodePath , array $ parentCols = [ ] , $ outerObjectHash = null ) { $ csvRow = new CsvRow ( $ this -> getHeaders ( $ nodePath , $ parentCols ) ) ; $ arrayParentId = $ this -> getPrimaryKeyValue ( $ dataRow , $ nodePath , $ outerObjectHash ) ; $ columns = $ this -> structure -> getColumnTypes ( $ nodePath ) ; foreach ( array_replace ( $ columns , $ parentCols ) as $ column => $ dataType ) { $ this -> parseField ( $ dataRow , $ csvRow , $ arrayParentId , $ column , $ dataType , $ nodePath ) ; } return $ csvRow ; }
|
Parse a single row If the row contains an array it s recursively parsed
|
901
|
private function getHeaders ( NodePath $ nodePath , & $ parent = false ) { $ headers = [ ] ; $ nodeData = $ this -> structure -> getNode ( $ nodePath ) ; if ( $ nodeData [ 'nodeType' ] == 'scalar' ) { $ headers [ ] = $ nodeData [ 'headerNames' ] ; } if ( is_array ( $ parent ) && ! empty ( $ parent ) ) { foreach ( $ parent as $ key => $ value ) { $ previousPath = $ nodePath -> popLast ( ) ; $ previousNode = $ this -> structure -> getNode ( $ previousPath ) ; $ actualKey = $ this -> structure -> encodeNodeName ( $ key ) ; if ( ! isset ( $ previousNode [ $ key ] ) && ! isset ( $ nodeData [ Structure :: ARRAY_NAME ] [ $ actualKey ] ) && empty ( $ nodeData [ $ actualKey ] [ 'type' ] ) && empty ( $ nodeData [ Structure :: ARRAY_NAME ] [ $ actualKey ] [ 'type' ] ) ) { if ( isset ( $ previousNode [ Structure :: ARRAY_NAME ] [ $ actualKey ] ) ) { $ newColName = $ key ; $ i = 0 ; while ( isset ( $ previousNode [ Structure :: ARRAY_NAME ] [ $ this -> structure -> encodeNodeName ( $ newColName ) ] ) ) { $ newColName = $ key . '_u' . $ i ; $ i ++ ; } $ parent [ $ newColName ] = $ value ; unset ( $ parent [ $ key ] ) ; $ this -> structure -> setParentTargetName ( $ key , $ newColName ) ; $ key = $ newColName ; } $ previousNode [ Structure :: ARRAY_NAME ] [ $ this -> structure -> encodeNodeName ( $ key ) ] = [ 'nodeType' => 'scalar' , 'type' => 'parent' ] ; $ this -> structure -> saveNode ( $ previousPath , $ previousNode ) ; $ this -> structure -> generateHeaderNames ( ) ; $ nodeData = $ this -> structure -> getNode ( $ nodePath ) ; } } } foreach ( $ nodeData as $ nodeName => $ data ) { if ( is_array ( $ data ) && ( $ data [ 'nodeType' ] == 'object' ) ) { $ pparent = false ; $ nodeName = $ this -> structure -> decodeNodeName ( $ nodeName ) ; $ ch = $ this -> getHeaders ( $ nodePath -> addChild ( $ nodeName ) , $ pparent ) ; $ headers = array_merge ( $ headers , $ ch ) ; } else if ( is_array ( $ data ) ) { $ headers [ ] = $ data [ 'headerNames' ] ; } } return $ headers ; }
|
Get column names for a particular node path
|
902
|
private function createCsvFile ( $ type , NodePath $ nodePath , & $ parentId ) { if ( empty ( $ this -> csvFiles [ $ type ] ) ) { $ this -> csvFiles [ $ type ] = Table :: create ( $ type , $ this -> getHeaders ( $ nodePath , $ parentId ) , $ this -> temp ) ; $ this -> csvFiles [ $ type ] -> addAttributes ( [ "fullDisplayName" => $ type ] ) ; if ( ! empty ( $ this -> primaryKeys [ $ type ] ) ) { $ this -> csvFiles [ $ type ] -> setPrimaryKey ( $ this -> primaryKeys [ $ type ] ) ; } } return $ this -> csvFiles [ $ type ] ; }
|
to allow saving a single type to different files
|
903
|
private function validateParentId ( $ parentId ) : array { if ( ! empty ( $ parentId ) ) { if ( is_array ( $ parentId ) ) { if ( count ( $ parentId ) != count ( $ parentId , COUNT_RECURSIVE ) ) { throw new JsonParserException ( 'Error assigning parentId to a CSV file! $parentId array cannot be multidimensional.' , [ 'parentId' => $ parentId ] ) ; } } else { $ parentId = [ 'JSON_parentId' => $ parentId ] ; } } else { $ parentId = [ ] ; } $ result = [ ] ; foreach ( $ parentId as $ key => $ value ) { $ result [ $ this -> structure -> getParentTargetName ( $ key ) ] = $ value ; } return $ result ; }
|
Ensure the parentId array is not multidimensional
|
904
|
public function getCsvFiles ( ) { while ( $ batch = $ this -> cache -> getNext ( ) ) { $ this -> parse ( $ batch [ "data" ] , new NodePath ( [ $ batch [ 'type' ] , Structure :: ARRAY_NAME ] ) , $ batch [ "parentId" ] ) ; } return $ this -> csvFiles ; }
|
Returns an array of CSV files containing results
|
905
|
public function login ( Request $ request , AuthenticateUser $ authenticate , ThrottlesCommand $ throttles ) { $ username = Authen :: getIdentifierName ( ) ; $ input = $ request -> only ( [ $ username , 'password' , 'remember' ] ) ; $ throttles -> setRequest ( $ request ) -> setLoginKey ( $ username ) ; return $ authenticate ( $ this , $ input , $ throttles ) ; }
|
POST Login the user .
|
906
|
public function userLoginHasFailedAuthentication ( array $ input ) { $ message = trans ( 'orchestra/foundation::response.credential.invalid-combination' ) ; return $ this -> redirectWithMessage ( $ this -> getRedirectToLoginPath ( ) , $ message , 'error' ) -> withInput ( ) ; }
|
Response to user log - in trigger has failed authentication .
|
907
|
public function profile ( $ model , $ url ) { return $ this -> form -> of ( 'orchestra.account' , function ( FormGrid $ form ) use ( $ model , $ url ) { $ form -> setup ( $ this , $ url , $ model ) ; $ form -> hidden ( 'id' ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> control ( 'input:text' , 'email' ) -> label ( trans ( 'orchestra/foundation::label.users.email' ) ) ; $ fieldset -> control ( 'input:text' , 'fullname' ) -> label ( trans ( 'orchestra/foundation::label.users.fullname' ) ) ; } ) ; } ) ; }
|
Form view generator for User Account .
|
908
|
public function activationHasSucceed ( Fluent $ extension ) { $ this -> dispatch ( new RefreshRouteCache ( ) ) ; $ message = trans ( 'orchestra/foundation::response.extensions.activate' , $ extension -> getAttributes ( ) ) ; return $ this -> redirectWithMessage ( handles ( 'orchestra::extensions' ) , $ message ) ; }
|
Response when extension activation has succeed .
|
909
|
protected function markAsRegistered ( $ provider ) { $ this [ 'events' ] -> dispatch ( \ get_class ( $ provider ) , [ $ provider ] ) ; parent :: markAsRegistered ( $ provider ) ; }
|
Mark the given provider as registered .
|
910
|
public function configure ( Processor $ processor , $ vendor , $ package = null ) { $ extension = $ this -> getExtension ( $ vendor , $ package ) ; return $ processor -> configure ( $ this , $ extension ) ; }
|
Configure an extension .
|
911
|
public function update ( Processor $ processor , $ vendor , $ package = null ) { $ extension = $ this -> getExtension ( $ vendor , $ package ) ; return $ processor -> update ( $ this , $ extension , Input :: all ( ) ) ; }
|
Update extension configuration .
|
912
|
public function showConfigurationChanger ( array $ data ) { $ name = $ data [ 'extension' ] -> name ; set_meta ( 'title' , Foundation :: memory ( ) -> get ( "extensions.available.{$name}.name" , $ name ) ) ; set_meta ( 'description' , trans ( 'orchestra/foundation::title.extensions.configure' ) ) ; return view ( 'orchestra/foundation::extensions.configure' , $ data ) ; }
|
Response for extension configuration .
|
913
|
public function load ( string $ helper ) { if ( isset ( $ this -> filters [ $ helper ] ) ) { return call_user_func_array ( $ this -> filters [ $ helper ] , array_slice ( func_get_args ( ) , 1 ) ) ; } }
|
Check if filter is registered call filter if is registered
|
914
|
public function collect ( ) { $ self = $ this ; $ fileSystem = new FileSystem ( ) ; $ environment = $ this -> environment ; $ this -> testTargetRepository -> walkOnResources ( function ( $ resource , $ index , TestTargetRepository $ testTargetRepository ) use ( $ self , $ fileSystem , $ environment ) { $ absoluteTargetPath = $ fileSystem -> getAbsolutePath ( $ resource , $ environment -> getWorkingDirectoryAtStartup ( ) ) ; if ( ! file_exists ( $ absoluteTargetPath ) ) { throw new \ UnexpectedValueException ( sprintf ( 'The directory or file [ %s ] is not found' , $ absoluteTargetPath ) ) ; } if ( is_dir ( $ absoluteTargetPath ) ) { $ files = Finder :: create ( ) -> files ( ) -> in ( $ absoluteTargetPath ) -> depth ( $ self -> isRecursive ( ) ? '>= 0' : '== 0' ) -> sortByName ( ) ; foreach ( $ files as $ file ) { call_user_func ( array ( $ self , 'collectTestCasesFromFile' ) , $ file -> getPathname ( ) ) ; } } else { call_user_func ( array ( $ self , 'collectTestCasesFromFile' ) , $ absoluteTargetPath ) ; } } ) ; return $ this -> suite ; }
|
Collects tests .
|
915
|
protected function getRecord ( $ tableName , $ where = null ) { $ record = $ this -> database -> table ( $ tableName ) -> order ( 'RAND()' ) ; return $ where ? $ record -> where ( $ where ) -> limit ( 1 ) -> fetch ( ) : $ record -> limit ( 1 ) -> fetch ( ) ; }
|
Returns random record from given table .
|
916
|
protected function getId ( $ tableName , $ where = null ) { $ record = $ this -> getRecord ( $ tableName , $ where ) ; return $ record ? $ record -> id : null ; }
|
Returns id of random record from given table .
|
917
|
public function scaffold ( ) { $ this -> updateDependencies ( [ "vue" => "^2.4.3" , ] ) ; $ this -> updateDevDependencies ( [ "vue-loader" => "^13.3.0" , "vue-template-compiler" => "^2.5.2" , ] ) ; $ this -> updateJavascript ( $ this -> name ) ; $ this -> updateAssets ( $ this -> name ) ; }
|
Scaffold a Vue boilerplate preset .
|
918
|
private function buildConfig ( ) { $ env = getenv ( 'CRM_ENV' ) ; $ configData = [ 'paths' => [ 'migrations' => [ '%%PHINX_CONFIG_DIR%%/../../../../migrations' ] ] , 'environments' => [ 'default_migration_table' => 'phinxlog' , 'default_database' => $ env , ] , ] ; foreach ( $ this -> moduleManager -> getModules ( ) as $ module ) { $ reflector = new \ ReflectionClass ( $ module ) ; $ configData [ 'paths' ] [ 'migrations' ] [ ] = dirname ( $ reflector -> getFileName ( ) ) . '/migrations' ; } $ configData [ 'environments' ] [ $ env ] = [ 'adapter' => $ this -> envConfig -> get ( 'CRM_DB_ADAPTER' ) , 'host' => $ this -> envConfig -> get ( 'CRM_DB_HOST' ) , 'name' => $ this -> envConfig -> get ( 'CRM_DB_NAME' ) , 'user' => $ this -> envConfig -> get ( 'CRM_DB_USER' ) , 'pass' => $ this -> envConfig -> get ( 'CRM_DB_PASS' ) , 'port' => $ this -> envConfig -> get ( 'CRM_DB_PORT' ) , 'charset' => 'utf8mb4' , 'collation' => 'utf8mb4_unicode_ci' , ] ; return $ configData ; }
|
Build phinx config from config . local . neon
|
919
|
public function clone ( $ destination ) { $ fs = new Filesystem ; if ( ! $ fs -> exists ( $ destination ) ) { $ fs -> mkdir ( $ destination , 0755 ) ; } $ fs -> mirror ( $ this -> source , $ destination , null , $ this -> options ) ; }
|
Perform source cloning .
|
920
|
public function copy ( $ file ) { $ fs = new Filesystem ; if ( ! $ fs -> exists ( dirname ( $ file ) ) ) { $ fs -> mkdir ( dirname ( $ file ) , 0755 ) ; } $ fs -> copy ( $ this -> source , $ file , true ) ; }
|
Perform source coping .
|
921
|
public function run ( $ suite ) { $ printer = $ this -> createPrinter ( ) ; $ testResult = new \ PHPUnit_Framework_TestResult ( ) ; $ testRunner = new TestRunner ( ) ; $ testRunner -> setTestResult ( $ testResult ) ; $ testRunner -> doRun ( $ suite , $ this -> createArguments ( $ printer , $ testResult ) , false ) ; $ this -> notification = $ printer -> getNotification ( ) ; }
|
Runs tests based on the given \ PHPUnit_Framework_TestSuite object .
|
922
|
private function getFiltered ( bool $ public = true ) : array { $ result = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ event [ 'is_public' ] === $ public ) { $ result [ ] = $ event ; } } return $ result ; }
|
Returns array with events filtered by event s visibility
|
923
|
public function quoteValue ( $ str ) { if ( is_int ( $ str ) || is_float ( $ str ) ) { return $ str ; } return "'" . addcslashes ( str_replace ( "'" , "''" , $ str ) , "\000\n\r\\\032" ) . "'" ; }
|
Quotes a string value for use in a query .
|
924
|
public function utmParams ( ) : array { return array_filter ( [ 'utm_source' => $ this -> utmSession -> utmSource , 'utm_medium' => $ this -> utmSession -> utmMedium , 'utm_campaign' => $ this -> utmSession -> utmCampaign , 'utm_content' => $ this -> utmSession -> utmContent , ] ) ; }
|
Returns array with UTM parameters of campaign
|
925
|
protected function buildTrackingParamsSession ( ) { $ this -> utmSession = $ this -> getSession ( 'utm_session' ) ; $ this -> utmSession -> setExpiration ( '30 minutes' ) ; if ( $ this -> getParameter ( 'utm_source' ) ) { $ this -> utmSession -> utmSource = $ this -> getParameter ( 'utm_source' ) ; } if ( $ this -> getParameter ( 'utm_medium' ) ) { $ this -> utmSession -> utmMedium = $ this -> getParameter ( 'utm_medium' ) ; } if ( $ this -> getParameter ( 'utm_campaign' ) ) { $ this -> utmSession -> utmCampaign = $ this -> getParameter ( 'utm_campaign' ) ; } if ( $ this -> getParameter ( 'utm_content' ) ) { $ this -> utmSession -> utmContent = $ this -> getParameter ( 'utm_content' ) ; } $ this -> additionalTrackingSession = $ this -> getSession ( 'additional_tracking_params' ) ; $ this -> additionalTrackingSession -> setExpiration ( '30 minutes' ) ; if ( $ this -> getParameter ( 'banner_variant' ) ) { $ this -> additionalTrackingSession -> bannerVariant = $ this -> getParameter ( 'banner_variant' ) ; } }
|
Store sales funnel UTM parameters and additional tracking parameters to session
|
926
|
public function onMethodVerificationSuccess ( Member $ member , $ method ) { $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) successfully verified using MFA method' , $ member -> Email ? : $ member -> Title , $ member -> ID ) , [ 'method' => get_class ( $ method ) ] ) ; }
|
A successful login using an MFA method
|
927
|
public function onMethodVerificationFailure ( Member $ member , $ method ) { $ context = [ 'method' => get_class ( $ method ) , ] ; if ( $ lockOutAfterCount = $ member -> config ( ) -> get ( 'lock_out_after_incorrect_logins' ) ) { $ context [ 'attempts' ] = $ member -> FailedLoginCount ; $ context [ 'attempt_limit' ] = $ lockOutAfterCount ; } $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) failed to verify using MFA method' , $ member -> Email ? : $ member -> Title , $ member -> ID ) , $ context ) ; }
|
A failed login using an MFA method
|
928
|
public function onSkipRegistration ( Member $ member ) { $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) skipped MFA registration' , $ member -> Email ? : $ member -> Title , $ member -> ID ) ) ; }
|
A user has skipped MFA registration when it is enabled but optional or within a grace period
|
929
|
public function getDatabaseSeriesData ( Criteria $ criteria ) { $ dbData = [ ] ; $ res = $ this -> database -> query ( "SELECT {$criteria->getValueField()} AS value,calendar.week AS week,calendar.month AS month,calendar.year AS year,{$this->getSeries($criteria->getSeries())}{$criteria->getTableName()}.idFROM {$criteria->getTableName()}INNER JOIN calendar ON date({$criteria->getTableName()}.{$criteria->getTimeField()}) = calendar.date AND calendar.date >= '{$criteria->getStartDate()}' AND calendar.date <= '{$criteria->getEndDate()}' {$criteria->getJoin()}WHERE {$criteria->getTableName()}.{$criteria->getTimeField()} >= '{$criteria->getStartDate()}' AND {$criteria->getTableName()}.{$criteria->getTimeField()} <= '{$criteria->getEndDate()}' {$criteria->getWhere()}GROUP BY calendar.year,calendar.month,calendar.week" . $ this -> getGroupBy ( $ criteria -> getGroupBy ( ) ) . ' ' ) ; foreach ( $ res as $ row ) { $ value = 0 ; if ( $ row -> id != null ) { $ value = $ row [ 'value' ] ; } $ date = new \ DateTime ( ) ; $ date -> setISODate ( $ row -> year , $ row -> week ) ; if ( isset ( $ row -> name ) ) { $ dbData [ $ row -> name ] [ $ date -> format ( 'Y-m-d' ) ] = $ value ; } else { $ dbData [ ' ' ] [ $ date -> format ( 'Y-m-d' ) ] = $ value ; } } return $ dbData ; }
|
pridat do vsetkych queries ?
|
930
|
public function add ( array $ assets ) { if ( ! file_exists ( $ this -> file ) ) { throw new RuntimeException ( "Could not add assets, `app.json` file do not exists." ) ; } $ packages = json_decode ( file_get_contents ( $ this -> file ) , true ) ; $ packages [ 'assets' ] = $ assets + $ packages [ 'assets' ] ; ksort ( $ packages [ 'assets' ] ) ; file_put_contents ( $ this -> file , json_encode ( $ packages , JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) . PHP_EOL ) ; }
|
Adds additional entries to the assets option .
|
931
|
public function insert ( $ query , $ bindings = [ ] ) { try { $ this -> statement ( $ query , $ bindings ) ; return true ; } catch ( \ Exception $ e ) { throw new InternalServerErrorException ( 'Insert failed. ' . $ e -> getMessage ( ) ) ; } }
|
Run an insert statement against the database .
|
932
|
public function run ( Renamer $ renamer , Scaffolder $ scaffolder ) { $ this -> drawBanner ( ) ; $ child = $ this -> askForChildConfirmation ( ) ; $ replacements = $ this -> askForReplacements ( $ child ) ; if ( ! $ child ) { $ preset = $ this -> askForPreset ( ) ; } if ( $ this -> askForConfirmation ( ) ) { if ( isset ( $ preset ) && $ preset !== 'none' ) { $ scaffolder -> build ( $ preset ) ; } $ renamer -> replace ( $ replacements ) ; $ this -> climate -> backgroundLightGreen ( 'Done. Cheers!' ) ; } else { $ this -> climate -> backgroundRed ( 'Shaking abored.' ) ; } }
|
Run CLI logic .
|
933
|
public function askForReplacements ( $ child ) { $ replacements = [ ] ; if ( $ child ) { $ this -> placeholders = array_merge ( $ this -> placeholders , $ this -> childPlaceholders ) ; } foreach ( $ this -> placeholders as $ placeholder => $ data ) { $ input = $ this -> climate -> input ( $ data [ 'message' ] ) ; $ input -> defaultTo ( $ data [ 'value' ] ) ; $ replacements [ $ placeholder ] = addslashes ( $ input -> prompt ( ) ) ; } return $ replacements ; }
|
Asks placeholders and saves answers .
|
934
|
public function askForPreset ( ) { $ input = $ this -> climate -> input ( '<comment>Choose the front-end scaffolding</comment>' ) ; $ input -> accept ( $ this -> presets , true ) ; return strtolower ( $ input -> prompt ( ) ) ; }
|
Asks for preset name which files will be generated .
|
935
|
public function scaffold ( ) { $ this -> updateDependencies ( [ 'foundation-sites' => '^6.4.1' , 'what-input' => '^4.1.3' , 'motion-ui' => '^1.2.2' , ] ) ; $ this -> updateConfig ( [ 'foundation' => [ './resources/assets/js/foundation.js' , './resources/assets/sass/foundation.scss' , ] , ] ) ; $ this -> updateSass ( $ this -> name ) ; $ this -> updateJavascript ( $ this -> name ) ; $ this -> updateAssets ( $ this -> name ) ; }
|
Scaffold a Foundation boilerplate preset .
|
936
|
public function removeObjectById ( $ contentObjectId , $ commit = null ) { if ( ! isset ( $ commit ) && ( $ this -> iniConfig -> variable ( 'IndexOptions' , 'DisableDeleteCommits' ) === 'true' ) ) { $ commit = false ; } elseif ( ! isset ( $ commit ) ) { $ commit = true ; } if ( $ this -> searchHandler instanceof LegacyHandler ) { $ searchEngine = new eZSearchEngine ( ) ; $ searchEngine -> removeObjectById ( $ contentObjectId , $ commit ) ; return true ; } $ this -> searchHandler -> deleteContent ( ( int ) $ contentObjectId ) ; if ( $ commit ) { $ this -> commit ( ) ; } return true ; }
|
Removes a content object by ID from the search database .
|
937
|
public function cleanup ( ) { if ( $ this -> searchHandler instanceof LegacyHandler ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ db -> query ( "DELETE FROM ezsearch_word" ) ; $ db -> query ( "DELETE FROM ezsearch_object_word_link" ) ; $ db -> commit ( ) ; } else if ( method_exists ( $ this -> searchHandler , 'purgeIndex' ) ) { $ this -> searchHandler -> purgeIndex ( ) ; } }
|
Purges the index .
|
938
|
public function updateNodeSection ( $ nodeID , $ sectionID ) { $ contentObject = eZContentObject :: fetchByNodeID ( $ nodeID ) ; eZContentOperationCollection :: registerSearchObject ( $ contentObject -> attribute ( 'id' ) ) ; }
|
Update index when a new section is assigned to an object through a node .
|
939
|
public function updateNodeVisibility ( $ nodeID , $ action ) { $ node = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; eZContentOperationCollection :: registerSearchObject ( $ node -> attribute ( 'contentobject_id' ) ) ; $ params = array ( 'Depth' => 1 , 'DepthOperator' => 'eq' , 'Limitation' => array ( ) , 'IgnoreVisibility' => true ) ; if ( $ node -> subTreeCount ( $ params ) > 0 ) { $ pendingAction = new eZPendingActions ( array ( 'action' => 'index_subtree' , 'created' => time ( ) , 'param' => $ nodeID ) ) ; $ pendingAction -> store ( ) ; } }
|
Update index when node s visibility is modified .
|
940
|
public function swapNode ( $ nodeID , $ selectedNodeID , $ nodeIdList = array ( ) ) { $ contentObject1 = eZContentObject :: fetchByNodeID ( $ nodeID ) ; $ contentObject2 = eZContentObject :: fetchByNodeID ( $ selectedNodeID ) ; eZContentOperationCollection :: registerSearchObject ( $ contentObject1 -> attribute ( 'id' ) ) ; eZContentOperationCollection :: registerSearchObject ( $ contentObject2 -> attribute ( 'id' ) ) ; }
|
Update search index when two nodes are swapped
|
941
|
function isSearchPartIncomplete ( $ part ) { if ( $ this -> searchHandler instanceof LegacyHandler ) { $ searchEngine = new eZSearchEngine ( ) ; return $ searchEngine -> isSearchPartIncomplete ( $ part ) ; } return false ; }
|
Returns true if the search part is incomplete .
|
942
|
public function normalizeText ( $ text ) { if ( $ this -> searchHandler instanceof LegacyHandler ) { $ searchEngine = new eZSearchEngine ( ) ; return $ searchEngine -> normalizeText ( $ text ) ; } return $ text ; }
|
Normalizes the text so that it is easily parsable
|
943
|
protected function getSSLBuilder ( $ config ) { if ( empty ( $ config ) ) { return null ; } $ ssl = \ Cassandra :: ssl ( ) ; $ serverCert = array_get ( $ config , 'server_cert_path' ) ; $ clientCert = array_get ( $ config , 'client_cert_path' ) ; $ privateKey = array_get ( $ config , 'private_key_path' ) ; $ passPhrase = array_get ( $ config , 'key_pass_phrase' ) ; if ( ! empty ( $ serverCert ) && ! empty ( $ clientCert ) ) { if ( empty ( $ privateKey ) ) { throw new InternalServerErrorException ( 'No private key provider.' ) ; } return $ ssl -> withVerifyFlags ( \ Cassandra :: VERIFY_PEER_CERT ) -> withTrustedCerts ( $ serverCert ) -> withClientCert ( $ clientCert ) -> withPrivateKey ( $ privateKey , $ passPhrase ) -> build ( ) ; } elseif ( ! empty ( $ serverCert ) ) { return $ ssl -> withVerifyFlags ( \ Cassandra :: VERIFY_PEER_CERT ) -> withTrustedCerts ( getenv ( 'SERVER_CERT' ) ) -> build ( ) ; } elseif ( true === boolval ( array_get ( $ config , 'ssl' , array_get ( $ config , 'tls' , false ) ) ) ) { return $ ssl -> withVerifyFlags ( \ Cassandra :: VERIFY_NONE ) -> build ( ) ; } else { return null ; } }
|
Creates the SSL connection builder .
|
944
|
public function listTables ( ) { $ tables = $ this -> keyspace -> tables ( ) ; $ out = [ ] ; foreach ( $ tables as $ table ) { $ out [ ] = [ 'table_name' => $ table -> name ( ) ] ; } return $ out ; }
|
Lists Cassandra table .
|
945
|
protected function extractPaginationInfo ( & $ cql ) { $ words = explode ( ' ' , $ cql ) ; $ limit = 0 ; $ offset = 0 ; $ limitKey = null ; foreach ( $ words as $ key => $ word ) { if ( 'limit' === strtolower ( $ word ) && is_numeric ( $ words [ $ key + 1 ] ) ) { $ limit = ( int ) $ words [ $ key + 1 ] ; $ limitKey = $ key + 1 ; } if ( 'offset' === strtolower ( $ word ) && is_numeric ( $ words [ $ key + 1 ] ) ) { $ offset = ( int ) $ words [ $ key + 1 ] ; unset ( $ words [ $ key ] , $ words [ $ key + 1 ] ) ; } } $ limit += $ offset ; if ( $ limitKey !== null ) { $ words [ $ limitKey ] = $ limit ; } $ cql = implode ( ' ' , $ words ) ; return [ 'limit' => $ limit , 'offset' => $ offset ] ; }
|
Extracts pagination info from CQL .
|
946
|
protected function handleBootstrap ( $ filename , $ syntaxCheck = false ) { try { \ PHPUnit_Util_Fileloader :: checkAndLoad ( $ filename , $ syntaxCheck ) ; } catch ( RuntimeException $ e ) { \ PHPUnit_TextUI_TestRunner :: showError ( $ e -> getMessage ( ) ) ; } }
|
Loads a bootstrap file .
|
947
|
public function addSeeder ( AbstractPopulator $ seeder ) { $ seeder -> setPopulator ( $ this ) ; $ seeder -> setDatabase ( $ this -> database ) ; $ seeder -> setFaker ( $ this -> faker ) ; $ this -> seeders [ ] = $ seeder ; }
|
Add new seeder
|
948
|
public function canvasImageScale ( ) { $ imageOriginalWidth = imagesx ( $ this -> oImg ) ; $ imageOriginalHeight = imagesy ( $ this -> oImg ) ; $ scale = min ( $ imageOriginalWidth / $ this -> options [ 'width' ] , $ imageOriginalHeight / $ this -> options [ 'height' ] ) ; $ this -> options [ 'cropWidth' ] = ceil ( $ this -> options [ 'width' ] * $ scale ) ; $ this -> options [ 'cropHeight' ] = ceil ( $ this -> options [ 'height' ] * $ scale ) ; $ this -> options [ 'minScale' ] = min ( $ this -> options [ 'maxScale' ] , max ( 1 / $ scale , $ this -> options [ 'minScale' ] ) ) ; if ( $ this -> options [ 'prescale' ] !== false ) { $ this -> preScale = 1 / $ scale / $ this -> options [ 'minScale' ] ; if ( $ this -> preScale < 1 ) { $ this -> canvasImageResample ( ceil ( $ imageOriginalWidth * $ this -> preScale ) , ceil ( $ imageOriginalHeight * $ this -> preScale ) ) ; $ this -> options [ 'cropWidth' ] = ceil ( $ this -> options [ 'cropWidth' ] * $ this -> preScale ) ; $ this -> options [ 'cropHeight' ] = ceil ( $ this -> options [ 'cropHeight' ] * $ this -> preScale ) ; } else { $ this -> preScale = 1 ; } } return $ this ; }
|
Scale the image before smartcrop analyse
|
949
|
public function canvasImageResample ( $ width , $ height ) { $ oCanvas = imagecreatetruecolor ( $ width , $ height ) ; imagecopyresampled ( $ oCanvas , $ this -> oImg , 0 , 0 , 0 , 0 , $ width , $ height , imagesx ( $ this -> oImg ) , imagesy ( $ this -> oImg ) ) ; $ this -> oImg = $ oCanvas ; return $ this ; }
|
Function for scale image
|
950
|
public function analyse ( ) { $ result = [ ] ; $ w = $ this -> w = imagesx ( $ this -> oImg ) ; $ h = $ this -> h = imagesy ( $ this -> oImg ) ; $ this -> od = new \ SplFixedArray ( $ h * $ w * 3 ) ; $ this -> aSample = new \ SplFixedArray ( $ h * $ w ) ; for ( $ y = 0 ; $ y < $ h ; $ y ++ ) { for ( $ x = 0 ; $ x < $ w ; $ x ++ ) { $ p = ( $ y ) * $ this -> w * 3 + ( $ x ) * 3 ; $ aRgb = $ this -> getRgbColorAt ( $ x , $ y ) ; $ this -> od [ $ p + 1 ] = $ this -> edgeDetect ( $ x , $ y , $ w , $ h ) ; $ this -> od [ $ p ] = $ this -> skinDetect ( $ aRgb [ 0 ] , $ aRgb [ 1 ] , $ aRgb [ 2 ] , $ this -> sample ( $ x , $ y ) ) ; $ this -> od [ $ p + 2 ] = $ this -> saturationDetect ( $ aRgb [ 0 ] , $ aRgb [ 1 ] , $ aRgb [ 2 ] , $ this -> sample ( $ x , $ y ) ) ; } } $ scoreOutput = $ this -> downSample ( $ this -> options [ 'scoreDownSample' ] ) ; $ topScore = - INF ; $ topCrop = null ; $ crops = $ this -> generateCrops ( ) ; foreach ( $ crops as & $ crop ) { $ crop [ 'score' ] = $ this -> score ( $ scoreOutput , $ crop ) ; if ( $ crop [ 'score' ] [ 'total' ] > $ topScore ) { $ topCrop = $ crop ; $ topScore = $ crop [ 'score' ] [ 'total' ] ; } } $ result [ 'topCrop' ] = $ topCrop ; if ( $ this -> options [ 'debug' ] && $ topCrop ) { $ result [ 'crops' ] = $ crops ; $ result [ 'debugOutput' ] = $ scoreOutput ; $ result [ 'debugOptions' ] = $ this -> options ; $ result [ 'debugTopCrop' ] = array_merge ( [ ] , $ result [ 'topCrop' ] ) ; } return $ result ; }
|
Analyse the image find out the optimal crop scheme
|
951
|
public function generateCrops ( ) { $ w = imagesx ( $ this -> oImg ) ; $ h = imagesy ( $ this -> oImg ) ; $ results = [ ] ; $ minDimension = min ( $ w , $ h ) ; $ cropWidth = empty ( $ this -> options [ 'cropWidth' ] ) ? $ minDimension : $ this -> options [ 'cropWidth' ] ; $ cropHeight = empty ( $ this -> options [ 'cropHeight' ] ) ? $ minDimension : $ this -> options [ 'cropHeight' ] ; for ( $ scale = $ this -> options [ 'maxScale' ] ; $ scale >= $ this -> options [ 'minScale' ] ; $ scale -= $ this -> options [ 'scaleStep' ] ) { for ( $ y = 0 ; $ y + $ cropHeight * $ scale <= $ h ; $ y += $ this -> options [ 'step' ] ) { for ( $ x = 0 ; $ x + $ cropWidth * $ scale <= $ w ; $ x += $ this -> options [ 'step' ] ) { $ results [ ] = [ 'x' => $ x , 'y' => $ y , 'width' => $ cropWidth * $ scale , 'height' => $ cropHeight * $ scale ] ; } } } return $ results ; }
|
Generate crop schemes
|
952
|
public function score ( $ output , $ crop ) { $ result = [ 'detail' => 0 , 'saturation' => 0 , 'skin' => 0 , 'boost' => 0 , 'total' => 0 ] ; $ downSample = $ this -> options [ 'scoreDownSample' ] ; $ invDownSample = 1 / $ downSample ; $ outputHeightDownSample = floor ( $ this -> h / $ downSample ) * $ downSample ; $ outputWidthDownSample = floor ( $ this -> w / $ downSample ) * $ downSample ; $ outputWidth = floor ( $ this -> w / $ downSample ) ; for ( $ y = 0 ; $ y < $ outputHeightDownSample ; $ y += $ downSample ) { for ( $ x = 0 ; $ x < $ outputWidthDownSample ; $ x += $ downSample ) { $ i = $ this -> importance ( $ crop , $ x , $ y ) ; $ p = floor ( $ y / $ downSample ) * $ outputWidth * 4 + floor ( $ x / $ downSample ) * 4 ; $ detail = $ output [ $ p + 1 ] / 255 ; $ result [ 'skin' ] += $ output [ $ p ] / 255 * ( $ detail + $ this -> options [ 'skinBias' ] ) * $ i ; $ result [ 'saturation' ] += $ output [ $ p + 2 ] / 255 * ( $ detail + $ this -> options [ 'saturationBias' ] ) * $ i ; $ result [ 'detail' ] = $ p ; } } $ result [ 'total' ] = ( $ result [ 'detail' ] * $ this -> options [ 'detailWeight' ] + $ result [ 'skin' ] * $ this -> options [ 'skinWeight' ] + $ result [ 'saturation' ] * $ this -> options [ 'saturationWeight' ] + $ result [ 'boost' ] * $ this -> options [ 'boostWeight' ] ) / ( $ crop [ 'width' ] * $ crop [ 'height' ] ) ; return $ result ; }
|
Score a crop scheme
|
953
|
public function swap ( array $ replacements ) { foreach ( $ replacements as $ from => $ to ) { $ this -> replace ( $ from , $ this -> normalize ( $ to ) ) ; } }
|
Inits renaming process .
|
954
|
protected function replace ( $ from , $ to ) { if ( $ this -> file -> getExtension ( ) === 'json' ) { $ from = addslashes ( $ from ) ; } file_put_contents ( $ this -> file -> getRealPath ( ) , str_replace ( $ from , $ to , $ this -> file -> getContents ( ) ) ) ; }
|
Replaces strings in file content .
|
955
|
public function delete ( IRow & $ row ) { $ res = $ this -> getTable ( ) -> wherePrimary ( $ row -> getPrimary ( ) ) -> delete ( ) ; $ oldValues = [ ] ; if ( $ row instanceof ActiveRow ) { $ oldValues = $ row -> toArray ( ) ; } if ( ! $ res ) { return false ; } if ( $ this -> auditLogRepository ) { $ from = $ this -> filterValues ( $ this -> excludeColumns ( $ oldValues ) ) ; $ data = [ 'version' => '1' , 'from' => $ from , 'to' => [ ] , ] ; $ this -> pushAuditLog ( AuditLogRepository :: OPERATION_DELETE , $ row -> getSignature ( ) , $ data ) ; } return true ; }
|
Delete deletes provided record from repository and mutates the provided instance . Operation is logged to audit log .
|
956
|
public function insert ( $ data ) { $ row = $ this -> getTable ( ) -> insert ( $ data ) ; if ( ! $ row instanceof IRow ) { return $ row ; } if ( $ this -> auditLogRepository ) { $ to = $ this -> filterValues ( $ this -> excludeColumns ( ( array ) $ data ) ) ; $ data = [ 'version' => '1' , 'from' => [ ] , 'to' => $ to , ] ; $ this -> pushAuditLog ( AuditLogRepository :: OPERATION_CREATE , $ row -> getSignature ( ) , $ data ) ; } return $ row ; }
|
Insert inserts data to the repository . If single IRow is returned it attempts to log audit information .
|
957
|
private function filterValues ( array $ values ) { foreach ( $ values as $ i => $ field ) { if ( is_bool ( $ field ) ) { $ values [ $ i ] = ( int ) $ field ; } elseif ( $ field instanceof \ DateTime ) { $ values [ $ i ] = $ field -> format ( 'Y-m-d H:i:s' ) ; } elseif ( ! is_scalar ( $ field ) ) { unset ( $ values [ $ i ] ) ; } } return $ values ; }
|
filterValues removes non - scalar values from the array and formats any DateTime to DB string representation .
|
958
|
public static function bind_manipulation_capture ( ) { $ current = DB :: get_conn ( ) ; if ( ! $ current || ! $ current -> getConnector ( ) -> getSelectedDatabase ( ) || @ $ current -> isManipulationLoggingCapture ) { return ; } $ type = get_class ( $ current ) ; $ sanitisedType = str_replace ( '\\' , '_' , $ type ) ; $ file = TEMP_FOLDER . "/.cache.CLC.$sanitisedType" ; $ dbClass = 'AuditLoggerManipulateCapture_' . $ sanitisedType ; if ( ! is_file ( $ file ) ) { file_put_contents ( $ file , "<?php class $dbClass extends $type { public \$isManipulationLoggingCapture = true; public function manipulate(\$manipulation) { \SilverStripe\Auditor\AuditHook::handle_manipulation(\$manipulation); return parent::manipulate(\$manipulation); } } " ) ; } require_once $ file ; $ captured = new $ dbClass ( ) ; $ captured -> setConnector ( $ current -> getConnector ( ) ) ; $ captured -> setQueryBuilder ( $ current -> getQueryBuilder ( ) ) ; $ captured -> setSchemaManager ( $ current -> getSchemaManager ( ) ) ; $ captured -> selectDatabase ( $ current -> getConnector ( ) -> getSelectedDatabase ( ) ) ; DB :: set_conn ( $ captured ) ; }
|
This will bind a new class dynamically so we can hook into manipulation and capture it . It creates a new PHP file in the temp folder then loads it and sets it as the active DB class .
|
959
|
public function onAfterPublish ( & $ original ) { $ member = Security :: getCurrentUser ( ) ; if ( ! $ member || ! $ member -> exists ( ) ) { return false ; } $ effectiveViewerGroups = '' ; if ( $ this -> owner -> CanViewType === 'OnlyTheseUsers' ) { $ originalViewerGroups = $ original ? $ original -> ViewerGroups ( ) -> column ( 'Title' ) : [ ] ; $ effectiveViewerGroups = implode ( ', ' , $ originalViewerGroups ) ; } if ( ! $ effectiveViewerGroups ) { $ effectiveViewerGroups = $ this -> owner -> CanViewType ; } $ effectiveEditorGroups = '' ; if ( $ this -> owner -> CanEditType === 'OnlyTheseUsers' ) { $ originalEditorGroups = $ original ? $ original -> EditorGroups ( ) -> column ( 'Title' ) : [ ] ; $ effectiveEditorGroups = implode ( ', ' , $ originalEditorGroups ) ; } if ( ! $ effectiveEditorGroups ) { $ effectiveEditorGroups = $ this -> owner -> CanEditType ; } $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) published %s "%s" (ID: %s, Version: %s, ClassName: %s, Effective ViewerGroups: %s, ' . 'Effective EditorGroups: %s)' , $ member -> Email ? : $ member -> Title , $ member -> ID , $ this -> owner -> singular_name ( ) , $ this -> owner -> Title , $ this -> owner -> ID , $ this -> owner -> Version , $ this -> owner -> ClassName , $ effectiveViewerGroups , $ effectiveEditorGroups ) ) ; }
|
Log a record being published .
|
960
|
public function onAfterUnpublish ( ) { $ member = Security :: getCurrentUser ( ) ; if ( ! $ member || ! $ member -> exists ( ) ) { return false ; } $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) unpublished %s "%s" (ID: %s)' , $ member -> Email ? : $ member -> Title , $ member -> ID , $ this -> owner -> singular_name ( ) , $ this -> owner -> Title , $ this -> owner -> ID ) ) ; }
|
Log a record being unpublished .
|
961
|
public function afterMemberLoggedIn ( ) { $ this -> getAuditLogger ( ) -> info ( sprintf ( '"%s" (ID: %s) successfully logged in' , $ this -> owner -> Email ? : $ this -> owner -> Title , $ this -> owner -> ID ) ) ; }
|
Log successful login attempts .
|
962
|
public function authenticationFailed ( $ data ) { $ login = isset ( $ data [ 'Login' ] ) ? $ data [ 'Login' ] : ( isset ( $ data [ Email :: class ] ) ? $ data [ Email :: class ] : '' ) ; if ( empty ( $ login ) ) { return $ this -> getAuditLogger ( ) -> warning ( 'Could not determine username/email of failed authentication. ' . 'This could be due to login form not using Email or Login field for POST data.' ) ; } $ this -> getAuditLogger ( ) -> info ( sprintf ( 'Failed login attempt using email "%s"' , $ login ) ) ; }
|
Log failed login attempts .
|
963
|
public function replace ( array $ replacements ) { foreach ( $ this -> files ( ) as $ file ) { ( new Replacer ( $ file ) ) -> swap ( $ replacements ) ; } }
|
Process renaming in files content .
|
964
|
public function files ( ) { $ files = ( new Finder ) -> files ( ) ; foreach ( $ this -> ignoredFiles as $ name ) { $ files -> notName ( $ name ) ; } foreach ( $ this -> searchedFiles as $ name ) { $ files -> name ( $ name ) ; } return $ files -> exclude ( $ this -> ignoredDirectories ) -> in ( $ this -> dir ) ; }
|
Finds files to rename .
|
965
|
public function hasRoleById ( int $ roleId ) : bool { if ( isset ( $ this -> roles [ $ roleId ] ) ) { return true ; } return false ; }
|
Check if an user has a role use role Id .
|
966
|
public function hasRoleByName ( string $ roleName ) : bool { if ( \ in_array ( $ roleName , \ array_column ( $ this -> roles , 'name' ) , true ) ) { return true ; } return false ; }
|
Check if an user has a role use role name .
|
967
|
public function update ( SplSubject $ subject ) { if ( $ subject instanceof Model ) { $ this -> data = \ array_merge ( $ this -> data , $ subject -> get ( ) ) ; } }
|
Update Observer data .
|
968
|
public static function createNewRefreshToken ( int $ ttl , TokenOwnerInterface $ owner = null , Client $ client = null , $ scopes = null ) : RefreshToken { return static :: createNew ( $ ttl , $ owner , $ client , $ scopes ) ; }
|
Create a new RefreshToken
|
969
|
public function prepare ( ) { $ object_type = $ this -> getObjectType ( ) ; $ object_link = elgg_view ( 'output/url' , array ( 'text' => $ this -> object -> getDisplayName ( ) , 'href' => elgg_http_add_url_query_elements ( $ this -> object -> getURL ( ) , array ( 'active_tab' => 'comments' , ) ) , ) ) ; if ( $ this -> author -> guid == $ this -> object -> owner_guid ) { $ object_summary_title = elgg_echo ( 'interactions:ownership:own' , array ( $ object_type ) , $ this -> language ) ; } else if ( $ this -> recipient -> guid == $ this -> object -> owner_guid ) { $ object_summary_title = elgg_echo ( 'interactions:ownership:your' , array ( $ object_type ) , $ this -> language ) ; } else { $ object_owner = $ this -> object -> getOwnerEntity ( ) ? : elgg_get_site_entity ( ) ; $ object_summary_title = elgg_echo ( 'interactions:ownership:owner' , array ( $ object_owner -> getDisplayName ( ) , $ object_type ) , $ this -> language ) ; } if ( $ this -> object instanceof Comment ) { $ object_full_title = $ object_summary_title ; } else { $ object_full_title = $ object_summary_title . ' ' . $ object_link ; } if ( $ this -> root -> guid !== $ this -> object -> guid ) { $ root_link = elgg_view ( 'output/url' , array ( 'text' => $ this -> root -> getDisplayName ( ) , 'href' => elgg_http_add_url_query_elements ( $ this -> root -> getURL ( ) , array ( 'active_tab' => 'comments' , ) ) , ) ) ; $ object_full_title .= ' ' . elgg_echo ( 'interactions:comment:in_thread' , array ( $ root_link ) ) ; } $ author_link = elgg_view ( 'output/url' , array ( 'text' => $ this -> author -> name , 'href' => $ this -> author -> getURL ( ) , ) ) ; $ object_summary_link = elgg_view ( 'output/url' , array ( 'text' => $ object_summary_title , 'href' => elgg_http_add_url_query_elements ( $ this -> object -> getURL ( ) , array ( 'active_tab' => 'comments' , ) ) , ) ) ; $ action_type = $ this -> getActionType ( ) ; $ notification = new \ stdClass ( ) ; $ notification -> summary = elgg_echo ( 'interactions:response:email:subject' , array ( $ author_link , $ action_type , $ object_summary_link ) , $ this -> language ) ; $ notification -> subject = strip_tags ( $ notification -> summary ) ; $ notification -> body = elgg_echo ( 'interactions:response:email:body' , array ( $ author_link , $ action_type , $ object_full_title , $ this -> getComment ( ) , $ this -> comment -> getURL ( ) , $ this -> root -> getURL ( ) , $ this -> author -> getDisplayName ( ) , $ this -> author -> getURL ( ) , ) , $ this -> language ) ; return $ notification ; }
|
Prepares notification elements
|
970
|
public function getObjectType ( ) { $ type = $ this -> object -> getType ( ) ; $ subtype = $ this -> object -> getSubtype ( ) ? : 'default' ; $ keys = [ "interactions:$type:$subtype" , $ this -> object instanceof Comment ? "interactions:comment" : "interactions:post" , ] ; foreach ( $ keys as $ key ) { if ( elgg_language_key_exists ( $ key , $ this -> language ) ) { return elgg_echo ( $ key , array ( ) , $ this -> language ) ; } } return elgg_echo ( 'interactions:post' , $ this -> language ) ; }
|
Prepares object type string
|
971
|
protected function getComment ( ) { $ comment_body = elgg_view ( 'output/longtext' , array ( 'value' => $ this -> comment -> description , ) ) ; $ comment_body .= elgg_view ( 'output/attached' , array ( 'entity' => $ this -> comment , ) ) ; $ attachments = $ this -> comment -> getAttachments ( array ( 'limit' => 0 ) ) ; if ( $ attachments && count ( $ attachments ) ) { $ attachments = array_map ( __NAMESPACE__ . '\\get_linked_entity_name' , $ attachments ) ; $ attachments_text = implode ( ', ' , array_filter ( $ attachments ) ) ; if ( $ attachments_text ) { $ comment_body .= elgg_echo ( 'interactions:attachments:labelled' , array ( $ attachments_text ) ) ; } } return strip_tags ( $ comment_body , '<p><strong><em><span><ul><li><ol><blockquote><img><a>' ) ; }
|
Prepares comment body including the text and attachment info
|
972
|
protected static function parseProgressBar ( ProgressBarInterface $ progressBar , array $ args ) { $ progressBar -> setAnimated ( ArrayHelper :: get ( $ args , "animated" , false ) ) ; $ progressBar -> setContent ( ArrayHelper :: get ( $ args , "content" ) ) ; $ progressBar -> setMax ( ArrayHelper :: get ( $ args , "max" , 100 ) ) ; $ progressBar -> setMin ( ArrayHelper :: get ( $ args , "min" , 0 ) ) ; $ progressBar -> setStriped ( ArrayHelper :: get ( $ args , "striped" , false ) ) ; $ progressBar -> setValue ( ArrayHelper :: get ( $ args , "value" , 50 ) ) ; return $ progressBar ; }
|
Parses a progress bar .
|
973
|
public static function urlHandler ( $ hook , $ type , $ url , $ params ) { $ entity = elgg_extract ( 'entity' , $ params ) ; if ( $ entity instanceof Comment ) { $ container = $ entity -> getContainerEntity ( ) ; if ( $ container instanceof Comment ) { return $ container -> getURL ( ) ; } return elgg_normalize_url ( implode ( '/' , array ( 'stream' , 'comments' , $ entity -> container_guid , $ entity -> guid , ) ) ) . "#elgg-object-$entity->guid" ; } else if ( $ entity instanceof RiverObject ) { return elgg_normalize_url ( implode ( '/' , array ( 'stream' , 'view' , $ entity -> guid ) ) ) ; } return $ url ; }
|
Handles entity URLs
|
974
|
public static function iconUrlHandler ( $ hook , $ type , $ url , $ params ) { $ entity = elgg_extract ( 'entity' , $ params ) ; if ( $ entity instanceof Comment ) { $ owner = $ entity -> getOwnerEntity ( ) ; if ( ! $ owner ) { return ; } return $ owner -> getIconURL ( $ params ) ; } return $ url ; }
|
Replaces comment icons
|
975
|
protected function bootstrapProgressBar ( ProgressBarInterface $ progressBar ) { $ span = static :: coreHTMLElement ( "span" , $ progressBar -> getValue ( ) . "%" , [ "class" => "sr-only" ] ) ; $ attributes = [ ] ; $ attributes [ "class" ] = [ "progress-bar" , ProgressBarRenderer :: renderType ( $ progressBar ) ] ; $ attributes [ "class" ] [ ] = ProgressBarRenderer :: renderStriped ( $ progressBar ) ; $ attributes [ "class" ] [ ] = ProgressBarRenderer :: renderAnimated ( $ progressBar ) ; $ attributes [ "style" ] = ProgressBarRenderer :: renderStyle ( $ progressBar ) ; $ attributes [ "role" ] = "progressbar" ; $ attributes [ "aria-valuenow" ] = $ progressBar -> getValue ( ) ; $ attributes [ "aria-valuemin" ] = $ progressBar -> getMin ( ) ; $ attributes [ "aria-valuemax" ] = $ progressBar -> getMax ( ) . "%" ; $ innerHTML = ProgressBarRenderer :: renderContent ( $ progressBar , $ span ) ; $ div = static :: coreHTMLElement ( "div" , $ innerHTML , $ attributes ) ; return static :: coreHTMLElement ( "div" , $ div , [ "class" => "progress" ] ) ; }
|
Displays a Bootstrap progress bar .
|
976
|
public function bootstrapGridOffsetFunction ( array $ args = [ ] ) { return $ this -> bootstrapGrid ( ArrayHelper :: get ( $ args , "lgOffset" ) , ArrayHelper :: get ( $ args , "mdOffset" ) , ArrayHelper :: get ( $ args , "smOffset" ) , ArrayHelper :: get ( $ args , "xsOffset" ) , ArrayHelper :: get ( $ args , "recopyOffset" , false ) , "offset" ) ; }
|
Displays a Bootstrap grid with offset .
|
977
|
public function bootstrapGridPullFunction ( array $ args = [ ] ) { return $ this -> bootstrapGrid ( ArrayHelper :: get ( $ args , "lgPull" ) , ArrayHelper :: get ( $ args , "mdPull" ) , ArrayHelper :: get ( $ args , "smPull" ) , ArrayHelper :: get ( $ args , "xsPull" ) , ArrayHelper :: get ( $ args , "recopyPull" , false ) , "pull" ) ; }
|
Displays a Bootstrap grid with pull .
|
978
|
public function bootstrapGridPushFunction ( array $ args = [ ] ) { return $ this -> bootstrapGrid ( ArrayHelper :: get ( $ args , "lgPush" ) , ArrayHelper :: get ( $ args , "mdPush" ) , ArrayHelper :: get ( $ args , "smPush" ) , ArrayHelper :: get ( $ args , "xsPush" ) , ArrayHelper :: get ( $ args , "recopyPush" , false ) , "push" ) ; }
|
Displays a Bootstrap grid with push .
|
979
|
public function bootstrapGridStackedFunction ( array $ args = [ ] ) { return $ this -> bootstrapGrid ( ArrayHelper :: get ( $ args , "lg" ) , ArrayHelper :: get ( $ args , "md" ) , ArrayHelper :: get ( $ args , "sm" ) , ArrayHelper :: get ( $ args , "xs" ) , ArrayHelper :: get ( $ args , "recopy" , false ) , "" ) ; }
|
Displays a Bootstrap grid with stacked - to - horizontal .
|
980
|
public static function fromArray ( array $ options = [ ] ) : self { return new self ( $ options [ 'authorization_code_ttl' ] ?? 120 , $ options [ 'access_token_ttl' ] ?? 3600 , $ options [ 'refresh_token_ttl' ] ?? 86400 , $ options [ 'rotate_refresh_tokens' ] ?? false , $ options [ 'revoke_rotated_refresh_tokens' ] ?? true , $ options [ 'owner_callable' ] ?? null , $ options [ 'grants' ] ?? [ ] , $ options [ 'owner_request_attribute' ] ?? 'owner' , $ options [ 'token_request_attribute' ] ?? 'oauth_token' ) ; }
|
Set one or more configuration properties
|
981
|
public function add ( array $ parameters ) { if ( ! array_key_exists ( 'name' , $ parameters ) || ! is_string ( $ parameters [ 'name' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the name of the SSH Key.' ) ; } if ( ! array_key_exists ( 'ssh_pub_key' , $ parameters ) || ! is_string ( $ parameters [ 'ssh_pub_key' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the SSH key.' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( null , SSHKeysActions :: ACTION_ADD , $ parameters ) ) ; }
|
Adds a new public SSH key to your account . The array requires name and ssh_pub_key keys .
|
982
|
public function edit ( $ sshKeyId , array $ parameters ) { if ( ! array_key_exists ( 'ssh_pub_key' , $ parameters ) || ! is_string ( $ parameters [ 'ssh_pub_key' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the new public SSH Key.' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( $ sshKeyId , SSHKeysActions :: ACTION_EDIT , $ parameters ) ) ; }
|
Edits an existing public SSH key in your account . The array requires ssh_pub_key key .
|
983
|
public function make ( $ path , $ name , array $ options = [ ] ) { $ options += [ 'middleware' => null , 'prefix' => null ] ; $ parsedRoutes = $ this -> getParsedRoutes ( $ options [ 'middleware' ] , $ options [ 'prefix' ] ) ; $ template = $ this -> file -> get ( __DIR__ . '/templates/Router.js' ) ; $ template = str_replace ( "routes: null," , 'routes: ' . json_encode ( $ parsedRoutes ) . ',' , $ template ) ; $ template = str_replace ( "'Router'" , "'" . $ options [ 'object' ] . "'" , $ template ) ; if ( $ this -> file -> isWritable ( $ path ) ) { $ filename = $ path . '/' . $ name ; return $ this -> file -> put ( $ filename , $ template ) !== false ; } return false ; }
|
Compile routes template and generate
|
984
|
private function bootstrapBreadcrumb ( NavigationNode $ node , $ last ) { $ attributes = true === $ node -> getActive ( ) && true === $ last ? [ "class" => "active" ] : [ ] ; $ content = $ this -> getTranslator ( ) -> trans ( $ node -> getId ( ) ) ; $ innerHTML = true === $ last ? $ content : static :: coreHTMLElement ( "a" , $ content , [ "href" => $ node -> getUri ( ) ] ) ; return static :: coreHTMLElement ( "li" , $ innerHTML , $ attributes ) ; }
|
Displays a Bootstrap breadcrumb .
|
985
|
public function respond ( array $ data , $ status = 200 , $ code , array $ headers = [ ] , $ options = 0 ) { return $ this -> response -> json ( array_merge ( compact ( 'status' , 'code' ) , $ data ) , $ status , $ headers , $ options ) ; }
|
Respond with a json response .
|
986
|
protected function buildRecordsQuery ( $ domain , $ id = null , $ action = null , array $ parameters = array ( ) ) { $ parameters = http_build_query ( array_merge ( $ parameters , $ this -> credentials ) ) ; $ query = sprintf ( "%s/%s/%s" , $ this -> apiUrl , $ domain , DomainsActions :: ACTION_RECORDS ) ; $ query = $ id ? sprintf ( "%s/%s" , $ query , $ id ) : $ query ; $ query = $ action ? sprintf ( "%s/%s/?%s" , $ query , $ action , $ parameters ) : sprintf ( "%s/?%s" , $ query , $ parameters ) ; return $ query ; }
|
Builds the records API url according to the parameters .
|
987
|
protected function checkParameters ( array $ parameters ) { if ( ! array_key_exists ( 'record_type' , $ parameters ) ) { throw new \ InvalidArgumentException ( 'You need to provide the record_type.' ) ; } if ( ! in_array ( $ parameters [ 'record_type' ] , array ( 'A' , 'CNAME' , 'NS' , 'TXT' , 'MX' , 'SRV' ) ) ) { throw new \ InvalidArgumentException ( 'The record_type can only be A, CNAME, NS, TXT, MX or SRV' ) ; } if ( ! array_key_exists ( 'data' , $ parameters ) || ! is_string ( $ parameters [ 'data' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the data value of the record.' ) ; } if ( in_array ( $ parameters [ 'record_type' ] , array ( 'A' , 'CNAME' , 'TXT' , 'SRV' ) ) ) { if ( ! array_key_exists ( 'name' , $ parameters ) || ! is_string ( $ parameters [ 'name' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the name string if the record_type is A, CNAME, TXT or SRV.' ) ; } } if ( in_array ( $ parameters [ 'record_type' ] , array ( 'SRV' , 'MX' ) ) ) { if ( ! array_key_exists ( 'priority' , $ parameters ) || ! is_int ( $ parameters [ 'priority' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the priority integer if the record_type is SRV or MX.' ) ; } } if ( 'SRV' === $ parameters [ 'record_type' ] ) { if ( ! array_key_exists ( 'port' , $ parameters ) || ! is_int ( $ parameters [ 'port' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the port integer if the record_type is SRV.' ) ; } } if ( 'SRV' === $ parameters [ 'record_type' ] ) { if ( ! array_key_exists ( 'weight' , $ parameters ) || ! is_int ( $ parameters [ 'weight' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the weight integer if the record_type is SRV.' ) ; } } }
|
Check submitted parameters .
|
988
|
public function newRecord ( $ domain , array $ parameters ) { $ this -> checkParameters ( $ parameters ) ; return $ this -> processQuery ( $ this -> buildRecordsQuery ( $ domain , null , RecordsActions :: ACTION_ADD , $ parameters ) ) ; }
|
Adds a new record to a specific domain .
|
989
|
public function editRecord ( $ domain , $ recordId , array $ parameters ) { $ this -> checkParameters ( $ parameters ) ; return $ this -> processQuery ( $ this -> buildRecordsQuery ( $ domain , $ recordId , RecordsActions :: ACTION_EDIT , $ parameters ) ) ; }
|
Edits a record to a specific domain .
|
990
|
public function destroyRecord ( $ domain , $ recordId ) { return $ this -> processQuery ( $ this -> buildRecordsQuery ( $ domain , $ recordId , RecordsActions :: ACTION_DESTROY ) ) ; }
|
Deletes the specified domain record .
|
991
|
protected function buildQuery ( $ id = null , $ action = null , array $ parameters = array ( ) ) { $ parameters = http_build_query ( array_merge ( $ parameters , $ this -> credentials ) ) ; $ query = $ id ? sprintf ( "%s/%s" , $ this -> apiUrl , $ id ) : $ this -> apiUrl ; $ query = $ action ? sprintf ( "%s/%s/?%s" , $ query , $ action , $ parameters ) : sprintf ( "%s/?%s" , $ query , $ parameters ) ; return $ query ; }
|
Builds the API url according to the parameters .
|
992
|
protected function processQuery ( $ query ) { if ( null === $ processed = json_decode ( $ this -> adapter -> getContent ( $ query ) ) ) { throw new \ RuntimeException ( sprintf ( "Impossible to process this query: %s" , $ query ) ) ; } if ( 'ERROR' === $ processed -> status ) { if ( isset ( $ processed -> error_message ) ) { $ errorMessage = $ processed -> error_message ; } if ( isset ( $ processed -> message ) ) { $ errorMessage = $ processed -> message ; } throw new \ RuntimeException ( sprintf ( "%s: %s" , $ errorMessage , $ query ) ) ; } return $ processed ; }
|
Processes the query .
|
993
|
public static function deleteRiverObject ( $ event , $ type , $ river ) { $ ia = elgg_set_ignore_access ( true ) ; $ guid = InteractionsCache :: getInstance ( ) -> getGuidFromRiverId ( $ river -> id ) ; if ( $ guid ) { $ object = get_entity ( $ guid ) ; if ( $ object ) { $ object -> delete ( ) ; } } elgg_set_ignore_access ( $ ia ) ; }
|
Deletes a commentable object associated with river items whose object is not ElggObject
|
994
|
public static function createActionableRiverObject ( ElggRiverItem $ river ) { if ( ! $ river instanceof ElggRiverItem ) { return false ; } $ object = $ river -> getObjectEntity ( ) ; $ views = self :: getActionableViews ( ) ; if ( ! in_array ( $ river -> view , $ views ) ) { return $ object ; } $ access_id = $ object -> access_id ; if ( $ object instanceof ElggUser ) { $ access_id = ACCESS_FRIENDS ; } else if ( $ object instanceof ElggGroup ) { $ access_id = $ object -> group_acl ; } $ ia = elgg_set_ignore_access ( true ) ; $ object = new RiverObject ( ) ; $ object -> owner_guid = $ river -> subject_guid ; $ object -> container_guid = $ object -> guid ; $ object -> access_id = $ access_id ; $ object -> river_id = $ river -> id ; $ object -> save ( ) ; elgg_set_ignore_access ( $ ia ) ; return $ object ; }
|
Creates an object associated with a river item for commenting and other purposes This is a workaround for river items that do not have an object or have an object that is group or user
|
995
|
public static function getRiverObject ( ElggRiverItem $ river ) { if ( ! $ river instanceof ElggRiverItem ) { return false ; } $ object = $ river -> getObjectEntity ( ) ; $ views = self :: getActionableViews ( ) ; if ( in_array ( $ river -> view , $ views ) ) { $ ia = elgg_set_ignore_access ( true ) ; $ guid = InteractionsCache :: getInstance ( ) -> getGuidFromRiverId ( $ river -> id ) ; if ( ! $ guid ) { $ object = InteractionsService :: createActionableRiverObject ( $ river ) ; $ guid = $ object -> guid ; } elgg_set_ignore_access ( $ ia ) ; $ object = get_entity ( $ guid ) ; } if ( $ object instanceof ElggEntity ) { $ object -> setVolatileData ( 'river_item' , $ river ) ; } return $ object ; }
|
Get an actionable object associated with the river item This could be a river object entity or a special entity that was created for this river item
|
996
|
public static function getStats ( $ entity ) { if ( ! $ entity instanceof ElggEntity ) { return array ( ) ; } $ stats = array ( 'comments' => array ( 'count' => $ entity -> countComments ( ) ) , 'likes' => array ( 'count' => $ entity -> countAnnotations ( 'likes' ) , 'state' => ( elgg_annotation_exists ( $ entity -> guid , 'likes' ) ) ? 'after' : 'before' , ) ) ; return elgg_trigger_plugin_hook ( 'get_stats' , 'interactions' , array ( 'entity' => $ entity ) , $ stats ) ; }
|
Get interaction statistics
|
997
|
public static function getCommentsSort ( ) { $ user_setting = elgg_get_plugin_user_setting ( 'comments_order' , 0 , 'hypeInteractions' ) ; $ setting = $ user_setting ? : elgg_get_plugin_setting ( 'comments_order' , 'hypeInteractions' ) ; if ( $ setting == 'asc' ) { $ setting = 'time_created::asc' ; } else if ( $ setting == 'desc' ) { $ setting = 'time_created::desc' ; } return $ setting ; }
|
Get configured comments order
|
998
|
public static function getLimit ( $ partial = true ) { if ( $ partial ) { $ limit = elgg_get_plugin_setting ( 'comments_limit' , 'hypeInteractions' ) ; return $ limit ? : 3 ; } else { $ limit = elgg_get_plugin_setting ( 'comments_load_limit' , 'hypeInteractions' ) ; return min ( max ( ( int ) $ limit , 20 ) , 200 ) ; } }
|
Get number of comments to show
|
999
|
public static function calculateOffset ( $ count , $ limit , $ comment = null ) { $ order = self :: getCommentsSort ( ) ; $ style = self :: getLoadStyle ( ) ; if ( $ comment instanceof Comment ) { $ thread = new Thread ( $ comment ) ; $ offset = $ thread -> getOffset ( $ limit , $ order ) ; } else if ( ( $ order == 'time_created::asc' && $ style == 'load_older' ) || ( $ order == 'time_created::desc' && $ style == 'load_newer' ) ) { $ offset = $ count - $ limit ; if ( $ offset < 0 ) { $ offset = 0 ; } } else { $ offset = 0 ; } return ( int ) $ offset ; }
|
Calculate offset till the page that contains the comment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.