idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
24,700
public function describeTable ( $ tableName , $ schemaName = null ) { $ sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, c.typename, c.default, c.nulls, c.length, c.scale, c.identity, tc.type AS tabconsttype, k.colseq FROM syscat.columns c LE...
DB2 catalog lookup for describe table
24,701
public function lastSequenceId ( $ sequenceName ) { $ sql = 'SELECT PREVVAL FOR ' . $ this -> _adapter -> quoteIdentifier ( $ sequenceName ) . ' AS VAL FROM SYSIBM.SYSDUMMY1' ; $ value = $ this -> _adapter -> fetchOne ( $ sql ) ; return $ value ; }
DB2 - specific last sequence id
24,702
public static function excludeQueryParametersFromUrl ( $ originalUrl , $ idSite ) { $ originalUrl = self :: cleanupUrl ( $ originalUrl ) ; $ parsedUrl = @ parse_url ( $ originalUrl ) ; $ parsedUrl = self :: cleanupHostAndHashTag ( $ parsedUrl , $ idSite ) ; $ parametersToExclude = self :: getQueryParametersToExclude ( ...
Given the Input URL will exclude all query parameters set for this site
24,703
public static function getQueryParametersToExclude ( $ idSite ) { $ campaignTrackingParameters = Common :: getCampaignParameters ( ) ; $ campaignTrackingParameters = array_merge ( $ campaignTrackingParameters [ 0 ] , $ campaignTrackingParameters [ 1 ] ) ; $ website = Cache :: getCacheWebsiteAttributes ( $ idSite ) ; $ ...
Returns the array of parameters names that must be excluded from the Query String in all tracked URLs
24,704
protected static function getUrlParameterNamesToExcludeFromUrl ( ) { $ paramsToExclude = Config :: getInstance ( ) -> Tracker [ 'url_query_parameter_to_exclude_from_url' ] ; $ paramsToExclude = explode ( "," , $ paramsToExclude ) ; $ paramsToExclude = array_map ( 'trim' , $ paramsToExclude ) ; return $ paramsToExclude ...
Returns the list of URL query parameters that should be removed from the tracked URL query string .
24,705
public static function reconstructNormalizedUrl ( $ url , $ prefixId ) { $ map = array_flip ( self :: $ urlPrefixMap ) ; if ( $ prefixId !== null && isset ( $ map [ $ prefixId ] ) ) { $ fullUrl = $ map [ $ prefixId ] . $ url ; } else { $ fullUrl = $ url ; } $ parsedUrl = @ parse_url ( $ fullUrl ) ; $ parsedUrl = PageUr...
Build the full URL from the prefix ID and the rest .
24,706
public static function normalizeUrl ( $ url ) { foreach ( self :: $ urlPrefixMap as $ prefix => $ id ) { if ( strtolower ( substr ( $ url , 0 , strlen ( $ prefix ) ) ) == $ prefix ) { return array ( 'url' => substr ( $ url , strlen ( $ prefix ) ) , 'prefixId' => $ id ) ; } } return array ( 'url' => $ url , 'prefixId' =...
Extract the prefix from a URL . Return the prefix ID and the rest .
24,707
private function getSeriesLabel ( $ rowLabel , $ columnName ) { $ metricLabel = @ $ this -> properties [ 'translations' ] [ $ columnName ] ; if ( $ rowLabel !== false ) { $ label = "$rowLabel ($metricLabel)" ; } else { $ label = $ metricLabel ; } return $ label ; }
Derive the series label from the row label and the column name . If the row label is set both the label and the column name are displayed .
24,708
public function filter ( $ table ) { $ columnSet = array ( ) ; if ( empty ( $ this -> pivotColumn ) ) { $ this -> pivotColumn = $ this -> getNameOfFirstNonLabelColumnInTable ( $ table ) ; } Log :: debug ( "PivotByDimension::%s: pivoting table with pivot column = %s" , __FUNCTION__ , $ this -> pivotColumn ) ; foreach ( ...
Pivots to table .
24,709
private function getIntersectedTable ( DataTable $ table , Row $ row ) { if ( $ this -> isPivotDimensionSubtable ( ) ) { return $ this -> loadSubtable ( $ table , $ row ) ; } if ( $ this -> isFetchingBySegmentEnabled ) { $ segment = $ row -> getMetadata ( 'segment' ) ; if ( empty ( $ segment ) ) { $ segmentValue = $ ro...
An intersected table is a table that describes visits by a certain dimension for the visits represented by a row in another table . This method fetches intersected tables either via subtable or by using a segment . Read the class docs for more info .
24,710
public function getTableCreateSql ( $ tableName ) { $ tables = DbHelper :: getTablesCreateSql ( ) ; if ( ! isset ( $ tables [ $ tableName ] ) ) { throw new Exception ( "The table '$tableName' SQL creation code couldn't be found." ) ; } return $ tables [ $ tableName ] ; }
Get the SQL to create a specific Piwik table
24,711
public function getTablesNames ( ) { $ aTables = array_keys ( $ this -> getTablesCreateSql ( ) ) ; $ prefixTables = $ this -> getTablePrefix ( ) ; $ return = array ( ) ; foreach ( $ aTables as $ table ) { $ return [ ] = $ prefixTables . $ table ; } return $ return ; }
Names of all the prefixed tables in piwik Doesn t use the DB
24,712
public function getTableColumns ( $ tableName ) { $ db = $ this -> getDb ( ) ; $ allColumns = $ db -> fetchAll ( "SHOW COLUMNS FROM " . $ tableName ) ; $ fields = array ( ) ; foreach ( $ allColumns as $ column ) { $ fields [ trim ( $ column [ 'Field' ] ) ] = $ column ; } return $ fields ; }
Get list of installed columns in a table
24,713
public function getTablesInstalled ( $ forceReload = true ) { if ( is_null ( $ this -> tablesInstalled ) || $ forceReload === true ) { $ db = $ this -> getDb ( ) ; $ prefixTables = $ this -> getTablePrefixEscaped ( ) ; $ allTables = $ this -> getAllExistingTables ( $ prefixTables ) ; $ allMyTables = $ this -> getTables...
Get list of tables installed
24,714
public function createTable ( $ nameWithoutPrefix , $ createDefinition ) { $ statement = sprintf ( "CREATE TABLE `%s` ( %s ) ENGINE=%s DEFAULT CHARSET=utf8 ;" , Common :: prefixTable ( $ nameWithoutPrefix ) , $ createDefinition , $ this -> getTableEngine ( ) ) ; try { Db :: exec ( $ statement ) ; } catch ( Exception $ ...
Creates a new table in the database .
24,715
public function createTables ( ) { $ db = $ this -> getDb ( ) ; $ prefixTables = $ this -> getTablePrefix ( ) ; $ tablesAlreadyInstalled = $ this -> getTablesInstalled ( ) ; $ tablesToCreate = $ this -> getTablesCreateSql ( ) ; unset ( $ tablesToCreate [ 'archive_blob' ] ) ; unset ( $ tablesToCreate [ 'archive_numeric'...
Create all tables
24,716
public function createAnonymousUser ( ) { $ now = Date :: factory ( 'now' ) -> getDatetime ( ) ; $ db = $ this -> getDb ( ) ; $ db -> query ( "INSERT IGNORE INTO " . Common :: prefixTable ( "user" ) . " VALUES ( 'anonymous', '', 'anonymous', 'anonymous@example.org', '', 'anonymous', 0, '$now', '$now'...
Creates an entry in the User table for the anonymous user .
24,717
public function getInstallVersion ( ) { Option :: clearCachedOption ( self :: OPTION_NAME_MATOMO_INSTALL_VERSION ) ; $ version = Option :: get ( self :: OPTION_NAME_MATOMO_INSTALL_VERSION ) ; if ( ! empty ( $ version ) ) { return $ version ; } }
Returns which Matomo version was used to install this Matomo for the first time .
24,718
public function deleteSiteReport ( $ idSite ) { $ idReports = API :: getInstance ( ) -> getReports ( $ idSite ) ; foreach ( $ idReports as $ report ) { $ idReport = $ report [ 'idreport' ] ; API :: getInstance ( ) -> deleteReport ( $ idReport ) ; } }
Delete reports for the website
24,719
public static function getPeriodToFrequency ( ) { return array ( Schedule :: PERIOD_NEVER => Piwik :: translate ( 'General_Never' ) , Schedule :: PERIOD_DAY => Piwik :: translate ( 'General_Daily' ) , Schedule :: PERIOD_WEEK => Piwik :: translate ( 'General_Weekly' ) , Schedule :: PERIOD_MONTH => Piwik :: translate ( '...
Used in the Report Listing
24,720
public function remove ( $ metricCategory , $ metricName = false ) { foreach ( $ this -> metrics as $ index => $ metric ) { if ( $ metric -> getCategoryId ( ) === $ metricCategory ) { if ( ! $ metricName || $ metric -> getName ( ) === $ metricName ) { unset ( $ this -> metrics [ $ index ] ) ; $ this -> metricsByNameCac...
Removes one or more metrics from the metrics list .
24,721
public static function get ( ) { $ cache = Cache :: getTransientCache ( ) ; $ cacheKey = CacheId :: siteAware ( 'MetricsList' ) ; if ( $ cache -> contains ( $ cacheKey ) ) { return $ cache -> fetch ( $ cacheKey ) ; } $ list = new static ; Piwik :: postEvent ( 'Metric.addMetrics' , array ( $ list ) ) ; $ dimensions = Di...
Get all metrics defined in the Piwik platform .
24,722
protected function renderTable ( $ table , & $ allColumns = array ( ) ) { if ( is_array ( $ table ) ) { $ table = DataTable :: makeFromSimpleArray ( $ table ) ; } if ( $ table instanceof DataTable \ Map ) { $ str = $ this -> renderDataTableMap ( $ table , $ allColumns ) ; } else { $ str = $ this -> renderDataTable ( $ ...
Computes the output of the given data table
24,723
protected function renderDataTableMap ( $ table , & $ allColumns = array ( ) ) { $ str = '' ; foreach ( $ table -> getDataTables ( ) as $ currentLinePrefix => $ dataTable ) { $ returned = explode ( "\n" , $ this -> renderTable ( $ dataTable , $ allColumns ) ) ; $ returned = array_slice ( $ returned , 1 ) ; if ( ! empty...
Computes the output of the given data table array
24,724
protected function renderDataTable ( $ table , & $ allColumns = array ( ) ) { if ( $ table instanceof Simple ) { $ row = $ table -> getFirstRow ( ) ; if ( $ row !== false ) { $ columnNameToValue = $ row -> getColumns ( ) ; if ( count ( $ columnNameToValue ) == 1 ) { $ allColumns [ 'value' ] = true ; $ value = array_val...
Converts the output of the given simple data table
24,725
private function getHeaderLine ( $ columnMetrics ) { foreach ( $ columnMetrics as $ index => $ value ) { if ( in_array ( $ value , $ this -> unsupportedColumns ) ) { unset ( $ columnMetrics [ $ index ] ) ; } } if ( $ this -> translateColumnNames ) { $ columnMetrics = $ this -> translateColumnNames ( $ columnMetrics ) ;...
Returns the CSV header line for a set of metrics . Will translate columns if desired .
24,726
protected function renderHeader ( ) { $ fileName = Piwik :: translate ( 'General_Export' ) ; $ period = Common :: getRequestVar ( 'period' , false ) ; $ date = Common :: getRequestVar ( 'date' , false ) ; if ( $ period || $ date ) { if ( $ period == 'range' ) { $ period = new Range ( $ period , $ date ) ; } elseif ( st...
Sends the http headers for csv file
24,727
protected function getRenamedColumns ( $ columns ) { $ newColumns = array ( ) ; foreach ( $ columns as $ columnName => $ columnValue ) { $ renamedColumn = $ this -> getRenamedColumn ( $ columnName ) ; if ( $ renamedColumn ) { if ( $ renamedColumn == 'goals' ) { $ columnValue = $ this -> flattenGoalColumns ( $ columnVal...
Checks the given columns and renames them if required
24,728
protected function _getMetadatas ( $ id ) { if ( isset ( $ this -> _metadatasArray [ $ id ] ) ) { return $ this -> _metadatasArray [ $ id ] ; } else { $ metadatas = $ this -> _loadMetadatas ( $ id ) ; if ( ! $ metadatas ) { return false ; } $ this -> _setMetadatas ( $ id , $ metadatas , false ) ; return $ metadatas ; }...
Get a metadatas record
24,729
protected function _setMetadatas ( $ id , $ metadatas , $ save = true ) { if ( count ( $ this -> _metadatasArray ) >= $ this -> _options [ 'metadatas_array_max_size' ] ) { $ n = ( int ) ( $ this -> _options [ 'metadatas_array_max_size' ] / 10 ) ; $ this -> _metadatasArray = array_slice ( $ this -> _metadatasArray , $ n...
Set a metadatas record
24,730
protected function _delMetadatas ( $ id ) { if ( isset ( $ this -> _metadatasArray [ $ id ] ) ) { unset ( $ this -> _metadatasArray [ $ id ] ) ; } $ file = $ this -> _metadatasFile ( $ id ) ; return $ this -> _remove ( $ file ) ; }
Drop a metadata record
24,731
protected function _loadMetadatas ( $ id ) { $ file = $ this -> _metadatasFile ( $ id ) ; $ result = $ this -> _fileGetContents ( $ file ) ; if ( ! $ result ) { return false ; } $ tmp = @ unserialize ( $ result ) ; return $ tmp ; }
Load metadatas from disk
24,732
protected function _saveMetadatas ( $ id , $ metadatas ) { $ file = $ this -> _metadatasFile ( $ id ) ; $ result = $ this -> _filePutContents ( $ file , serialize ( $ metadatas ) ) ; if ( ! $ result ) { return false ; } return true ; }
Save metadatas to disk
24,733
protected function _isMetadatasFile ( $ fileName ) { $ id = $ this -> _fileNameToId ( $ fileName ) ; if ( substr ( $ id , 0 , 21 ) == 'internal-metadatas---' ) { return true ; } else { return false ; } }
Check if the given filename is a metadatas one
24,734
protected function _recursiveMkdirAndChmod ( $ id ) { if ( $ this -> _options [ 'hashed_directory_level' ] <= 0 ) { return true ; } $ partsArray = $ this -> _path ( $ id , true ) ; foreach ( $ partsArray as $ part ) { if ( ! is_dir ( $ part ) ) { @ mkdir ( $ part , $ this -> _options [ 'hashed_directory_umask' ] ) ; @ ...
Make the directory strucuture for the given id
24,735
protected function _fileGetContents ( $ file ) { $ result = false ; if ( ! is_file ( $ file ) ) { return false ; } $ f = @ fopen ( $ file , 'rb' ) ; if ( $ f ) { if ( $ this -> _options [ 'file_locking' ] ) @ flock ( $ f , LOCK_SH ) ; $ result = stream_get_contents ( $ f ) ; if ( $ this -> _options [ 'file_locking' ] )...
Return the file content of the given file
24,736
protected function _filePutContents ( $ file , $ string ) { $ result = false ; $ f = @ fopen ( $ file , 'ab+' ) ; if ( $ f ) { if ( $ this -> _options [ 'file_locking' ] ) @ flock ( $ f , LOCK_EX ) ; fseek ( $ f , 0 ) ; ftruncate ( $ f , 0 ) ; $ tmp = @ fwrite ( $ f , $ string ) ; if ( ! ( $ tmp === FALSE ) ) { $ resul...
Put the given string into the given file
24,737
public function getSubmitValue ( $ elementName ) { $ value = $ this -> getValue ( ) ; return isset ( $ value [ $ elementName ] ) ? $ value [ $ elementName ] : null ; }
Ported from HTML_QuickForm to minimize changes to Controllers
24,738
public function getFormData ( $ groupErrors = true ) { if ( ! self :: $ registered ) { HTML_QuickForm2_Renderer :: register ( 'smarty' , 'HTML_QuickForm2_Renderer_Smarty' ) ; self :: $ registered = true ; } $ renderer = HTML_QuickForm2_Renderer :: factory ( 'smarty' ) ; $ renderer -> setOption ( 'group_errors' , $ grou...
Returns the rendered form as an array .
24,739
public function getTransitionsForAction ( $ actionName , $ actionType , $ idSite , $ period , $ date , $ segment = false , $ limitBeforeGrouping = false , $ parts = 'all' ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ idaction = $ this -> deriveIdAction ( $ actionName , $ actionType ) ; if ( $ idaction < 0 ) { th...
General method to get transitions for an action
24,740
private function deriveIdAction ( $ actionName , $ actionType ) { switch ( $ actionType ) { case 'url' : $ originalActionName = $ actionName ; $ actionName = Common :: unsanitizeInputValue ( $ actionName ) ; $ id = TableLogAction :: getIdActionFromSegment ( $ actionName , 'idaction_url' , SegmentExpression :: MATCH_EQU...
Derive the action ID from the request action name and type .
24,741
public function setWidth ( $ width ) { if ( ! is_numeric ( $ width ) || $ width <= 0 ) { return ; } if ( $ width > self :: MAX_WIDTH ) { $ this -> _width = self :: MAX_WIDTH ; } else { $ this -> _width = ( int ) $ width ; } }
Sets the width of the sparkline
24,742
public function setHeight ( $ height ) { if ( ! is_numeric ( $ height ) || $ height <= 0 ) { return ; } if ( $ height > self :: MAX_HEIGHT ) { $ this -> _height = self :: MAX_HEIGHT ; } else { $ this -> _height = ( int ) $ height ; } }
Sets the height of the sparkline
24,743
private function setSparklineColors ( $ sparkline ) { $ colors = Common :: getRequestVar ( 'colors' , false , 'json' ) ; if ( empty ( $ colors ) ) { $ colors = array ( 'backgroundColor' => '#ffffff' , 'lineColor' => '#162C4A' , 'minPointColor' => '#ff7f7f' , 'maxPointColor' => '#75BF7C' , 'lastPointColor' => '#55AAFF' ...
Sets the sparkline colors
24,744
public function getLocalizedLongString ( ) { $ string = $ this -> getTranslatedRange ( $ this -> getRangeFormat ( ) ) ; return $ this -> translator -> translate ( 'Intl_PeriodWeek' ) . " " . $ string ; }
Returns the current period as a localized long string
24,745
protected function generate ( ) { if ( $ this -> subperiodsProcessed ) { return ; } parent :: generate ( ) ; $ date = $ this -> date ; if ( $ date -> toString ( 'N' ) > 1 ) { $ date = $ date -> subDay ( $ date -> toString ( 'N' ) - 1 ) ; } $ startWeek = $ date ; $ currentDay = clone $ startWeek ; while ( $ currentDay -...
Generates the subperiods - one for each day in the week
24,746
public static function regenerateCacheWebsiteAttributes ( $ idSites = array ( ) ) { if ( ! is_array ( $ idSites ) ) { $ idSites = array ( $ idSites ) ; } foreach ( $ idSites as $ idSite ) { self :: deleteCacheWebsiteAttributes ( $ idSite ) ; self :: getCacheWebsiteAttributes ( $ idSite ) ; } }
Regenerate Tracker cache files
24,747
public static function set ( $ name , $ value , $ autoload = 0 ) { self :: getInstance ( ) -> setValue ( $ name , $ value , $ autoload ) ; }
Sets an option value by name .
24,748
protected function autoload ( ) { if ( $ this -> loaded ) { return ; } $ table = Common :: prefixTable ( 'option' ) ; $ sql = 'SELECT option_value, option_name FROM `' . $ table . '` WHERE autoload = 1' ; $ all = Db :: fetchAll ( $ sql ) ; foreach ( $ all as $ option ) { $ this -> all [ $ option [ 'option_name' ] ] = $...
Initialize cache with autoload settings .
24,749
public function willBeArchived ( ) { if ( $ this -> isEmpty ( ) ) { return true ; } $ idSites = $ this -> idSites ; if ( ! is_array ( $ idSites ) ) { $ idSites = array ( $ this -> idSites ) ; } return Rules :: isRequestAuthorizedToArchive ( ) || Rules :: isBrowserArchivingAvailableForSegments ( ) || Rules :: isSegmentP...
Detects whether the Piwik instance is configured to be able to archive this segment . It checks whether the segment will be either archived via browser or cli archiving . It does not check if the segment has been archived . If you want to know whether the segment has been archived the actual report data needs to be req...
24,750
public function getSelectQuery ( $ select , $ from , $ where = false , $ bind = array ( ) , $ orderBy = false , $ groupBy = false , $ limit = 0 , $ offset = 0 ) { $ segmentExpression = $ this -> segmentExpression ; $ limitAndOffset = null ; if ( $ limit > 0 ) { $ limitAndOffset = ( int ) $ offset . ', ' . ( int ) $ lim...
Extend an SQL query that aggregates data over one of the log_ tables with segment expressions .
24,751
public static function combine ( $ segment , $ operator , $ segmentCondition ) { if ( empty ( $ segment ) ) { return $ segmentCondition ; } if ( empty ( $ segmentCondition ) || self :: containsCondition ( $ segment , $ operator , $ segmentCondition ) ) { return $ segment ; } return $ segment . $ operator . $ segmentCon...
Combines this segment with another segment condition if the segment condition is not already in the segment .
24,752
public function sendToDisk ( $ filename ) { $ filePath = self :: getOutputPath ( $ filename ) ; $ this -> pImage -> render ( $ filePath ) ; return $ filePath ; }
Save rendering to disk
24,753
public function updateSearchEngines ( ) { $ url = 'https://raw.githubusercontent.com/matomo-org/searchengine-and-social-list/master/SearchEngines.yml' ; $ list = Http :: sendHttpRequest ( $ url , 30 ) ; $ searchEngines = SearchEngine :: getInstance ( ) -> loadYmlData ( $ list ) ; if ( count ( $ searchEngines ) < 200 ) ...
Update the search engine definitions
24,754
public function updateSocials ( ) { $ url = 'https://raw.githubusercontent.com/matomo-org/searchengine-and-social-list/master/Socials.yml' ; $ list = Http :: sendHttpRequest ( $ url , 30 ) ; $ socials = Social :: getInstance ( ) -> loadYmlData ( $ list ) ; if ( count ( $ socials ) < 50 ) { return ; } Option :: set ( So...
Update the social definitions
24,755
protected function _prepareHeaders ( $ headers ) { if ( ! $ this -> _mail ) { throw new Zend_Mail_Transport_Exception ( '_prepareHeaders requires a registered Zend_Mail object' ) ; } if ( 0 === strpos ( PHP_OS , 'WIN' ) ) { if ( empty ( $ this -> recipients ) ) { throw new Zend_Mail_Transport_Exception ( 'Missing To ad...
Format and fix headers
24,756
public function createDatabaseObject ( ) { $ dbname = trim ( $ this -> getSubmitValue ( 'dbname' ) ) ; if ( empty ( $ dbname ) ) { throw new Exception ( "No database name" ) ; } $ adapter = $ this -> getSubmitValue ( 'adapter' ) ; $ port = Adapter :: getDefaultPortForAdapter ( $ adapter ) ; $ host = $ this -> getSubmit...
Creates database object based on form data .
24,757
public function validateOwner ( ) { try { $ this -> createDatabaseObject ( ) ; } catch ( Exception $ ex ) { if ( $ this -> isAccessDenied ( $ ex ) ) { return false ; } else { return true ; } } $ db = Db :: get ( ) ; try { $ this -> dropExtraTables ( $ db ) ; } catch ( Exception $ ex ) { if ( $ this -> isAccessDenied ( ...
Checks that the DB user entered in the form has the necessary privileges for Piwik to run .
24,758
public static function getRequiredPrivileges ( ) { return array ( 'CREATE' => 'CREATE TABLE ' . self :: TEST_TABLE_NAME . ' ( id INT AUTO_INCREMENT, value INT, PRIMARY KEY (id), KEY index_value (value...
Returns an array describing the database privileges required for Matomo to run . The array maps privilege names with one or more SQL queries that can be used to test if the current user has the privilege .
24,759
protected function getAuthCookie ( $ rememberMe ) { $ authCookieExpiry = $ rememberMe ? time ( ) + $ this -> authCookieValidTime : 0 ; $ cookie = new Cookie ( $ this -> authCookieName , $ authCookieExpiry , $ this -> authCookiePath ) ; return $ cookie ; }
Returns a Cookie instance that manages the browser cookie used to store session information .
24,760
protected function processFailedSession ( $ rememberMe ) { $ cookie = $ this -> getAuthCookie ( $ rememberMe ) ; $ cookie -> delete ( ) ; throw new Exception ( Piwik :: translate ( 'Login_LoginPasswordNotCorrect' ) ) ; }
Executed when the session could not authenticate .
24,761
public function getLocation ( $ info ) { $ enableLanguageToCountryGuess = Config :: getInstance ( ) -> Tracker [ 'enable_language_to_country_guess' ] ; if ( empty ( $ info [ 'lang' ] ) ) { $ info [ 'lang' ] = Common :: getBrowserLanguage ( ) ; } $ country = Common :: getCountry ( $ info [ 'lang' ] , $ enableLanguageToC...
Guesses a visitor s location using a visitor s browser language .
24,762
public function getPrettyNumber ( $ value , $ precision = 0 ) { if ( $ this -> decimalPoint === null ) { $ locale = localeconv ( ) ; $ this -> decimalPoint = $ locale [ 'decimal_point' ] ; $ this -> thousandsSeparator = $ locale [ 'thousands_sep' ] ; } return number_format ( $ value , $ precision , $ this -> decimalPoi...
Returns a prettified string representation of a number . The result will have thousands separators and a decimal point specific to the current locale eg 1 000 000 . 05 or 1 . 000 . 000 05 .
24,763
public function formatMetrics ( DataTable $ dataTable , Report $ report = null , $ metricsToFormat = null , $ formatAll = false ) { $ metrics = $ this -> getMetricsToFormat ( $ dataTable , $ report ) ; if ( empty ( $ metrics ) || $ dataTable -> getMetadata ( self :: PROCESSED_METRICS_FORMATTED_FLAG ) ) { return ; } $ d...
Formats all metrics including processed metrics for a DataTable . Metrics to format are found through report metadata and DataTable metadata .
24,764
public static function setUpdaterOptionsFromUrl ( ) { $ options = array ( 'loc' => Common :: getRequestVar ( 'loc_db' , false , 'string' ) , 'isp' => Common :: getRequestVar ( 'isp_db' , false , 'string' ) , 'org' => Common :: getRequestVar ( 'org_db' , false , 'string' ) , 'period' => Common :: getRequestVar ( 'period...
Sets the options used by this class based on query parameter values .
24,765
public static function clearOptions ( ) { foreach ( self :: $ urlOptions as $ optionKey => $ optionName ) { Option :: delete ( $ optionName ) ; } Option :: delete ( self :: SCHEDULE_PERIOD_OPTION_NAME ) ; }
Removes all options to disable any configured automatic updates
24,766
public static function isUpdaterSetup ( ) { if ( Option :: get ( self :: LOC_URL_OPTION_NAME ) !== false || Option :: get ( self :: ISP_URL_OPTION_NAME ) !== false || Option :: get ( self :: ORG_URL_OPTION_NAME ) !== false ) { return true ; } return false ; }
Returns true if the auto - updater is setup to update at least one type of database . False if otherwise .
24,767
private function getOldAndNewPathsForBrokenDb ( $ possibleDbNames ) { $ pathToDb = GeoIp :: getPathToGeoIpDatabase ( $ possibleDbNames ) ; $ newPath = false ; if ( $ pathToDb !== false ) { $ newPath = $ pathToDb . ".broken" ; } return array ( $ pathToDb , $ newPath ) ; }
Returns the path to a GeoIP database and a path to rename it to if it s broken .
24,768
public static function catchGeoIPError ( $ errno , $ errstr , $ errfile , $ errline ) { self :: $ unzipPhpError = array ( $ errno , $ errstr , $ errfile , $ errline ) ; }
Custom PHP error handler used to catch any PHP errors that occur when testing a downloaded GeoIP file .
24,769
public function attributeExistingVisit ( $ visit , $ useClassCache = true ) { if ( empty ( $ visit [ 'idvisit' ] ) ) { $ this -> logger -> debug ( 'Empty idvisit field. Skipping re-attribution..' ) ; return null ; } $ idVisit = $ visit [ 'idvisit' ] ; if ( empty ( $ visit [ 'location_ip' ] ) ) { $ this -> logger -> deb...
Geolcates an existing visit and then updates it if it s current attributes are different than what was geolocated . Also updates all conversions of a visit .
24,770
private function getVisitFieldsToUpdate ( array $ row , $ location ) { if ( isset ( $ location [ LocationProvider :: COUNTRY_CODE_KEY ] ) ) { $ location [ LocationProvider :: COUNTRY_CODE_KEY ] = strtolower ( $ location [ LocationProvider :: COUNTRY_CODE_KEY ] ) ; } $ valuesToUpdate = array ( ) ; foreach ( self :: $ lo...
Returns location log values that are different than the values currently in a log row .
24,771
public function filterSubTable ( Row $ row ) { if ( ! $ this -> enableRecursive ) { return ; } $ subTable = $ row -> getSubtable ( ) ; if ( $ subTable ) { $ this -> filter ( $ subTable ) ; } }
Filters a row s subtable if one exists and is loaded in memory .
24,772
public function init ( ) { $ this -> invokeBeforeContainerCreatedHook ( ) ; $ this -> container = $ this -> createContainer ( ) ; StaticContainer :: push ( $ this -> container ) ; $ this -> validateEnvironment ( ) ; $ this -> invokeEnvironmentBootstrappedHook ( ) ; Piwik :: postEvent ( 'Environment.bootstrapped' ) ; }
Initializes the kernel globals and DI container .
24,773
public function formatNumber ( $ value , $ maximumFractionDigits = 0 , $ minimumFractionDigits = 0 ) { $ pattern = $ this -> getPattern ( $ value , 'Intl_NumberFormatNumber' ) ; return $ this -> formatNumberWithPattern ( $ pattern , $ value , $ maximumFractionDigits , $ minimumFractionDigits ) ; }
Formats a given number
24,774
public function formatPercentEvolution ( $ value ) { $ isPositiveEvolution = ! empty ( $ value ) && ( $ value > 0 || $ value [ 0 ] == '+' ) ; $ formatted = self :: formatPercent ( $ value ) ; if ( $ isPositiveEvolution ) { $ language = $ this -> translator -> getCurrentLanguage ( ) ; return $ this -> symbols [ $ langua...
Formats given number as percent value but keep the leading + sign if found
24,775
protected function getPattern ( $ value , $ translationId ) { $ language = $ this -> translator -> getCurrentLanguage ( ) ; if ( ! isset ( $ this -> patterns [ $ language ] [ $ translationId ] ) ) { $ this -> patterns [ $ language ] [ $ translationId ] = $ this -> parsePattern ( $ this -> translator -> translate ( $ tr...
Returns the relevant pattern for the given number .
24,776
protected function parsePattern ( $ pattern ) { $ patterns = explode ( ';' , $ pattern ) ; if ( ! isset ( $ patterns [ 1 ] ) ) { $ patterns [ 1 ] = '-' . $ patterns [ 0 ] ; } return $ patterns ; }
Parses the given pattern and returns patterns for positive and negative numbers
24,777
protected function formatNumberWithPattern ( $ pattern , $ value , $ maximumFractionDigits = 0 , $ minimumFractionDigits = 0 ) { if ( ! is_numeric ( $ value ) ) { return $ value ; } $ usesGrouping = ( strpos ( $ pattern , ',' ) !== false ) ; if ( $ usesGrouping ) { preg_match ( '/#+0/' , $ pattern , $ primaryGroupMatch...
Formats the given number with the given pattern
24,778
protected function replaceSymbols ( $ value ) { $ language = $ this -> translator -> getCurrentLanguage ( ) ; if ( ! isset ( $ this -> symbols [ $ language ] ) ) { $ this -> symbols [ $ language ] = array ( '.' => $ this -> translator -> translate ( 'Intl_NumberSymbolDecimal' ) , ',' => $ this -> translator -> translat...
Replaces number symbols with their localized equivalents .
24,779
public function onEcommerceOrderConversion ( Request $ request , Visitor $ visitor , $ action , GoalManager $ goalManager ) { if ( $ visitor -> isVisitorKnown ( ) ) { return 1 ; } return 0 ; }
This event is triggered when an ecommerce order is converted . In this example we would store a 0 in case it was the visitors first action or 1 otherwise . Return boolean false if you do not want to change the value in some cases . If you do not want to perform any action on an ecommerce order at all it is recommended ...
24,780
public function onEcommerceCartUpdateConversion ( Request $ request , Visitor $ visitor , $ action , GoalManager $ goalManager ) { return Common :: getRequestVar ( 'myCustomParam' , $ default = false , 'int' , $ request -> getParams ( ) ) ; }
This event is triggered when an ecommerce cart update is converted . In this example we would store a the value of the tracking url parameter myCustomParam in the example_conversion_dimension column . Return boolean false if you do not want to change the value in some cases . If you do not want to perform any action on...
24,781
public function onGoalConversion ( Request $ request , Visitor $ visitor , $ action , GoalManager $ goalManager ) { $ goalId = $ goalManager -> getGoalColumn ( 'idgoal' ) ; if ( $ visitor -> isVisitorKnown ( ) ) { return $ goalId ; } return false ; }
This event is triggered when an any custom goal is converted . In this example we would store a the id of the goal in the example_conversion_dimension column if the visitor is known and nothing otherwise . Return boolean false if you do not want to change the value in some cases . If you do not want to perform any acti...
24,782
protected static function processTableFormat ( $ reportMetadata , $ report , $ reportColumns ) { $ finalReport = $ report ; if ( empty ( $ reportMetadata [ 'dimension' ] ) ) { $ simpleReportMetrics = $ report -> getFirstRow ( ) ; if ( $ simpleReportMetrics ) { $ finalReport = new Simple ( ) ; foreach ( $ simpleReportMe...
Convert a dimension - less report to a multi - row two - column data table
24,783
public function filter ( $ table ) { foreach ( $ table -> getRows ( ) as $ row ) { $ value = $ row -> getColumn ( $ this -> columnToFilter ) ; if ( $ value === false ) { $ value = $ row -> getMetadata ( $ this -> columnToFilter ) ; if ( $ value !== false ) { if ( $ value < ( float ) self :: $ minimumValue ) { $ row -> ...
Executes the filter an adjusts all columns to fit the defined range
24,784
protected function reload ( $ pathLocal = null , $ pathGlobal = null , $ pathCommon = null ) { $ this -> settings -> reload ( $ pathGlobal , $ pathLocal , $ pathCommon ) ; }
Reloads config data from disk .
24,785
protected function writeConfig ( $ clear = true ) { $ output = $ this -> dumpConfig ( ) ; if ( $ output !== null && $ output !== false ) { $ localPath = $ this -> getLocalPath ( ) ; if ( $ this -> doNotWriteConfigInTests ) { $ success = is_writable ( $ localPath ) ; } else { $ success = @ file_put_contents ( $ localPat...
Write user configuration file
24,786
public static function setSetting ( $ sectionName , $ name , $ value ) { $ section = self :: getInstance ( ) -> $ sectionName ; $ section [ $ name ] = $ value ; self :: getInstance ( ) -> $ sectionName = $ section ; }
Convenience method for setting settings in a single section . Will set them in a new array first to be compatible with certain PHP versions .
24,787
protected function _setContentTypeMemorization ( $ value ) { $ found = null ; foreach ( $ this -> _specificOptions [ 'memorize_headers' ] as $ key => $ value ) { if ( strtolower ( $ value ) == 'content-type' ) { $ found = $ key ; } } if ( $ value ) { if ( ! $ found ) { $ this -> _specificOptions [ 'memorize_headers' ] ...
Set the deprecated contentTypeMemorization option
24,788
protected function _makePartialId ( $ arrayName , $ bool1 , $ bool2 ) { switch ( $ arrayName ) { case 'Get' : $ var = $ _GET ; break ; case 'Post' : $ var = $ _POST ; break ; case 'Session' : if ( isset ( $ _SESSION ) ) { $ var = $ _SESSION ; } else { $ var = null ; } break ; case 'Cookie' : if ( isset ( $ _COOKIE ) ) ...
Make a partial id depending on options
24,789
public function getResponse ( $ value = null , $ apiModule = false , $ apiMethod = false ) { $ this -> apiModule = $ apiModule ; $ this -> apiMethod = $ apiMethod ; $ this -> sendHeaderIfEnabled ( ) ; if ( ! isset ( $ value ) ) { if ( ob_get_contents ( ) ) { return null ; } return $ this -> apiRenderer -> renderSuccess...
This method processes the data resulting from the API call .
24,790
protected function _connect ( ) { if ( $ this -> _connection ) { return ; } if ( ! extension_loaded ( 'mysqli' ) ) { throw new Zend_Db_Adapter_Mysqli_Exception ( 'The Mysqli extension is required for this adapter but the extension is not loaded' ) ; } if ( isset ( $ this -> _config [ 'port' ] ) ) { $ port = ( integer )...
Creates a connection to the database .
24,791
public function prepare ( $ sql ) { $ this -> _connect ( ) ; if ( $ this -> _stmt ) { $ this -> _stmt -> close ( ) ; } $ stmtClass = $ this -> _defaultStmtClass ; if ( ! class_exists ( $ stmtClass ) ) { Zend_Loader :: loadClass ( $ stmtClass ) ; } $ stmt = new $ stmtClass ( $ this , $ sql ) ; if ( $ stmt === false ) { ...
Prepare a statement and return a PDOStatement - like object .
24,792
protected function _rollBack ( ) { $ this -> _connect ( ) ; $ this -> _connection -> rollback ( ) ; $ this -> _connection -> autocommit ( true ) ; }
Roll - back a transaction .
24,793
public function translate ( $ translationId , $ args = array ( ) , $ language = null ) { $ args = is_array ( $ args ) ? $ args : array ( $ args ) ; if ( strpos ( $ translationId , "_" ) !== false ) { list ( $ plugin , $ key ) = explode ( "_" , $ translationId , 2 ) ; $ language = is_string ( $ language ) ? $ language :...
Returns an internationalized string using a translation ID . If a translation cannot be found for the ID the ID is returned .
24,794
public function getJavascriptTranslations ( ) { $ clientSideTranslations = array ( ) ; foreach ( $ this -> getClientSideTranslationKeys ( ) as $ id ) { list ( $ plugin , $ key ) = explode ( '_' , $ id , 2 ) ; $ clientSideTranslations [ $ id ] = $ this -> getTranslation ( $ id , $ this -> currentLanguage , $ plugin , $ ...
Generate javascript translations array
24,795
public function addDirectory ( $ directory ) { if ( isset ( $ this -> directories [ $ directory ] ) ) { return ; } $ this -> directories [ $ directory ] = $ directory ; $ this -> translations = array ( ) ; }
Add a directory containing translations .
24,796
public function reset ( ) { $ this -> currentLanguage = $ this -> getDefaultLanguage ( ) ; $ this -> directories = array ( PIWIK_INCLUDE_PATH . '/lang' ) ; $ this -> translations = array ( ) ; }
Should be used by tests only and this method should eventually be removed .
24,797
public function getAllTranslations ( ) { $ this -> loadTranslations ( $ this -> currentLanguage ) ; if ( ! isset ( $ this -> translations [ $ this -> currentLanguage ] ) ) { return array ( ) ; } return $ this -> translations [ $ this -> currentLanguage ] ; }
Returns all the translation messages loaded .
24,798
public function setCachedEntity ( $ cachedEntity ) { if ( ! is_string ( $ cachedEntity ) && ! is_object ( $ cachedEntity ) ) { Zend_Cache :: throwException ( 'cached_entity must be an object or a class name' ) ; } $ this -> _cachedEntity = $ cachedEntity ; $ this -> _specificOptions [ 'cached_entity' ] = $ cachedEntity...
Specific method to set the cachedEntity
24,799
public function save ( $ idSite ) { $ this -> checkIdSiteIsLoaded ( $ idSite ) ; $ optionName = self :: getAnnotationCollectionOptionName ( $ idSite ) ; Option :: set ( $ optionName , serialize ( $ this -> annotations [ $ idSite ] ) ) ; }
Persists the annotations list for a site overwriting whatever exists .