idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
24,200
public function setOptions ( array $ options ) { foreach ( $ options as $ key => $ value ) { if ( in_array ( strtolower ( $ key ) , $ this -> _skipOptions ) ) { continue ; } $ method = 'set' . ucfirst ( $ key ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( $ value ) ; } } return $ this ; }
Set options via an array
24,201
private function selectColumnToExclude ( $ columnToFilter , $ row ) { if ( $ row -> hasColumn ( $ columnToFilter ) ) { return $ columnToFilter ; } $ columnIdToName = Metrics :: getMappingFromNameToId ( ) ; if ( isset ( $ columnIdToName [ $ columnToFilter ] ) ) { $ column = $ columnIdToName [ $ columnToFilter ] ; if ( $...
Sets the column to be used for Excluding low population
24,202
private function sumTable ( $ table ) { $ metadata = $ table -> getMetadata ( DataTable :: COLUMN_AGGREGATION_OPS_METADATA_NAME ) ; $ enableCopyMetadata = false ; foreach ( $ table -> getRowsWithoutSummaryRow ( ) as $ row ) { $ this -> sumRow ( $ row , $ enableCopyMetadata , $ metadata ) ; } $ summaryRow = $ table -> g...
Sums a tables row with this one .
24,203
public static function getDimensions ( Plugin $ plugin ) { $ dimensions = $ plugin -> findMultipleComponents ( 'Columns' , '\\Piwik\\Plugin\\Dimension\\VisitDimension' ) ; $ instances = array ( ) ; foreach ( $ dimensions as $ dimension ) { $ instances [ ] = new $ dimension ( ) ; } return $ instances ; }
Get all visit dimensions that are defined by the given plugin .
24,204
public static function enableMaintenanceMode ( ) { $ config = Config :: getInstance ( ) ; $ tracker = $ config -> Tracker ; $ tracker [ 'record_statistics' ] = 0 ; $ config -> Tracker = $ tracker ; $ general = $ config -> General ; $ general [ 'maintenance_mode' ] = 1 ; $ config -> General = $ general ; $ config -> for...
Enables maintenance mode . Should be used for updates where Piwik will be unavailable for a large amount of time .
24,205
public function isEnabled ( ) { $ isEnabled = ( bool ) Config :: getInstance ( ) -> General [ 'enable_update_communication' ] ; if ( $ isEnabled === true && SettingsPiwik :: isInternetEnabled ( ) === true ) { return true ; } return false ; }
Checks whether update communication in general is enabled or not .
24,206
protected function sendEmailNotification ( $ subject , $ message ) { $ superUsers = UsersManagerApi :: getInstance ( ) -> getUsersHavingSuperUserAccess ( ) ; foreach ( $ superUsers as $ superUser ) { $ mail = new Mail ( ) ; $ mail -> setDefaultFromPiwik ( ) ; $ mail -> addTo ( $ superUser [ 'email' ] ) ; $ mail -> setS...
Send an email notification to all super users .
24,207
public function loadYmlData ( $ yml ) { $ searchEngines = \ Spyc :: YAMLLoadString ( $ yml ) ; $ this -> definitionList = $ this -> transformData ( $ searchEngines ) ; return $ this -> definitionList ; }
Parses the given YML string and caches the resulting definitions
24,208
public function isSocialUrl ( $ url , $ socialName = false ) { foreach ( $ this -> getDefinitions ( ) as $ domain => $ name ) { if ( preg_match ( '/(^|[\.\/])' . $ domain . '([\.\/]|$)/' , $ url ) && ( $ socialName === false || $ name == $ socialName ) ) { return true ; } } return false ; }
Returns true if a URL belongs to a social network false if otherwise .
24,209
public function getSocialNetworkFromDomain ( $ url ) { foreach ( $ this -> getDefinitions ( ) as $ domain => $ name ) { if ( preg_match ( '/(^|[\.\/])' . $ domain . '([\.\/]|$)/' , $ url ) ) { return $ name ; } } return Piwik :: translate ( 'General_Unknown' ) ; }
Get s social network name from URL .
24,210
public function getMainUrl ( $ url ) { $ social = $ this -> getSocialNetworkFromDomain ( $ url ) ; foreach ( $ this -> getDefinitions ( ) as $ domain => $ name ) { if ( $ name == $ social ) { return $ domain ; } } return $ url ; }
Returns the main url of the social network the given url matches
24,211
public function getMainUrlFromName ( $ social ) { foreach ( $ this -> getDefinitions ( ) as $ domain => $ name ) { if ( $ name == $ social ) { return $ domain ; } } return null ; }
Returns the main url of the given social network
24,212
public function getLogoFromUrl ( $ domain ) { $ social = $ this -> getSocialNetworkFromDomain ( $ domain ) ; $ socialNetworks = $ this -> getDefinitions ( ) ; $ filePattern = 'plugins/Morpheus/icons/dist/socials/%s.png' ; $ socialDomains = array_keys ( $ socialNetworks , $ social ) ; foreach ( $ socialDomains as $ doma...
Return social network logo path by URL
24,213
public function renderWidgetContainer ( ) { Piwik :: checkUserHasSomeViewAccess ( ) ; $ this -> checkSitePermission ( ) ; $ view = new View ( '@CoreHome/widgetContainer' ) ; $ view -> isWidgetized = ( bool ) Common :: getRequestVar ( 'widget' , 0 , 'int' ) ; $ view -> containerId = Common :: getRequestVar ( 'containerI...
This is only used for exported widgets
24,214
public function getRowEvolutionPopover ( ) { $ rowEvolution = $ this -> makeRowEvolution ( $ isMulti = false ) ; $ view = new View ( '@CoreHome/getRowEvolutionPopover' ) ; return $ rowEvolution -> renderPopover ( $ this , $ view ) ; }
Render the entire row evolution popover for a single row
24,215
public function getMultiRowEvolutionPopover ( ) { $ rowEvolution = $ this -> makeRowEvolution ( $ isMulti = true ) ; $ view = new View ( '@CoreHome/getMultiRowEvolutionPopover' ) ; return $ rowEvolution -> renderPopover ( $ this , $ view ) ; }
Render the entire row evolution popover for multiple rows
24,216
public function getRowEvolutionGraph ( $ fetch = false , $ rowEvolution = null ) { if ( empty ( $ rowEvolution ) ) { $ label = Common :: getRequestVar ( 'label' , '' , 'string' ) ; $ isMultiRowEvolution = strpos ( $ label , ',' ) !== false ; $ rowEvolution = $ this -> makeRowEvolution ( $ isMultiRowEvolution , $ graphT...
Generic method to get an evolution graph or a sparkline for the row evolution popover
24,217
private function makeRowEvolution ( $ isMultiRowEvolution , $ graphType = null ) { if ( $ isMultiRowEvolution ) { return new MultiRowEvolution ( $ this -> idSite , $ this -> date , $ graphType ) ; } else { return new RowEvolution ( $ this -> idSite , $ this -> date , $ graphType ) ; } }
Utility function . Creates a RowEvolution instance .
24,218
public function checkForUpdates ( ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ this -> checkTokenInUrl ( ) ; UpdateCheck :: check ( $ force = false , UpdateCheck :: UI_CLICK_CHECK_INTERVAL ) ; $ view = new View ( '@CoreHome/checkForUpdates' ) ; $ this -> setGeneralVariablesView ( $ view ) ; return $ view -> render ...
Forces a check for updates and re - renders the header message .
24,219
public function redirectToPaypal ( ) { $ parameters = Request :: getRequestArrayFromString ( $ request = null ) ; foreach ( $ parameters as $ name => $ param ) { if ( $ name == 'idSite' || $ name == 'module' || $ name == 'action' ) { unset ( $ parameters [ $ name ] ) ; } } $ paypalParameters = [ "cmd" => "_s-xclick" ] ...
Redirects the user to a paypal so they can donate to Piwik .
24,220
private function renderArray ( $ array , $ prefixLines ) { $ isAssociativeArray = Piwik :: isAssociativeArray ( $ array ) ; $ wrapInRow = $ prefixLines === "\t" && self :: shouldWrapArrayBeforeRendering ( $ array , $ wrapSingleValues = false , $ isAssociativeArray ) ; $ result = "" ; if ( $ wrapInRow ) { $ result .= "$...
Renders an array as XML .
24,221
protected function renderDataTableMap ( $ table , $ array , $ prefixLines = "" ) { $ firstTable = current ( $ array ) ; if ( ! is_array ( $ firstTable ) ) { $ xml = '' ; $ nameDescriptionAttribute = $ table -> getKeyName ( ) ; foreach ( $ array as $ valueAttribute => $ value ) { if ( empty ( $ value ) ) { $ xml .= $ pr...
Computes the output for the given data table array
24,222
protected function renderDataTable ( $ array , $ prefixLine = "" ) { $ columnsHaveInvalidChars = $ this -> areTableLabelsInvalidXmlTagNames ( reset ( $ array ) ) ; $ out = '' ; foreach ( $ array as $ rowId => $ row ) { if ( ! is_array ( $ row ) ) { $ value = self :: formatValueXml ( $ row ) ; if ( strlen ( $ value ) ==...
Computes the output for the given data array
24,223
private static function isValidXmlTagName ( $ str ) { static $ validTagRegex = null ; if ( $ validTagRegex === null ) { $ invalidTagChars = "!\"#$%&'()*+,\\/;<=>?@[\\]\\\\^`{|}~" ; $ invalidTagStartChars = $ invalidTagChars . "\\-.0123456789" ; $ validTagRegex = "/^[^" . $ invalidTagStartChars . "][^" . $ invalidTagCha...
Returns true if a string is a valid XML tag name false if otherwise .
24,224
public function _sendMail ( ) { if ( ! ( $ this -> _connection instanceof Zend_Mail_Protocol_Smtp ) ) { $ connectionClass = 'Zend_Mail_Protocol_Smtp' ; if ( $ this -> _auth ) { $ connectionClass .= '_Auth_' . ucwords ( $ this -> _auth ) ; } if ( ! class_exists ( $ connectionClass ) ) { Zend_Loader :: loadClass ( $ conn...
Send an email via the SMTP connection protocol
24,225
public function getValue ( ) { $ values = array ( ) ; foreach ( $ this as $ child ) { $ value = $ child -> getValue ( ) ; if ( null !== $ value ) { if ( $ child instanceof HTML_QuickForm2_Container && ! $ child -> prependsName ( ) ) { $ values = self :: arrayMerge ( $ values , $ value ) ; } else { $ name = $ child -> g...
Returns the element s value
24,226
public function getElementById ( $ id ) { foreach ( $ this -> getRecursiveIterator ( ) as $ element ) { if ( $ id == $ element -> getId ( ) ) { return $ element ; } } return null ; }
Returns an element if its id is found
24,227
public function getElementsByName ( $ name ) { $ found = array ( ) ; foreach ( $ this -> getRecursiveIterator ( ) as $ element ) { if ( $ element -> getName ( ) == $ name ) { $ found [ ] = $ element ; } } return $ found ; }
Returns an array of elements which name corresponds to element
24,228
public function render ( HTML_QuickForm2_Renderer $ renderer ) { foreach ( $ this -> rules as $ rule ) { if ( $ rule [ 1 ] & HTML_QuickForm2_Rule :: RUNAT_CLIENT ) { $ renderer -> getJavascriptBuilder ( ) -> addRule ( $ rule [ 0 ] ) ; } } $ renderer -> startContainer ( $ this ) ; foreach ( $ this as $ element ) { $ ele...
Renders the container using the given renderer
24,229
public function getJavascriptValue ( ) { $ args = array ( ) ; foreach ( $ this as $ child ) { if ( $ child instanceof HTML_QuickForm2_Container ) { $ args [ ] = $ child -> getJavascriptValue ( ) ; } else { $ args [ ] = "'" . $ child -> getId ( ) . "'" ; } } return 'qf.form.getContainerValue(' . implode ( ', ' , $ args ...
Returns Javascript code for getting the element s value
24,230
public function filter ( $ translations ) { foreach ( $ translations as $ pluginName => $ pluginTranslations ) { foreach ( $ pluginTranslations as $ key => $ translation ) { $ baseTranslation = '' ; if ( isset ( $ this -> baseTranslations [ $ pluginName ] [ $ key ] ) ) { $ baseTranslation = $ this -> baseTranslations [...
Removes all unnecassary whitespaces and newlines from the given translations
24,231
public function getStatus ( ) { $ status = self :: STATUS_OK ; foreach ( $ this -> getItems ( ) as $ item ) { if ( $ item -> getStatus ( ) === self :: STATUS_ERROR ) { return self :: STATUS_ERROR ; } if ( $ item -> getStatus ( ) === self :: STATUS_WARNING ) { $ status = self :: STATUS_WARNING ; } } return $ status ; }
Returns the worst status of the items .
24,232
public function filter ( $ translations ) { $ translationsBefore = $ translations ; foreach ( $ translations as $ plugin => & $ pluginTranslations ) { $ pluginTranslations = array_filter ( $ pluginTranslations , function ( $ value ) { return ! empty ( $ value ) && '' != trim ( $ value ) ; } ) ; $ diff = array_diff ( $ ...
Removes all empty translations
24,233
public function getLayoutForUser ( $ login , $ idDashboard ) { $ return = $ this -> getModel ( ) -> getLayoutForUser ( $ login , $ idDashboard ) ; if ( count ( $ return ) == 0 ) { return false ; } return $ return [ 0 ] [ 'layout' ] ; }
Returns the layout in the DB for the given user or false if the layout has not been set yet . Parameters must be checked BEFORE this function call
24,234
protected function onAttributeChange ( $ name , $ value = null ) { if ( 'name' == $ name ) { if ( null === $ value ) { throw new HTML_QuickForm2_InvalidArgumentException ( "Required attribute 'name' can not be removed" ) ; } else { $ this -> setName ( $ value ) ; } } elseif ( 'id' == $ name ) { if ( null === $ value ) ...
Intercepts setting name and id attributes
24,235
protected static function generateId ( $ elementName ) { $ stop = ! self :: getOption ( 'id_force_append_index' ) ; $ tokens = strlen ( $ elementName ) ? explode ( '[' , str_replace ( ']' , '' , $ elementName ) ) : ( $ stop ? array ( 'qfauto' , '' ) : array ( 'qfauto' ) ) ; $ container = & self :: $ ids ; $ id = '' ; d...
Generates an id for the element
24,236
protected static function storeId ( $ id ) { $ tokens = explode ( '-' , $ id ) ; $ container = & self :: $ ids ; do { $ token = array_shift ( $ tokens ) ; if ( ! isset ( $ container [ $ token ] ) ) { $ container [ $ token ] = array ( ) ; } $ container = & $ container [ $ token ] ; } while ( ! empty ( $ tokens ) ) ; }
Stores the explicitly given id to prevent duplicate id generation
24,237
public function setId ( $ id = null ) { if ( is_null ( $ id ) ) { $ id = self :: generateId ( $ this -> getName ( ) ) ; } else { self :: storeId ( $ id ) ; } $ this -> attributes [ 'id' ] = ( string ) $ id ; return $ this ; }
Sets the elements id
24,238
public function toggleFrozen ( $ freeze = null ) { $ old = $ this -> frozen ; if ( null !== $ freeze ) { $ this -> frozen = ( bool ) $ freeze ; } return $ old ; }
Changes the element s frozen status
24,239
public function persistentFreeze ( $ persistent = null ) { $ old = $ this -> persistent ; if ( null !== $ persistent ) { $ this -> persistent = ( bool ) $ persistent ; } return $ old ; }
Changes the element s persistent freeze behaviour
24,240
protected function setContainer ( HTML_QuickForm2_Container $ container = null ) { if ( null !== $ container ) { $ check = $ container ; do { if ( $ this === $ check ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'Cannot set an element or its child as its own container' ) ; } } while ( $ check = $ check -> ge...
Adds the link to the element containing current
24,241
public function addRule ( $ rule , $ messageOrRunAt = '' , $ options = null , $ runAt = HTML_QuickForm2_Rule :: RUNAT_SERVER ) { if ( $ rule instanceof HTML_QuickForm2_Rule ) { $ rule -> setOwner ( $ this ) ; $ runAt = '' == $ messageOrRunAt ? HTML_QuickForm2_Rule :: RUNAT_SERVER : $ messageOrRunAt ; } elseif ( is_stri...
Adds a validation rule
24,242
public function removeRule ( HTML_QuickForm2_Rule $ rule ) { foreach ( $ this -> rules as $ i => $ r ) { if ( $ r [ 0 ] === $ rule ) { unset ( $ this -> rules [ $ i ] ) ; break ; } } return $ rule ; }
Removes a validation rule
24,243
public function createRule ( $ type , $ message = '' , $ options = null ) { return HTML_QuickForm2_Factory :: createRule ( $ type , $ this , $ message , $ options ) ; }
Creates a validation rule
24,244
protected function applyFilters ( $ value ) { foreach ( $ this -> filters as $ filter ) { if ( is_array ( $ value ) && ! empty ( $ filter [ 'recursive' ] ) ) { array_walk_recursive ( $ value , array ( 'HTML_QuickForm2_Node' , 'applyFilter' ) , $ filter ) ; } else { self :: applyFilter ( $ value , null , $ filter ) ; } ...
Applies element filters on element value
24,245
public function postEvent ( $ eventName , $ params , $ pending = false , $ plugins = null ) { if ( $ pending ) { $ this -> pendingEvents [ ] = array ( $ eventName , $ params ) ; } $ manager = $ this -> pluginManager ; if ( empty ( $ plugins ) ) { $ plugins = $ manager -> getPluginsLoadedAndActivated ( ) ; } $ callbacks...
Triggers an event executing all callbacks associated with it .
24,246
public function postPendingEventsTo ( $ plugin ) { foreach ( $ this -> pendingEvents as $ eventInfo ) { list ( $ eventName , $ eventParams ) = $ eventInfo ; $ this -> postEvent ( $ eventName , $ eventParams , $ pending = false , array ( $ plugin ) ) ; } }
Re - posts all pending events to the given plugin .
24,247
public function render ( ) { $ data = $ this -> _config -> toArray ( ) ; $ sectionName = $ this -> _config -> getSectionName ( ) ; if ( is_string ( $ sectionName ) ) { $ data = array ( $ sectionName => $ data ) ; } $ arrayString = "<?php\n" . "return " . var_export ( $ data , true ) . ";\n" ; return $ arrayString ; }
Render a Zend_Config into a PHP Array config string .
24,248
public static function makeEmptyRow ( ) { return array ( Metrics :: INDEX_NB_UNIQ_VISITORS => 0 , Metrics :: INDEX_NB_VISITS => 0 , Metrics :: INDEX_NB_ACTIONS => 0 , Metrics :: INDEX_NB_USERS => 0 , Metrics :: INDEX_MAX_ACTIONS => 0 , Metrics :: INDEX_SUM_VISIT_LENGTH => 0 , Metrics :: INDEX_BOUNCE_COUNT => 0 , Metric...
Returns an empty row containing default metrics
24,249
public function sumMetrics ( $ label , $ row ) { foreach ( $ row as $ columnName => $ columnValue ) { if ( empty ( $ columnValue ) ) { continue ; } if ( empty ( $ this -> data [ $ label ] [ $ columnName ] ) ) { $ this -> data [ $ label ] [ $ columnName ] = 0 ; } if ( ! is_numeric ( $ columnValue ) ) { throw new Excepti...
Generic function that will sum all columns of the given row at the specified label s row .
24,250
protected function enrichWithConversions ( & $ data ) { foreach ( $ data as & $ values ) { if ( ! isset ( $ values [ Metrics :: INDEX_GOALS ] ) ) { continue ; } unset ( $ values [ Metrics :: INDEX_NB_VISITS_CONVERTED ] ) ; $ revenue = $ conversions = 0 ; foreach ( $ values [ Metrics :: INDEX_GOALS ] as $ idgoal => $ go...
Given an array of stats it will process the sum of goal conversions and sum of revenue and add it in the stats array in two new fields .
24,251
public static function isRowActions ( $ row ) { return ( count ( $ row ) == count ( static :: makeEmptyActionRow ( ) ) ) && isset ( $ row [ Metrics :: INDEX_NB_ACTIONS ] ) ; }
Returns true if the row looks like an Action metrics row
24,252
public function asDataTable ( ) { $ dataArray = $ this -> getDataArray ( ) ; $ dataArrayTwoLevels = $ this -> getDataArrayWithTwoLevels ( ) ; $ subtableByLabel = null ; if ( ! empty ( $ dataArrayTwoLevels ) ) { $ subtableByLabel = array ( ) ; foreach ( $ dataArrayTwoLevels as $ label => $ subTable ) { $ subtableByLabel...
Converts array to a datatable
24,253
public function invalidateArchivedReports ( $ idSites , $ dates , $ period = false , $ segment = false , $ cascadeDown = false ) { $ idSites = Site :: getIdSitesFromIdSitesString ( $ idSites ) ; if ( empty ( $ idSites ) ) { throw new Exception ( "Specify a value for &idSites= as a comma separated list of website IDs, f...
Invalidates report data forcing it to be recomputed during the next archiving run .
24,254
public function runCronArchiving ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ logger = StaticContainer :: get ( 'Psr\Log\LoggerInterface' ) ; $ handler = new StreamHandler ( 'php://output' , Logger :: INFO ) ; $ handler -> setFormatter ( StaticContainer :: get ( 'Piwik\Plugins\Monolog\Formatter\LineMessageFormatt...
Initiates cron archiving via web request .
24,255
public function deleteAllTrackingFailures ( ) { if ( Piwik :: hasUserSuperUserAccess ( ) ) { $ this -> trackingFailures -> deleteAllTrackingFailures ( ) ; } else { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ idSites = Access :: getInstance ( ) -> getSitesIdWithAdminAccess ( ) ; Piwik :: checkUserHasAdminAccess ( $ idS...
Deletes all tracking failures this user has at least admin access to . A super user will also delete tracking failures for sites that don t exist .
24,256
public function deleteTrackingFailure ( $ idSite , $ idFailure ) { $ idSite = ( int ) $ idSite ; Piwik :: checkUserHasAdminAccess ( $ idSite ) ; $ this -> trackingFailures -> deleteTrackingFailure ( $ idSite , $ idFailure ) ; }
Deletes a specific tracking failure
24,257
public function getTrackingFailures ( ) { if ( Piwik :: hasUserSuperUserAccess ( ) ) { $ failures = $ this -> trackingFailures -> getAllFailures ( ) ; } else { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ idSites = Access :: getInstance ( ) -> getSitesIdWithAdminAccess ( ) ; Piwik :: checkUserHasAdminAccess ( $ idSites...
Get all tracking failures . A user retrieves only tracking failures for sites with at least admin access . A super user will also retrieve failed requests for sites that don t exist .
24,258
private function getDatesToInvalidateFromString ( $ dates ) { $ toInvalidate = array ( ) ; $ invalidDates = array ( ) ; $ dates = explode ( ',' , trim ( $ dates ) ) ; $ dates = array_unique ( $ dates ) ; foreach ( $ dates as $ theDate ) { $ theDate = trim ( $ theDate ) ; try { $ date = Date :: factory ( $ theDate ) ; }...
Ensure the specified dates are valid . Store invalid date so we can log them
24,259
public function filter ( $ className , $ parameters = array ( ) ) { if ( $ className instanceof \ Closure || is_array ( $ className ) ) { array_unshift ( $ parameters , $ this ) ; call_user_func_array ( $ className , $ parameters ) ; return ; } if ( in_array ( $ className , $ this -> disabledFilters ) ) { return ; } if...
Applies a filter to this datatable .
24,260
public function filterSubtables ( $ className , $ parameters = array ( ) ) { foreach ( $ this -> getRowsWithoutSummaryRow ( ) as $ row ) { $ subtable = $ row -> getSubtable ( ) ; if ( $ subtable ) { $ subtable -> filter ( $ className , $ parameters ) ; $ subtable -> filterSubtables ( $ className , $ parameters ) ; } } ...
Applies a filter to all subtables but not to this datatable .
24,261
public function addDataTable ( DataTable $ tableToSum ) { if ( $ tableToSum instanceof Simple ) { if ( $ tableToSum -> getRowsCount ( ) > 1 ) { throw new Exception ( "Did not expect a Simple table with more than one row in addDataTable()" ) ; } $ row = $ tableToSum -> getFirstRow ( ) ; $ this -> aggregateRowFromSimpleT...
Sums a DataTable to this one .
24,262
public function rebuildIndex ( ) { $ this -> rowsIndexByLabel = array ( ) ; $ this -> rebuildIndexContinuously = true ; foreach ( $ this -> rows as $ id => $ row ) { $ label = $ row -> getColumn ( 'label' ) ; if ( $ label !== false ) { $ this -> rowsIndexByLabel [ $ label ] = $ id ; } } if ( $ this -> summaryRow ) { $ ...
Rebuilds the index used to lookup a row by label
24,263
public function addRow ( Row $ row ) { if ( $ this -> maximumAllowedRows > 0 && $ this -> getRowsCount ( ) >= $ this -> maximumAllowedRows - 1 ) { if ( $ this -> summaryRow === null ) { $ columns = array ( 'label' => self :: LABEL_SUMMARY_ROW ) + $ row -> getColumns ( ) ; $ this -> addSummaryRow ( new Row ( array ( Row...
Adds a row to this table .
24,264
public function addSummaryRow ( Row $ row ) { $ this -> summaryRow = $ row ; if ( ! $ this -> indexNotUpToDate && $ this -> rebuildIndexContinuously ) { $ label = $ row -> getColumn ( 'label' ) ; if ( $ label !== false ) { $ this -> rowsIndexByLabel [ $ label ] = self :: ID_SUMMARY_ROW ; } } return $ row ; }
Sets the summary row .
24,265
public function getColumn ( $ name ) { $ columnValues = array ( ) ; foreach ( $ this -> getRows ( ) as $ row ) { $ columnValues [ ] = $ row -> getColumn ( $ name ) ; } return $ columnValues ; }
Returns an array containing all column values for the requested column .
24,266
public function getColumns ( ) { $ result = array ( ) ; foreach ( $ this -> getRows ( ) as $ row ) { $ columns = $ row -> getColumns ( ) ; if ( ! empty ( $ columns ) ) { $ result = array_keys ( $ columns ) ; break ; } } foreach ( $ result as & $ column ) { if ( isset ( Metrics :: $ mappingFromIdToName [ $ column ] ) ) ...
Returns the names of every column this DataTable contains . This method will return the columns of the first row with data and will assume they occur in every other row as well .
24,267
public function getRowsMetadata ( $ name ) { $ metadataValues = array ( ) ; foreach ( $ this -> getRows ( ) as $ row ) { $ metadataValues [ ] = $ row -> getMetadata ( $ name ) ; } return $ metadataValues ; }
Returns an array containing the requested metadata value of each row .
24,268
public function getRowsCount ( ) { if ( is_null ( $ this -> summaryRow ) ) { return count ( $ this -> rows ) ; } else { return count ( $ this -> rows ) + 1 ; } }
Returns the number of rows in the table including the summary row .
24,269
public function getFirstRow ( ) { if ( count ( $ this -> rows ) == 0 ) { if ( ! is_null ( $ this -> summaryRow ) ) { return $ this -> summaryRow ; } return false ; } return reset ( $ this -> rows ) ; }
Returns the first row of the DataTable .
24,270
public function getLastRow ( ) { if ( ! is_null ( $ this -> summaryRow ) ) { return $ this -> summaryRow ; } if ( count ( $ this -> rows ) == 0 ) { return false ; } return end ( $ this -> rows ) ; }
Returns the last row of the DataTable . If there is a summary row it will always be considered the last row .
24,271
public function getRowsCountRecursive ( ) { $ totalCount = 0 ; foreach ( $ this -> rows as $ row ) { $ subTable = $ row -> getSubtable ( ) ; if ( $ subTable ) { $ count = $ subTable -> getRowsCountRecursive ( ) ; $ totalCount += $ count ; } } $ totalCount += $ this -> getRowsCount ( ) ; return $ totalCount ; }
Returns the number of rows in the entire DataTable hierarchy . This is the number of rows in this DataTable summed with the row count of each descendant subtable .
24,272
public function renameColumn ( $ oldName , $ newName ) { foreach ( $ this -> rows as $ row ) { $ row -> renameColumn ( $ oldName , $ newName ) ; $ subTable = $ row -> getSubtable ( ) ; if ( $ subTable ) { $ subTable -> renameColumn ( $ oldName , $ newName ) ; } } if ( ! is_null ( $ this -> summaryRow ) ) { $ this -> su...
Rename a column in every row . This change is applied recursively to all subtables .
24,273
public function deleteColumns ( $ names , $ deleteRecursiveInSubtables = false ) { foreach ( $ this -> rows as $ row ) { foreach ( $ names as $ name ) { $ row -> deleteColumn ( $ name ) ; } $ subTable = $ row -> getSubtable ( ) ; if ( $ subTable ) { $ subTable -> deleteColumns ( $ names , $ deleteRecursiveInSubtables )...
Deletes several columns by name in every row .
24,274
public function deleteRow ( $ id ) { if ( $ id === self :: ID_SUMMARY_ROW ) { $ this -> summaryRow = null ; return ; } if ( ! isset ( $ this -> rows [ $ id ] ) ) { throw new Exception ( "Trying to delete unknown row with idkey = $id" ) ; } unset ( $ this -> rows [ $ id ] ) ; }
Deletes a row by ID .
24,275
public static function isEqual ( DataTable $ table1 , DataTable $ table2 ) { $ table1 -> rebuildIndex ( ) ; $ table2 -> rebuildIndex ( ) ; if ( $ table1 -> getRowsCount ( ) != $ table2 -> getRowsCount ( ) ) { return false ; } $ rows1 = $ table1 -> getRows ( ) ; foreach ( $ rows1 as $ row1 ) { $ row2 = $ table2 -> getRo...
Returns true if both DataTable instances are exactly the same .
24,276
public function getSerialized ( $ maximumRowsInDataTable = null , $ maximumRowsInSubDataTable = null , $ columnToSortByBeforeTruncation = null , & $ aSerializedDataTable = array ( ) ) { static $ depth = 0 ; static $ subtableId = 0 ; if ( $ depth > self :: $ maximumDepthLevelAllowed ) { $ depth = 0 ; $ subtableId = 0 ; ...
Serializes an entire DataTable hierarchy and returns the array of serialized DataTables .
24,277
public function addRowsFromSerializedArray ( $ serialized ) { $ rows = $ this -> unserializeRows ( $ serialized ) ; if ( array_key_exists ( self :: ID_SUMMARY_ROW , $ rows ) ) { if ( is_array ( $ rows [ self :: ID_SUMMARY_ROW ] ) ) { $ this -> summaryRow = new Row ( $ rows [ self :: ID_SUMMARY_ROW ] ) ; } elseif ( isse...
Adds a set of rows from a serialized DataTable string .
24,278
public function addRowsFromArray ( $ array ) { foreach ( $ array as $ id => $ row ) { if ( is_array ( $ row ) ) { $ row = new Row ( $ row ) ; } if ( $ id == self :: ID_SUMMARY_ROW ) { $ this -> summaryRow = $ row ; } else { $ this -> addRow ( $ row ) ; } } }
Adds multiple rows from an array .
24,279
public function addRowsFromSimpleArray ( $ array ) { if ( count ( $ array ) === 0 ) { return ; } $ exceptionText = " Data structure returned is not convertible in the requested format." . " Try to call this method with the parameters '&format=original&serialize=1'" . "; you will get the original php data structure seri...
Adds multiple rows from an array containing arrays of column values .
24,280
public function setMetadataValues ( $ values ) { foreach ( $ values as $ name => $ value ) { $ this -> metadata [ $ name ] = $ value ; } }
Sets several metadata values by name .
24,281
public function walkPath ( $ path , $ missingRowColumns = false , $ maxSubtableRows = 0 ) { $ pathLength = count ( $ path ) ; $ table = $ this ; $ next = false ; for ( $ i = 0 ; $ i < $ pathLength ; ++ $ i ) { $ segment = $ path [ $ i ] ; $ next = $ table -> getRowFromLabel ( $ segment ) ; if ( $ next === false ) { if ...
Traverses a DataTable tree using an array of labels and returns the row it finds or false if it cannot find one . The number of path segments that were successfully walked is also returned .
24,282
public function mergeSubtables ( $ labelColumn = false , $ useMetadataColumn = false ) { $ result = new DataTable ( ) ; $ result -> setAllTableMetadata ( $ this -> getAllTableMetadata ( ) ) ; foreach ( $ this -> getRowsWithoutSummaryRow ( ) as $ row ) { $ subtable = $ row -> getSubtable ( ) ; if ( $ subtable !== false ...
Returns a new DataTable in which the rows of this table are replaced with the aggregatated rows of all its subtables .
24,283
private function checkFieldIsAvailable ( $ field , & $ availableTables ) { $ fieldParts = explode ( '.' , $ field ) ; $ table = count ( $ fieldParts ) == 2 ? $ fieldParts [ 0 ] : false ; $ table = preg_replace ( '/^[A-Z_]+\(/' , '' , $ table ) ; $ tableExists = ! $ table || in_array ( $ table , $ availableTables ) ; if...
Check whether the field is available If not add it to the available tables
24,284
private function escapeLikeString ( $ str ) { if ( false !== strpos ( $ str , '%' ) ) { $ str = str_replace ( "%" , "\%" , $ str ) ; } if ( false !== strpos ( $ str , '_' ) ) { $ str = str_replace ( "_" , "\_" , $ str ) ; } return $ str ; }
Escape the characters % and _ in the given string
24,285
protected function parseTree ( ) { $ string = $ this -> string ; if ( empty ( $ string ) ) { return array ( ) ; } $ tree = array ( ) ; $ i = 0 ; $ length = strlen ( $ string ) ; $ isBackslash = false ; $ operand = '' ; while ( $ i <= $ length ) { $ char = $ string [ $ i ] ; $ isAND = ( $ char == self :: AND_DELIMITER )...
Given a filter string will parse it into an array where each row contains the boolean operator applied to it and the operand
24,286
public function getSql ( ) { if ( $ this -> isEmpty ( ) ) { throw new Exception ( "Invalid segment, please specify a valid segment." ) ; } $ sql = '' ; $ subExpression = false ; foreach ( $ this -> tree as $ expression ) { $ operator = $ expression [ self :: INDEX_BOOL_OPERATOR ] ; $ operand = $ expression [ self :: IN...
Given the array of parsed boolean logic will return an array containing the full SQL string representing the filter the needed joins and the values to bind to the query
24,287
public static function initCorePiwikInTrackerMode ( ) { if ( SettingsServer :: isTrackerApiRequest ( ) && self :: $ initTrackerMode === false ) { self :: $ initTrackerMode = true ; require_once PIWIK_INCLUDE_PATH . '/core/Option.php' ; Access :: getInstance ( ) ; Config :: getInstance ( ) ; try { Db :: get ( ) ; } catc...
Used to initialize core Piwik components on a piwik . php request Eg . when cache is missed and we will be calling some APIs to generate cache
24,288
public function getUniqueId ( ) { $ parameters = $ this -> getParameters ( ) ; unset ( $ parameters [ 'module' ] ) ; unset ( $ parameters [ 'action' ] ) ; return WidgetsList :: getWidgetUniqueId ( $ this -> getModule ( ) , $ this -> getAction ( ) , $ parameters ) ; }
Returns the unique id of an widget based on module action and the set parameters .
24,289
public function updateUserWithoutCurrentPassword ( $ userLogin , $ password = false , $ email = false , $ alias = false , $ _isPasswordHashed = false ) { API :: $ UPDATE_USER_REQUIRE_PASSWORD_CONFIRMATION = false ; try { Request :: processRequest ( 'UsersManager.updateUser' , [ 'userLogin' => $ userLogin , 'password' =...
Use this method if you have to update the user without having the ability to ask the user for a password confirmation
24,290
public static function tableInsertBatchIterate ( $ tableName , $ fields , $ values , $ ignoreWhenDuplicate = true ) { $ fieldList = '(' . join ( ',' , $ fields ) . ')' ; $ ignore = $ ignoreWhenDuplicate ? 'IGNORE' : '' ; foreach ( $ values as $ row ) { $ query = "INSERT $ignore INTO " . $ tableName . " $fieldList...
Performs a batch insert into a specific table by iterating through the data
24,291
public function setDataSources ( array $ datasources ) { foreach ( $ datasources as $ ds ) { if ( ! $ ds instanceof HTML_QuickForm2_DataSource ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'Array should contain only DataSource instances' ) ; } } $ this -> datasources = $ datasources ; $ this -> updateValue (...
Replaces the list of form s data sources with a completely new one
24,292
public function render ( HTML_QuickForm2_Renderer $ renderer ) { $ renderer -> startForm ( $ this ) ; $ renderer -> getJavascriptBuilder ( ) -> startForm ( $ this ) ; foreach ( $ this as $ element ) { $ element -> render ( $ renderer ) ; } $ renderer -> finishForm ( $ this ) ; return $ renderer ; }
Renders the form using the given renderer
24,293
public function getPriority ( ) { if ( ! isset ( $ this -> priority ) ) { $ typeToPriority = array ( static :: CONTEXT_ERROR => static :: PRIORITY_MAX , static :: CONTEXT_WARNING => static :: PRIORITY_HIGH , static :: CONTEXT_SUCCESS => static :: PRIORITY_MIN , static :: CONTEXT_INFO => static :: PRIORITY_LOW ) ; if ( ...
Returns the notification s priority . If no priority has been set a priority will be set based on the notification s context .
24,294
public function isAvailable ( ) { if ( function_exists ( 'apache_get_modules' ) ) { foreach ( apache_get_modules ( ) as $ name ) { if ( strpos ( $ name , 'maxminddb' ) !== false ) { return true ; } } } $ settings = self :: getGeoIpServerVars ( ) ; $ available = array_key_exists ( $ settings [ self :: CONTINENT_CODE_KEY...
Checks if an mod_maxminddb has been installed and MMDB_ADDR server variable is defined .
24,295
public function isWorking ( ) { $ settings = self :: getGeoIpServerVars ( ) ; $ available = array_key_exists ( $ settings [ self :: CONTINENT_CODE_KEY ] , $ _SERVER ) || array_key_exists ( $ settings [ self :: COUNTRY_CODE_KEY ] , $ _SERVER ) || array_key_exists ( $ settings [ self :: REGION_CODE_KEY ] , $ _SERVER ) ||...
Returns true if the MMDB_ADDR server variable is defined .
24,296
public static function isSameOrAnonymizedIp ( $ ip , $ currentIp ) { $ ip = array_reverse ( explode ( '.' , $ ip ) ) ; $ currentIp = array_reverse ( explode ( '.' , $ currentIp ) ) ; if ( count ( $ ip ) != count ( $ currentIp ) ) { return false ; } foreach ( $ ip as $ i => $ byte ) { if ( $ byte == 0 ) { $ currentIp [ ...
Checks if two IP addresses are the same or if the first is the anonymized version of the other .
24,297
protected static function getGeoIpServerVars ( $ type = null ) { $ storedSettings = self :: getSystemSettingsValues ( ) ; if ( $ type === null ) { return $ storedSettings ; } if ( array_key_exists ( $ type , $ storedSettings ) ) { return $ storedSettings [ $ type ] ; } return '' ; }
Returns currently configured server variable name for given type
24,298
protected function purge ( array $ idArchivesToDelete , Date $ dateStart , $ reason ) { $ deletedRowCount = 0 ; if ( ! empty ( $ idArchivesToDelete ) ) { $ deletedRowCount = $ this -> deleteArchiveIds ( $ dateStart , $ idArchivesToDelete ) ; $ this -> logger -> info ( "Deleted {count} rows in archive tables (numeric + ...
Purge all numeric and blob archives with the given IDs from the database .
24,299
public function purgeArchivesWithPeriodRange ( Date $ date ) { $ numericTable = ArchiveTableCreator :: getNumericTable ( $ date ) ; $ blobTable = ArchiveTableCreator :: getBlobTable ( $ date ) ; $ deletedCount = $ this -> model -> deleteArchivesWithPeriod ( $ numericTable , $ blobTable , Piwik :: $ idPeriods [ 'range' ...
Deleting Custom Date Range reports after 1 day since they can be re - processed and would take up un - necessary space .