idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,800 | public static function getMethodIfApiRequest ( $ request ) { $ module = Common :: getRequestVar ( 'module' , '' , 'string' , $ request ) ; $ method = Common :: getRequestVar ( 'method' , '' , 'string' , $ request ) ; $ isApi = $ module === 'API' && ! empty ( $ method ) && ( count ( explode ( '.' , $ method ) ) === 2 ) ... | Returns the current API method being executed if the current request is an API request . |
23,801 | private static function forceReloadAuthUsingTokenAuth ( $ tokenAuth ) { Piwik :: postEvent ( 'API.Request.authenticate' , array ( $ tokenAuth ) ) ; if ( ! Access :: getInstance ( ) -> reloadAccess ( ) && $ tokenAuth && $ tokenAuth !== 'anonymous' ) { Piwik :: postEvent ( 'API.Request.authenticate.failed' ) ; } Settings... | The current session will be authenticated using this token_auth . It will overwrite the previous Auth object . |
23,802 | public static function getCurrentUrlWithoutGenericFilters ( $ params ) { $ genericFiltersInfo = DataTableGenericFilter :: getGenericFiltersInformation ( ) ; foreach ( $ genericFiltersInfo as $ filter ) { foreach ( $ filter [ 1 ] as $ queryParamName => $ queryParamInfo ) { if ( ! isset ( $ params [ $ queryParamName ] ) ... | Returns the current URL without generic filter query parameters . |
23,803 | public static function shouldLoadExpanded ( ) { return Common :: getRequestVar ( 'filter_column_recursive' , false ) !== false && Common :: getRequestVar ( 'filter_pattern_recursive' , false ) !== false && ! self :: shouldLoadFlatten ( ) ; } | Returns whether the DataTable result will have to be expanded for the current request before rendering . |
23,804 | public static function getRawSegmentFromRequest ( ) { $ segmentRaw = false ; $ segment = Common :: getRequestVar ( 'segment' , '' , 'string' ) ; if ( ! empty ( $ segment ) ) { $ request = Request :: getRequestParametersGET ( ) ; if ( ! empty ( $ request [ 'segment' ] ) ) { $ segmentRaw = $ request [ 'segment' ] ; } } r... | Returns the segment query parameter from the original request without modifications . |
23,805 | protected function renderDataTableMap ( DataTable \ Map $ map , $ prefix ) { $ output = "Set<hr />" ; $ prefix = $ prefix . ' ' ; foreach ( $ map -> getDataTables ( ) as $ descTable => $ table ) { $ output .= $ prefix . "<b>" . $ descTable . "</b><br />" ; $ output .= $ prefix . $ thi... | Computes the output of the given array of data tables |
23,806 | public static function encodeQuotedPrintable ( $ str , $ lineLength = self :: LINELENGTH , $ lineEnd = self :: LINEEND ) { $ out = '' ; $ str = self :: _encodeQuotedPrintable ( $ str ) ; while ( $ str ) { $ ptr = strlen ( $ str ) ; if ( $ ptr > $ lineLength ) { $ ptr = $ lineLength ; } $ pos = strrpos ( substr ( $ str ... | Encode a given string with the QUOTED_PRINTABLE mechanism and wrap the lines . |
23,807 | private static function _encodeQuotedPrintable ( $ str ) { $ str = str_replace ( '=' , '=3D' , $ str ) ; $ str = str_replace ( self :: $ qpKeys , self :: $ qpReplaceValues , $ str ) ; $ str = rtrim ( $ str ) ; return $ str ; } | Converts a string into quoted printable format . |
23,808 | public static function encodeQuotedPrintableHeader ( $ str , $ charset , $ lineLength = self :: LINELENGTH , $ lineEnd = self :: LINEEND ) { $ prefix = sprintf ( '=?%s?Q?' , $ charset ) ; $ lineLength = $ lineLength - strlen ( $ prefix ) - 3 ; $ str = self :: _encodeQuotedPrintable ( $ str ) ; $ str = str_replace ( arr... | Encode a given string with the QUOTED_PRINTABLE mechanism for Mail Headers . |
23,809 | private static function getNextQuotedPrintableToken ( $ str ) { if ( substr ( $ str , 0 , 1 ) == "=" ) { $ token = substr ( $ str , 0 , 3 ) ; } else { $ token = substr ( $ str , 0 , 1 ) ; } return $ token ; } | Retrieves the first token from a quoted printable string . |
23,810 | public static function encodeBase64Header ( $ str , $ charset , $ lineLength = self :: LINELENGTH , $ lineEnd = self :: LINEEND ) { $ prefix = '=?' . $ charset . '?B?' ; $ suffix = '?=' ; $ remainingLength = $ lineLength - strlen ( $ prefix ) - strlen ( $ suffix ) ; $ encodedValue = self :: encodeBase64 ( $ str , $ rem... | Encode a given string in mail header compatible base64 encoding . |
23,811 | public static function encodeBase64 ( $ str , $ lineLength = self :: LINELENGTH , $ lineEnd = self :: LINEEND ) { return rtrim ( chunk_split ( base64_encode ( $ str ) , $ lineLength , $ lineEnd ) ) ; } | Encode a given string in base64 encoding and break lines according to the maximum linelength . |
23,812 | public static function encode ( $ str , $ encoding , $ EOL = self :: LINEEND ) { switch ( $ encoding ) { case self :: ENCODING_BASE64 : return self :: encodeBase64 ( $ str , self :: LINELENGTH , $ EOL ) ; case self :: ENCODING_QUOTEDPRINTABLE : return self :: encodeQuotedPrintable ( $ str , self :: LINELENGTH , $ EOL )... | Encode the given string with the given encoding . |
23,813 | public function updateSpammerBlacklist ( ) { $ url = 'https://raw.githubusercontent.com/matomo-org/referrer-spam-blacklist/master/spammers.txt' ; $ list = Http :: sendHttpRequest ( $ url , 30 ) ; $ list = preg_split ( "/\r\n|\n|\r/" , $ list ) ; if ( count ( $ list ) < 10 ) { throw new \ Exception ( sprintf ( 'The spam... | Update the referrer spam blacklist |
23,814 | public function getSegmentHashesByIdSite ( ) { $ sql = "SELECT DISTINCT definition, enable_only_idsite FROM " . Common :: prefixTable ( 'segment' ) . " WHERE deleted = 0" ; $ rows = Db :: fetchAll ( $ sql ) ; $ segmentHashes = array ( ) ; foreach ( $ rows as $ row ) { $ idSite = ( int ) $ row [ 'enable_only_idsite' ] ;... | Get a list of all segment hashes that currently exist indexed by idSite . |
23,815 | public function getProperty ( $ name ) { return isset ( $ this -> visitInfo [ $ name ] ) ? $ this -> visitInfo [ $ name ] : null ; } | Returns a visit property or null if none is set . |
23,816 | public static function setOptions ( array $ userOptions = array ( ) ) { if ( ! self :: $ _defaultOptionsSet ) { foreach ( self :: $ _defaultOptions as $ defaultOptionName => $ defaultOptionValue ) { if ( isset ( self :: $ _defaultOptions [ $ defaultOptionName ] ) ) { @ ini_set ( "session.$defaultOptionName" , $ default... | setOptions - set both the class specified |
23,817 | protected function _getHeaders ( $ boundary ) { if ( null !== $ boundary ) { $ type = $ this -> _mail -> getType ( ) ; if ( ! $ type ) { if ( $ this -> _mail -> hasAttachments ) { $ type = Zend_Mime :: MULTIPART_MIXED ; } elseif ( $ this -> _mail -> getBodyText ( ) && $ this -> _mail -> getBodyHtml ( ) ) { $ type = Zen... | Return all mail headers as an array |
23,818 | protected function _prepareHeaders ( $ headers ) { if ( ! $ this -> _mail ) { throw new Zend_Mail_Transport_Exception ( 'Missing Zend_Mail object in _mail property' ) ; } $ this -> header = '' ; foreach ( $ headers as $ header => $ content ) { if ( isset ( $ content [ 'append' ] ) ) { unset ( $ content [ 'append' ] ) ;... | Prepare header string for use in transport |
23,819 | protected function _buildBody ( ) { if ( ( $ text = $ this -> _mail -> getBodyText ( ) ) && ( $ html = $ this -> _mail -> getBodyHtml ( ) ) ) { $ mime = new Zend_Mime ( null ) ; $ boundaryLine = $ mime -> boundaryLine ( $ this -> EOL ) ; $ boundaryEnd = $ mime -> mimeEnd ( $ this -> EOL ) ; $ text -> disposition = fals... | Generate MIME compliant message from the current configuration |
23,820 | public function getDirectory ( $ asArray = false ) { $ asArray = ( bool ) $ asArray ; $ directory = ( string ) $ this -> _directory ; if ( $ asArray ) { $ directory = explode ( ',' , $ directory ) ; } return $ directory ; } | Returns the set file directories which are checked |
23,821 | public static function createHtAccessFiles ( ) { $ denyAll = self :: getDenyAllHtaccessContent ( ) ; $ allow = self :: getAllowHtaccessContent ( ) ; $ allowAny = "# Allow any file in this directory\n" . "<Files \"*\">\n" . "\t" . $ allow . "\n" . "</Files>\n" ; $ allowStaticAssets = "# Serve HTML files as text/html mim... | Generate Apache . htaccess files to restrict access . htaccess files are created on all webservers even Nginx as sometimes Nginx knows how to handle . htaccess files |
23,822 | protected static function createHtAccess ( $ path , $ overwrite = true , $ content ) { $ file = $ path . '/.htaccess' ; $ content = "# This file is auto generated by Matomo, do not edit directly\n# Please report any issue or improvement directly to the Matomo team.\n\n" . $ content ; if ( $ overwrite || ! file_exists (... | Create . htaccess file in specified directory |
23,823 | protected static function createWebConfigFiles ( ) { if ( ! SettingsServer :: isIIS ( ) ) { return ; } @ file_put_contents ( PIWIK_INCLUDE_PATH . '/web.config' , '<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <security> <requestFiltering> <hiddenSegments> <add segment... | Generate IIS web . config files to restrict access |
23,824 | public static function deleteHtAccessFiles ( ) { $ files = Filesystem :: globr ( PIWIK_INCLUDE_PATH , ".htaccess" ) ; $ directoriesWithAutoHtaccess = array ( '/js' , '/libs' , '/vendor' , '/plugins' , '/misc/user' , '/config' , '/core' , '/lang' , '/tmp' , ) ; foreach ( $ files as $ file ) { foreach ( $ directoriesWith... | Deletes all existing . htaccess files and web . config files that Matomo may have created |
23,825 | public static function isGdExtensionEnabled ( ) { static $ gd = null ; if ( is_null ( $ gd ) ) { $ gd = false ; $ extensions = @ get_loaded_extensions ( ) ; if ( is_array ( $ extensions ) ) { $ gd = in_array ( 'gd' , $ extensions ) && function_exists ( 'imageftbbox' ) ; } } return $ gd ; } | Returns true if the GD PHP extension is available false if otherwise . |
23,826 | public static function raiseMemoryLimitIfNecessary ( ) { $ memoryLimit = self :: getMemoryLimitValue ( ) ; if ( $ memoryLimit === false ) { return false ; } $ minimumMemoryLimit = Config :: getInstance ( ) -> General [ 'minimum_memory_limit' ] ; if ( self :: isArchivePhpTriggered ( ) ) { self :: setMaxExecutionTime ( 0... | Raise PHP memory limit if below the minimum required |
23,827 | protected static function setMemoryLimit ( $ minimumMemoryLimit ) { $ currentValue = self :: getMemoryLimitValue ( ) ; if ( $ currentValue === false || ( $ currentValue < $ minimumMemoryLimit && @ ini_set ( 'memory_limit' , $ minimumMemoryLimit . 'M' ) ) ) { return true ; } return false ; } | Set PHP memory limit |
23,828 | public function getNumberOfVisitsByVisitCount ( $ idSite , $ period , $ date , $ segment = false ) { $ dataTable = $ this -> getDataTable ( Archiver :: VISITS_COUNT_RECORD_NAME , $ idSite , $ period , $ date , $ segment , Metrics :: INDEX_NB_VISITS ) ; $ dataTable -> queueFilter ( 'AddSegmentByRangeLabel' , array ( 'vi... | Returns a DataTable that associates ranges of visit numbers with the count of visits whose visit number falls within those ranges . |
23,829 | protected function makeSetting ( $ name , $ defaultValue , $ type , $ fieldConfigCallback ) { $ setting = new MeasurableSetting ( $ name , $ defaultValue , $ type , $ this -> pluginName , $ this -> idSite ) ; $ setting -> setConfigureCallback ( $ fieldConfigCallback ) ; $ this -> addSetting ( $ setting ) ; return $ set... | Creates a new measurable setting . |
23,830 | public function getTableStatus ( $ table ) { $ prefixed = Common :: prefixTable ( $ table ) ; if ( ! is_null ( $ this -> tableStatuses ) && isset ( $ this -> tableStatuses [ $ prefixed ] ) ) { return $ this -> tableStatuses [ $ prefixed ] ; } else { return $ this -> dataAccess -> getTableStatus ( $ prefixed ) ; } } | Gets the MySQL table status of the requested Piwik table . |
23,831 | public function getAllTablesStatus ( $ matchingRegex = null ) { if ( is_null ( $ this -> tableStatuses ) ) { $ tablesPiwik = DbHelper :: getTablesInstalled ( ) ; $ this -> tableStatuses = array ( ) ; foreach ( $ this -> dataAccess -> getAllTablesStatus ( ) as $ t ) { if ( in_array ( $ t [ 'Name' ] , $ tablesPiwik ) ) {... | Gets the result of a SHOW TABLE STATUS query for every Piwik table in the DB . Non - piwik tables are ignored . |
23,832 | public function getRowCountsAndSizeByBlobName ( $ forceCache = false ) { $ extraSelects = array ( "SUM(OCTET_LENGTH(value)) AS 'blob_size'" , "SUM(LENGTH(name)) AS 'name_size'" ) ; $ extraCols = array ( 'blob_size' , 'name_size' ) ; return $ this -> getRowCountsByArchiveName ( $ this -> getAllBlobArchiveStatus ( ) , 'g... | Returns a DataTable that lists the number of rows and the estimated amount of space each blob archive type takes up in the database . |
23,833 | private function getRowCountsByArchiveName ( $ statuses , $ getRowSizeMethod , $ forceCache = false , $ otherSelects = array ( ) , $ otherDataTableColumns = array ( ) ) { $ extraCols = '' ; if ( ! empty ( $ otherSelects ) ) { $ extraCols = ', ' . implode ( ', ' , $ otherSelects ) ; } $ cols = array_merge ( array ( 'row... | Utility function . Gets row count of a set of tables grouped by the name column . This is the implementation of the getRowCountsAndSizeBy ... functions . |
23,834 | public function getEstimatedRowsSize ( $ row_count , $ status ) { if ( $ status [ 'Rows' ] == 0 ) { return 0 ; } $ avgRowSize = ( $ status [ 'Data_length' ] + $ status [ 'Index_length' ] ) / $ status [ 'Rows' ] ; return $ avgRowSize * $ row_count ; } | Gets the estimated database size a count of rows takes in a table . |
23,835 | public function getEstimatedBlobArchiveRowSize ( $ row_count , $ blob_size , $ name_size , $ status ) { static $ fixedSizeColumnLength = null ; if ( is_null ( $ fixedSizeColumnLength ) ) { $ fixedSizeColumnLength = 0 ; foreach ( $ this -> dataAccess -> getColumnsFromTable ( $ status [ 'Name' ] ) as $ column ) { $ colum... | Gets the estimated database size a count of rows in a blob_archive table . Depends on the data table row to contain the size of all blobs & name strings in the row set it represents . |
23,836 | public function reduceArchiveRowName ( $ name ) { if ( strpos ( $ name , 'done' ) === 0 ) { return 'done' ; } if ( preg_match ( "/^Goal_(?:-?[0-9]+_)?(.*)/" , $ name , $ matches ) ) { $ name = "Goal_*_" . $ matches [ 1 ] ; } if ( preg_match ( "/^(.*)_[0-9]+$/" , $ name , $ matches ) ) { $ name = $ matches [ 1 ] . "_*" ... | Reduces the given metric name . Used to simplify certain reports . |
23,837 | public function queryEnd ( $ queryId ) { $ state = parent :: queryEnd ( $ queryId ) ; if ( ! $ this -> getEnabled ( ) || $ state == self :: IGNORED ) { return ; } $ this -> _message -> setDestroy ( false ) ; $ profile = $ this -> getQueryProfile ( $ queryId ) ; $ this -> _totalElapsedTime += $ profile -> getElapsedSecs... | Intercept the query end and log the profiling data . |
23,838 | protected function updateMessageLabel ( ) { if ( ! $ this -> _message ) { return ; } $ this -> _message -> setLabel ( str_replace ( array ( '%label%' , '%totalCount%' , '%totalDuration%' ) , array ( $ this -> _label , $ this -> getTotalNumQueries ( ) , ( string ) round ( $ this -> _totalElapsedTime , 5 ) ) , $ this -> ... | Update the label of the message holding the profile info . |
23,839 | public function setVisitorIpAddress ( & $ ip ) { $ ipObject = IP :: fromBinaryIP ( $ ip ) ; if ( ! $ this -> isActive ( ) ) { Common :: printDebug ( "Visitor IP was _not_ anonymized: " . $ ipObject -> toString ( ) ) ; return ; } $ privacyConfig = new Config ( ) ; $ newIpObject = self :: applyIPMask ( $ ipObject , $ pri... | Hook on Tracker . Visit . setVisitorIp to anomymize visitor IP addresses |
23,840 | public static function isSessionHandler ( $ handler ) { $ config = Config :: getInstance ( ) ; return ! isset ( $ config -> General [ 'session_save_handler' ] ) || $ config -> General [ 'session_save_handler' ] === $ handler ; } | Are we using file - based session store? |
23,841 | public function getMetricsFromVisitByDimension ( $ dimension ) { if ( ! is_array ( $ dimension ) ) { $ dimension = array ( $ dimension ) ; } if ( count ( $ dimension ) == 1 ) { $ dimension = array ( "label" => reset ( $ dimension ) ) ; } $ query = $ this -> queryVisitsByDimension ( $ dimension ) ; $ metrics = new DataA... | Helper function that returns an array with common metrics for a given log_visit field distinct values . |
23,842 | public function queryVisitsByDimension ( array $ dimensions = array ( ) , $ where = false , array $ additionalSelects = array ( ) , $ metrics = false , $ rankingQuery = false ) { $ tableName = self :: LOG_VISIT_TABLE ; $ availableMetrics = $ this -> getVisitsMetricFields ( ) ; $ select = $ this -> getSelectStatement ( ... | Executes and returns a query aggregating visit logs optionally grouping by some dimension . Returns a DB statement that can be used to iterate over the result |
23,843 | public function getGeneralQueryBindParams ( ) { $ bind = array ( $ this -> dateStart -> toString ( Date :: DATE_TIME_FORMAT ) , $ this -> dateEnd -> toString ( Date :: DATE_TIME_FORMAT ) ) ; $ bind = array_merge ( $ bind , $ this -> sites ) ; return $ bind ; } | Returns general bind parameters for all log aggregation queries . This includes the datetime start of entities datetime end of entities and IDs of all sites . |
23,844 | public static function getSelectsFromRangedColumn ( $ column , $ ranges , $ table , $ selectColumnPrefix , $ restrictToReturningVisitors = false ) { $ selects = array ( ) ; $ extraCondition = '' ; if ( $ restrictToReturningVisitors ) { $ extraCondition = 'and log_visit.visitor_returning = 1' ; $ extraSelect = "sum(case... | Creates and returns an array of SQL SELECT expressions that will each count how many rows have a column whose value is within a certain range . |
23,845 | public static function sendHttpRequest ( $ aUrl , $ timeout , $ userAgent = null , $ destinationPath = null , $ followDepth = 0 , $ acceptLanguage = false , $ byteRange = false , $ getExtendedInfo = false , $ httpMethod = 'GET' , $ httpUsername = null , $ httpPassword = null ) { $ file = self :: ensureDestinationDirect... | Sends an HTTP request using best available transport method . |
23,846 | private static function truncateStr ( $ str , $ limit ) { if ( strlen ( $ str ) > $ limit ) { return substr ( $ str , 0 , $ limit ) . '...' ; } return $ str ; } | Utility function that truncates a string to an arbitrary limit . |
23,847 | public static function getModifiedSinceHeader ( ) { $ modifiedSince = '' ; if ( isset ( $ _SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] ) ) { $ modifiedSince = $ _SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] ; if ( false !== ( $ semicolonPos = strpos ( $ modifiedSince , ';' ) ) ) { $ modifiedSince = substr ( $ modifiedSince , 0 , $ semi... | Returns the If - Modified - Since HTTP header if it can be found . If it cannot be found an empty string is returned . |
23,848 | private static function getProxyConfiguration ( $ url ) { $ hostname = UrlHelper :: getHostFromUrl ( $ url ) ; if ( Url :: isLocalHost ( $ hostname ) ) { return array ( null , null , null , null ) ; } $ proxyHost = Config :: getInstance ( ) -> proxy [ 'host' ] ; $ proxyPort = Config :: getInstance ( ) -> proxy [ 'port'... | Returns Proxy to use for connecting via HTTP to given URL |
23,849 | public function setMax ( $ max ) { if ( is_array ( $ max ) and isset ( $ max [ 'max' ] ) ) { $ max = $ max [ 'max' ] ; } if ( ! is_string ( $ max ) and ! is_numeric ( $ max ) ) { throw new Zend_Validate_Exception ( 'Invalid options to validator provided' ) ; } $ max = ( integer ) $ max ; if ( ( $ this -> _min !== null ... | Sets the maximum file count |
23,850 | public function addFile ( $ file ) { if ( is_string ( $ file ) ) { $ file = array ( $ file ) ; } if ( is_array ( $ file ) ) { foreach ( $ file as $ name ) { if ( ! isset ( $ this -> _files [ $ name ] ) && ! empty ( $ name ) ) { $ this -> _files [ $ name ] = $ name ; } } } return $ this ; } | Adds a file for validation |
23,851 | private static function shouldKeepURLFragmentsFor ( $ site ) { if ( $ site [ 'keep_url_fragment' ] == self :: KEEP_URL_FRAGMENT_YES ) { return true ; } else if ( $ site [ 'keep_url_fragment' ] == self :: KEEP_URL_FRAGMENT_NO ) { return false ; } return API :: getInstance ( ) -> getKeepURLFragmentsGlobal ( ) ; } | Returns whether we should keep URL fragments for a specific site . |
23,852 | private function getTrackerExcludedIps ( $ website ) { $ excludedIps = $ website [ 'excluded_ips' ] ; $ globalExcludedIps = API :: getInstance ( ) -> getExcludedIpsGlobal ( ) ; $ excludedIps .= ',' . $ globalExcludedIps ; $ ipRanges = array ( ) ; foreach ( explode ( ',' , $ excludedIps ) as $ ip ) { $ ipRange = API :: ... | Returns the array of excluded IPs to save in the config file |
23,853 | private static function getExcludedUserAgents ( $ website ) { $ excludedUserAgents = API :: getInstance ( ) -> getExcludedUserAgentsGlobal ( ) ; if ( API :: getInstance ( ) -> isSiteSpecificUserAgentExcludeEnabled ( ) ) { $ excludedUserAgents .= ',' . $ website [ 'excluded_user_agents' ] ; } return self :: filterBlankF... | Returns the array of excluded user agent substrings for a site . Filters out any garbage data & trims each entry . |
23,854 | public static function getTrackerExcludedQueryParameters ( $ website ) { $ excludedQueryParameters = $ website [ 'excluded_parameters' ] ; $ globalExcludedQueryParameters = API :: getInstance ( ) -> getExcludedQueryParametersGlobal ( ) ; $ excludedQueryParameters .= ',' . $ globalExcludedQueryParameters ; return self :... | Returns the array of URL query parameters to exclude from URLs |
23,855 | private function getTrackerHosts ( $ urls ) { $ hosts = array ( ) ; foreach ( $ urls as $ url ) { $ url = parse_url ( $ url ) ; if ( isset ( $ url [ 'host' ] ) ) { $ hosts [ ] = $ url [ 'host' ] ; } } return $ hosts ; } | Returns the hosts alias URLs |
23,856 | public static function factory ( $ type , $ properties ) { switch ( $ type ) { case 'evolution' : return new JqplotDataGenerator \ Evolution ( $ properties , $ type ) ; case 'pie' : case 'bar' : return new JqplotDataGenerator ( $ properties , $ type ) ; default : throw new Exception ( "Unknown JqplotDataGenerator type ... | Creates a new JqplotDataGenerator instance for a graph type and view properties . |
23,857 | public function generate ( $ dataTable ) { $ visualization = new Chart ( ) ; if ( $ dataTable -> getRowsCount ( ) > 0 ) { if ( $ this -> properties [ 'add_total_row' ] ) { $ dataTable -> queueFilter ( 'AddSummaryRow' , Piwik :: translate ( 'General_Total' ) ) ; } $ dataTable -> applyQueuedFilters ( ) ; $ this -> initCh... | Generates JSON graph data and returns it . |
23,858 | public static function getInstance ( $ userAgent ) { if ( array_key_exists ( $ userAgent , self :: $ deviceDetectorInstances ) ) { return self :: $ deviceDetectorInstances [ $ userAgent ] ; } $ deviceDetector = new DeviceDetector ( $ userAgent ) ; $ deviceDetector -> discardBotInformation ( ) ; $ deviceDetector -> setC... | Returns a Singleton instance of DeviceDetector for the given user agent |
23,859 | public function isConnectionUTF8 ( ) { $ charsetInfo = $ this -> fetchAll ( 'SHOW VARIABLES LIKE ?' , array ( 'character_set_connection' ) ) ; if ( empty ( $ charsetInfo ) ) { return false ; } $ charset = $ charsetInfo [ 0 ] [ 'Value' ] ; return $ charset === 'utf8' ; } | Is the connection character set equal to utf8? |
23,860 | public function query ( $ sql , $ bind = array ( ) ) { if ( ! is_string ( $ sql ) ) { return parent :: query ( $ sql , $ bind ) ; } if ( isset ( $ this -> cachePreparedStatement [ $ sql ] ) ) { if ( ! is_array ( $ bind ) ) { $ bind = array ( $ bind ) ; } $ stmt = $ this -> cachePreparedStatement [ $ sql ] ; $ stmt -> e... | Prepares and executes an SQL statement with bound data . Caches prepared statements to avoid preparing the same query more than once |
23,861 | protected static function normalizePath ( $ path ) { $ pathAry = explode ( '/' , $ path ) ; $ i = 1 ; do { if ( '.' == $ pathAry [ $ i ] ) { if ( $ i < count ( $ pathAry ) - 1 ) { array_splice ( $ pathAry , $ i , 1 ) ; } else { $ pathAry [ $ i ] = '' ; $ i ++ ; } } elseif ( '..' == $ pathAry [ $ i ] ) { if ( 1 == $ i )... | Removes the .. and . segments from the path component |
23,862 | protected static function resolveRelativeURL ( $ url ) { $ https = ! empty ( $ _SERVER [ 'HTTPS' ] ) && ( 'off' != strtolower ( $ _SERVER [ 'HTTPS' ] ) ) ; $ scheme = ( $ https ? 'https:' : 'http:' ) ; if ( '//' == substr ( $ url , 0 , 2 ) ) { return $ scheme . $ url ; } else { $ host = $ scheme . '//' . $ _SERVER [ 'S... | Resolves relative URL using current page s URL as base |
23,863 | public function render ( ) { $ xml = new SimpleXMLElement ( '<zend-config xmlns:zf="' . Zend_Config_Xml :: XML_NAMESPACE . '"/>' ) ; $ extends = $ this -> _config -> getExtends ( ) ; $ sectionName = $ this -> _config -> getSectionName ( ) ; if ( is_string ( $ sectionName ) ) { $ child = $ xml -> addChild ( $ sectionNam... | Render a Zend_Config into a XML config string . |
23,864 | protected function _addBranch ( Zend_Config $ config , SimpleXMLElement $ xml , SimpleXMLElement $ parent ) { $ branchType = null ; foreach ( $ config as $ key => $ value ) { if ( $ branchType === null ) { if ( is_numeric ( $ key ) ) { $ branchType = 'numeric' ; $ branchName = $ xml -> getName ( ) ; $ xml = $ parent ; ... | Add a branch to an XML object recursively |
23,865 | protected function getMessageFromException ( $ e ) { if ( $ e -> getCode ( ) == 1044 || $ e -> getCode ( ) == 42000 ) { return "Error while connecting to the Matomo database - please check your credentials in config/config.ini.php file" ; } if ( Common :: isPhpCliMode ( ) ) { return $ e -> getMessage ( ) . "\n" . $ e -... | Gets the error message to output when a tracking request fails . |
23,866 | public function getDefaultPeriod ( $ defaultDate = null ) { list ( $ defaultDate , $ defaultPeriod ) = $ this -> getDefaultDateAndPeriod ( $ defaultDate ) ; return $ defaultPeriod ; } | Returns default period type for Piwik reports . |
23,867 | public function filter ( $ translations ) { $ cleanedTranslations = array ( ) ; foreach ( $ translations as $ pluginName => $ pluginTranslations ) { foreach ( $ pluginTranslations as $ key => $ translation ) { if ( isset ( $ this -> baseTranslations [ $ pluginName ] [ $ key ] ) ) { $ baseTranslation = $ this -> baseTra... | Removes all translations where the placeholder parameter count differs to base translation |
23,868 | protected function _getParametersCountToReplace ( $ string ) { $ sprintfParameters = array ( '%s' , '%1$s' , '%2$s' , '%3$s' , '%4$s' , '%5$s' , '%6$s' , '%7$s' , '%8$s' , '%9$s' ) ; $ count = array ( ) ; foreach ( $ sprintfParameters as $ parameter ) { $ placeholderCount = substr_count ( $ string , $ parameter ) ; if ... | Counts the placeholder parameters n given string |
23,869 | private function getUserDatabaseMigrations ( $ queries ) { $ queries [ ] = $ this -> migration -> db -> changeColumn ( $ this -> userTable , 'password' , 'password' , 'VARCHAR(255) NOT NULL' ) ; return $ queries ; } | Returns database migrations for this update . |
23,870 | private function getUserPasswordMigrations ( $ queries ) { $ db = Db :: get ( ) ; $ userTable = Common :: prefixTable ( $ this -> userTable ) ; $ users = $ db -> fetchAll ( 'SELECT `login`, `password` FROM `' . $ userTable . '` WHERE LENGTH(`password`) = 32' ) ; foreach ( $ users as $ user ) { $ queries [ ] = $ this ->... | Returns migrations to hash existing password with bcrypt . |
23,871 | protected function adjustHour ( $ rescheduledTime ) { if ( $ this -> hour !== null ) { $ rescheduledTime = mktime ( $ this -> hour , 0 , date ( 's' , $ rescheduledTime ) , date ( 'n' , $ rescheduledTime ) , date ( 'j' , $ rescheduledTime ) , date ( 'Y' , $ rescheduledTime ) ) ; } return $ rescheduledTime ; } | Computes the delta in seconds needed to adjust the rescheduled time to the required hour . |
23,872 | public static function factory ( $ periodType , $ periodDay = false ) { switch ( $ periodType ) { case 'hourly' : return new Hourly ( ) ; case 'daily' : return new Daily ( ) ; case 'weekly' : $ result = new Weekly ( ) ; if ( $ periodDay !== false ) { $ result -> setDay ( $ periodDay ) ; } return $ result ; case 'monthl... | Returns a new Schedule instance using a string description of the scheduled period type and a string description of the day within the period to execute the task on . |
23,873 | public function loadActivatedPlugins ( ) { $ pluginsToLoad = $ this -> getActivatedPluginsFromConfig ( ) ; if ( ! SettingsPiwik :: isInternetEnabled ( ) ) { $ pluginsToLoad = array_filter ( $ pluginsToLoad , function ( $ name ) { $ plugin = Manager :: makePluginClass ( $ name ) ; return ! $ plugin -> requiresInternetCo... | Loads plugin that are enabled |
23,874 | public function loadCorePluginsDuringTracker ( ) { $ pluginsToLoad = $ this -> pluginList -> getActivatedPlugins ( ) ; $ pluginsToLoad = array_diff ( $ pluginsToLoad , $ this -> getTrackerPluginsNotToLoad ( ) ) ; $ this -> loadPlugins ( $ pluginsToLoad ) ; } | Called during Tracker |
23,875 | private function updatePluginsConfig ( $ pluginsToLoad ) { $ pluginsToLoad = $ this -> pluginList -> sortPluginsAndRespectDependencies ( $ pluginsToLoad ) ; $ section = PiwikConfig :: getInstance ( ) -> Plugins ; $ section [ 'Plugins' ] = $ pluginsToLoad ; PiwikConfig :: getInstance ( ) -> Plugins = $ section ; } | Update Plugins config |
23,876 | private function updatePluginsInstalledConfig ( $ plugins ) { $ section = PiwikConfig :: getInstance ( ) -> PluginsInstalled ; $ section [ 'PluginsInstalled' ] = $ plugins ; PiwikConfig :: getInstance ( ) -> PluginsInstalled = $ section ; } | Update PluginsInstalled config |
23,877 | public function isPluginActivated ( $ name ) { return in_array ( $ name , $ this -> pluginsToLoad ) || ( $ this -> doLoadAlwaysActivatedPlugins && $ this -> isPluginAlwaysActivated ( $ name ) ) ; } | Returns true if a plugin has been activated . |
23,878 | public static function getPluginDirectory ( $ pluginName ) { if ( isset ( self :: $ pluginsToPathCache [ $ pluginName ] ) ) { return self :: $ pluginsToPathCache [ $ pluginName ] ; } $ corePluginsDir = PIWIK_INCLUDE_PATH . '/plugins/' . $ pluginName ; if ( is_dir ( $ corePluginsDir ) ) { self :: $ pluginsToPathCache [ ... | Gets the path to a specific plugin . If the plugin does not exist in any plugins folder the default plugins folder will be assumed . |
23,879 | public function findComponents ( $ componentName , $ expectedSubclass ) { $ plugins = $ this -> getPluginsLoadedAndActivated ( ) ; $ components = array ( ) ; foreach ( $ plugins as $ plugin ) { $ component = $ plugin -> findComponent ( $ componentName , $ expectedSubclass ) ; if ( ! empty ( $ component ) ) { $ componen... | Tries to find the given components such as a Menu or Tasks implemented by plugins . This method won t cache the found components . If you need to find the same component multiple times you might want to cache the result to save a tiny bit of time . |
23,880 | public function installLoadedPlugins ( ) { Log :: debug ( "Loaded plugins: " . implode ( ", " , array_keys ( $ this -> getLoadedPlugins ( ) ) ) ) ; foreach ( $ this -> getLoadedPlugins ( ) as $ plugin ) { $ this -> installPluginIfNecessary ( $ plugin ) ; } } | Install loaded plugins |
23,881 | public function getThemeEnabled ( ) { $ plugins = $ this -> getLoadedPlugins ( ) ; $ theme = false ; foreach ( $ plugins as $ plugin ) { if ( $ plugin -> isTheme ( ) && $ this -> isPluginActivated ( $ plugin -> getPluginName ( ) ) ) { if ( $ plugin -> getPluginName ( ) != self :: DEFAULT_THEME ) { return $ plugin ; } $... | Returns the currently enabled theme . |
23,882 | public function loadAllPluginsAndGetTheirInfo ( ) { $ translator = StaticContainer :: get ( 'Piwik\Translation\Translator' ) ; $ plugins = array ( ) ; $ listPlugins = array_merge ( $ this -> readPluginsDirectory ( ) , $ this -> pluginList -> getActivatedPlugins ( ) ) ; $ listPlugins = array_unique ( $ listPlugins ) ; $... | Returns info regarding all plugins . Loads plugins that can be loaded . |
23,883 | public function isPluginBundledWithCore ( $ name ) { return $ this -> isPluginEnabledByDefault ( $ name ) || in_array ( $ name , $ this -> pluginList -> getCorePluginsDisabledByDefault ( ) ) || $ name == self :: DEFAULT_THEME ; } | Returns true if the plugin is bundled with core or false if it is third party . |
23,884 | public function loadPlugins ( array $ pluginsToLoad ) { $ this -> resetTransientCache ( ) ; $ this -> pluginsToLoad = $ this -> makePluginsToLoad ( $ pluginsToLoad ) ; $ this -> reloadActivatedPlugins ( ) ; } | Load AND activates the specified plugins . It will also overwrite all previously loaded plugins so it acts as a setter . |
23,885 | public function getPluginsLoadedAndActivated ( ) { if ( is_null ( $ this -> pluginsLoadedAndActivated ) ) { $ enabled = $ this -> getActivatedPlugins ( ) ; if ( empty ( $ enabled ) ) { return array ( ) ; } $ plugins = $ this -> getLoadedPlugins ( ) ; $ enabled = array_combine ( $ enabled , $ enabled ) ; $ plugins = arr... | Returns an array of plugins that are currently loaded and activated mapping loaded plugin names with their plugin objects eg |
23,886 | public function getLoadedPlugin ( $ name ) { if ( ! isset ( $ this -> loadedPlugins [ $ name ] ) || is_null ( $ this -> loadedPlugins [ $ name ] ) ) { throw new \ Exception ( "The plugin '$name' has not been loaded." ) ; } return $ this -> loadedPlugins [ $ name ] ; } | Returns a Plugin object by name . |
23,887 | private function reloadActivatedPlugins ( ) { $ pluginsToPostPendingEventsTo = array ( ) ; foreach ( $ this -> pluginsToLoad as $ pluginName ) { $ pluginsToPostPendingEventsTo = $ this -> reloadActivatedPlugin ( $ pluginName , $ pluginsToPostPendingEventsTo ) ; } foreach ( $ pluginsToPostPendingEventsTo as $ plugin ) {... | Load the plugins classes installed . Register the observers for every plugin . |
23,888 | public function unloadPlugins ( ) { $ this -> resetTransientCache ( ) ; $ pluginsLoaded = $ this -> getLoadedPlugins ( ) ; foreach ( $ pluginsLoaded as $ plugin ) { $ this -> unloadPlugin ( $ plugin ) ; } } | Unload all loaded plugins |
23,889 | private function executePluginInstall ( Plugin $ plugin ) { try { $ plugin -> install ( ) ; } catch ( \ Exception $ e ) { throw new \ Piwik \ Plugin \ PluginException ( $ plugin -> getPluginName ( ) , $ e -> getMessage ( ) ) ; } } | Install a specific plugin |
23,890 | public function addLoadedPlugin ( $ pluginName , Plugin $ newPlugin ) { $ this -> resetTransientCache ( ) ; $ this -> loadedPlugins [ $ pluginName ] = $ newPlugin ; } | Add a plugin in the loaded plugins array |
23,891 | public function getMissingPlugins ( ) { $ missingPlugins = array ( ) ; $ plugins = $ this -> pluginList -> getActivatedPlugins ( ) ; foreach ( $ plugins as $ pluginName ) { if ( ! $ this -> isPluginLoaded ( $ pluginName ) && ! $ this -> isPluginBogus ( $ pluginName ) && ! ( $ this -> doesPluginRequireInternetConnection... | Returns names of plugins that should be loaded but cannot be since their files cannot be found . |
23,892 | private function installPluginIfNecessary ( Plugin $ plugin ) { $ pluginName = $ plugin -> getPluginName ( ) ; $ saveConfig = false ; $ pluginsInstalled = $ this -> getInstalledPluginsName ( ) ; if ( ! $ this -> isPluginInstalled ( $ pluginName ) ) { $ this -> executePluginInstall ( $ plugin ) ; $ pluginsInstalled [ ] ... | Install a plugin if necessary |
23,893 | public function getPastRowFromCurrent ( Row $ row ) { $ pastData = $ this -> getPastDataTable ( ) ; if ( empty ( $ pastData ) ) { return null ; } $ label = $ row -> getColumn ( 'label' ) ; return $ label ? $ pastData -> getRowFromLabel ( $ label ) : $ pastData -> getFirstRow ( ) ; } | public for Insights use . |
23,894 | public function isValidReportForSite ( $ idSite , $ apiMethodUniqueId ) { $ report = $ this -> getReportMetadataByUniqueId ( $ idSite , $ apiMethodUniqueId ) ; return ! empty ( $ report ) ; } | Verfies whether the given report exists for the given site . |
23,895 | public function isValidMetricForReport ( $ metric , $ idSite , $ apiMethodUniqueId ) { $ translation = $ this -> translateMetric ( $ metric , $ idSite , $ apiMethodUniqueId ) ; return ! empty ( $ translation ) ; } | Verfies whether the given metric belongs to the given report . |
23,896 | public function translateMetric ( $ metric , $ idSite , $ apiMethodUniqueId ) { $ report = $ this -> getReportMetadataByUniqueId ( $ idSite , $ apiMethodUniqueId ) ; if ( empty ( $ report ) ) { return ; } $ properties = array ( 'metrics' , 'processedMetrics' , 'processedMetricsGoal' ) ; foreach ( $ properties as $ prop... | Translates the given metric in case the report exists and in case the metric acutally belongs to the report . |
23,897 | private function removeEmptyColumns ( & $ columns , & $ reportMetadata , $ dataTable ) { $ emptyColumns = $ dataTable -> getMetadata ( DataTable :: EMPTY_COLUMNS_METADATA_NAME ) ; if ( ! is_array ( $ emptyColumns ) ) { return ; } $ columnsToRemove = $ this -> getColumnsToRemove ( ) ; $ columnsToKeep = $ this -> getColu... | Removes metrics from the list of columns and the report meta data if they are marked empty in the data table meta data . |
23,898 | private function hideShowMetrics ( $ columns , $ emptyColumns = array ( ) ) { if ( ! is_array ( $ columns ) ) { return $ columns ; } $ columnsToRemove = $ this -> getColumnsToRemove ( ) ; $ columnsToKeep = $ this -> getColumnsToKeep ( ) ; return $ this -> hideShowMetricsWithParams ( $ columns , $ columnsToRemove , $ co... | Removes column names from an array based on the values in the hideColumns showColumns query parameters . This is a hack that provides the ColumnDelete filter functionality in processed reports . |
23,899 | public static function getPrettyValue ( Formatter $ formatter , $ idSite , $ columnName , $ value ) { if ( ! is_numeric ( $ value ) ) { return $ value ; } if ( strpos ( $ columnName , 'time_generation' ) !== false ) { return $ formatter -> getPrettyTimeFromSeconds ( $ value , true ) ; } if ( strpos ( $ columnName , 'ti... | Prettifies a metric value based on the column name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.