idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
25,000 | public function isWorking ( ) { if ( empty ( $ _SERVER [ self :: TEST_SERVER_VAR ] ) && empty ( $ _SERVER [ self :: TEST_SERVER_VAR_ALT ] ) && empty ( $ _SERVER [ self :: TEST_SERVER_VAR_ALT_IPV6 ] ) ) { return Piwik :: translate ( "UserCountry_CannotFindGeoIPServerVar" , self :: TEST_SERVER_VAR . ' $_SERVER' ) ; } ret... | Returns true if the GEOIP_ADDR server variable is defined . |
25,001 | public static function getRegionNameFromCodes ( $ countryCode , $ regionCode ) { $ regionNames = self :: getRegionNames ( ) ; $ countryCode = strtoupper ( $ countryCode ) ; $ regionCode = strtoupper ( $ regionCode ) ; if ( isset ( $ regionNames [ $ countryCode ] [ $ regionCode ] ) ) { return $ regionNames [ $ countryCo... | Returns a region name for a country code + region code . |
25,002 | public static function convertRegionCodeToIso ( $ countryCode , $ fipsRegionCode , $ returnOriginalIfNotFound = false ) { static $ mapping ; if ( empty ( $ mapping ) ) { $ mapping = include __DIR__ . '/../data/regionMapping.php' ; } $ countryCode = strtoupper ( $ countryCode ) ; if ( empty ( $ countryCode ) || in_array... | Converts an old FIPS region code to ISO |
25,003 | private function getReferrerSparklineParams ( $ referrerType ) { $ totalRow = $ this -> translator -> translate ( 'General_Total' ) ; return array ( 'columns' => array ( 'nb_visits' ) , 'rows' => array ( self :: getTranslatedReferrerTypeLabel ( $ referrerType ) , $ totalRow ) , 'typeReferrer' => $ referrerType , 'modul... | Returns the URL for the sparkline of visits with a specific referrer type . |
25,004 | private function getDistinctReferrersMetrics ( $ date = false ) { $ propertyToAccessorMapping = array ( 'numberDistinctSearchEngines' => 'getNumberOfDistinctSearchEngines' , 'numberDistinctSocialNetworks' => 'getNumberOfDistinctSocialNetworks' , 'numberDistinctKeywords' => 'getNumberOfDistinctKeywords' , 'numberDistinc... | Returns an array containing the number of distinct referrers for each referrer type . |
25,005 | public static function functionExists ( $ function ) { if ( $ function == 'eval' ) { if ( extension_loaded ( 'suhosin' ) ) { return @ ini_get ( "suhosin.executor.disable_eval" ) != "1" ; } return true ; } $ exists = function_exists ( $ function ) ; if ( extension_loaded ( 'suhosin' ) ) { $ blacklist = @ ini_get ( "suho... | Tests if a function exists . Also handles the case where a function is disabled via Suhosin . |
25,006 | protected function _base32Encode ( $ secret , $ padding = true ) { if ( empty ( $ secret ) ) return '' ; $ base32chars = $ this -> _getBase32LookupTable ( ) ; $ secret = str_split ( $ secret ) ; $ binaryString = "" ; for ( $ i = 0 ; $ i < count ( $ secret ) ; $ i ++ ) { $ binaryString .= str_pad ( base_convert ( ord ( ... | Helper class to encode base32 |
25,007 | public static function prefixTables ( ) { $ result = array ( ) ; foreach ( func_get_args ( ) as $ table ) { $ result [ ] = self :: prefixTable ( $ table ) ; } return $ result ; } | Returns an array containing the prefixed table names of every passed argument . |
25,008 | public static function unprefixTable ( $ table ) { static $ prefixTable = null ; if ( is_null ( $ prefixTable ) ) { $ prefixTable = Config :: getInstance ( ) -> database [ 'tables_prefix' ] ; } if ( empty ( $ prefixTable ) || strpos ( $ table , $ prefixTable ) !== 0 ) { return $ table ; } $ count = 1 ; return str_repla... | Removes the prefix from a table name and returns the result . |
25,009 | public static function safe_unserialize ( $ string , $ allowedClasses = [ ] , $ rethrow = false ) { if ( PHP_MAJOR_VERSION >= 7 ) { try { return unserialize ( $ string , [ 'allowed_classes' => empty ( $ allowedClasses ) ? false : $ allowedClasses ] ) ; } catch ( \ Throwable $ e ) { if ( $ rethrow ) { throw $ e ; } $ lo... | Secure wrapper for unserialize which by default disallows unserializing classes |
25,010 | public static function sanitizeInputValues ( $ value , $ alreadyStripslashed = false ) { if ( is_numeric ( $ value ) ) { return $ value ; } elseif ( is_string ( $ value ) ) { $ value = self :: sanitizeString ( $ value ) ; } elseif ( is_array ( $ value ) ) { foreach ( array_keys ( $ value ) as $ key ) { $ newKey = $ key... | Sanitizes a string to help avoid XSS vulnerabilities . |
25,011 | public static function sanitizeInputValue ( $ value ) { $ value = self :: sanitizeLineBreaks ( $ value ) ; $ value = self :: sanitizeString ( $ value ) ; return $ value ; } | Sanitize a single input value and removes line breaks tabs and null characters . |
25,012 | private static function sanitizeString ( $ value ) { $ value = html_entity_decode ( $ value , self :: HTML_ENCODING_QUOTE_STYLE , 'UTF-8' ) ; $ value = self :: sanitizeNullBytes ( $ value ) ; $ tmp = @ htmlspecialchars ( $ value , self :: HTML_ENCODING_QUOTE_STYLE , 'UTF-8' ) ; if ( $ value != '' && $ tmp == '' ) { $ v... | Sanitize a single input value |
25,013 | public static function unsanitizeInputValues ( $ value ) { if ( is_array ( $ value ) ) { $ result = array ( ) ; foreach ( $ value as $ key => $ arrayValue ) { $ result [ $ key ] = self :: unsanitizeInputValues ( $ arrayValue ) ; } return $ result ; } else { return self :: unsanitizeInputValue ( $ value ) ; } } | Unsanitizes one or more values and returns the result . |
25,014 | public static function getRandomInt ( $ min = 0 , $ max = null ) { $ rand = null ; if ( function_exists ( 'random_int' ) ) { try { if ( ! isset ( $ max ) ) { $ max = PHP_INT_MAX ; } $ rand = random_int ( $ min , $ max ) ; } catch ( Exception $ e ) { $ rand = null ; } } if ( ! isset ( $ rand ) ) { if ( function_exists (... | Generates a random integer |
25,015 | public static function convertVisitorIdToBin ( $ id ) { if ( strlen ( $ id ) !== Tracker :: LENGTH_HEX_ID_STRING || @ bin2hex ( self :: hex2bin ( $ id ) ) != $ id ) { throw new Exception ( "visitorId is expected to be a " . Tracker :: LENGTH_HEX_ID_STRING . " hex char string" ) ; } return self :: hex2bin ( $ id ) ; } | This function will convert the input string to the binary representation of the ID but it will throw an Exception if the specified input ID is not correct |
25,016 | public static function convertUserIdToVisitorIdBin ( $ userId ) { require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php' ; $ userIdHashed = \ PiwikTracker :: getUserIdHashed ( $ userId ) ; return self :: convertVisitorIdToBin ( $ userIdHashed ) ; } | Converts a User ID string to the Visitor ID Binary representation . |
25,017 | public static function getBrowserLanguage ( $ browserLang = null ) { static $ replacementPatterns = array ( '/(\\\\.)/' , '/(\s+)/' , '/(\([^)]*\))/' , '/(;q=[0-9.]+)/' , '/\.(.*)/' , '/^C$/' , ) ; if ( is_null ( $ browserLang ) ) { $ browserLang = self :: sanitizeInputValues ( @ $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ... | Returns the browser language code eg . en - gb en ; q = 0 . 5 |
25,018 | public static function getCountry ( $ lang , $ enableLanguageToCountryGuess , $ ip ) { if ( empty ( $ lang ) || strlen ( $ lang ) < 2 || $ lang == self :: LANGUAGE_CODE_INVALID ) { return self :: LANGUAGE_CODE_INVALID ; } $ dataProvider = StaticContainer :: get ( 'Piwik\Intl\Data\Provider\RegionDataProvider' ) ; $ vali... | Returns the visitor country based on the Browser accepted language information but provides a hook for geolocation via IP address . |
25,019 | public static function extractCountryCodeFromBrowserLanguage ( $ browserLanguage , $ validCountries , $ enableLanguageToCountryGuess ) { $ dataProvider = StaticContainer :: get ( 'Piwik\Intl\Data\Provider\LanguageDataProvider' ) ; $ langToCountry = $ dataProvider -> getLanguageToCountryList ( ) ; if ( $ enableLanguageT... | Returns list of valid country codes |
25,020 | public static function getContinent ( $ country ) { $ dataProvider = StaticContainer :: get ( 'Piwik\Intl\Data\Provider\RegionDataProvider' ) ; $ countryList = $ dataProvider -> getCountryList ( ) ; if ( $ country == 'ti' ) { $ country = 'cn' ; } return isset ( $ countryList [ $ country ] ) ? $ countryList [ $ country ... | Returns the continent of a given country |
25,021 | public static function getCampaignParameters ( ) { $ return = array ( Config :: getInstance ( ) -> Tracker [ 'campaign_var_name' ] , Config :: getInstance ( ) -> Tracker [ 'campaign_keyword_var_name' ] , ) ; foreach ( $ return as & $ list ) { if ( strpos ( $ list , ',' ) !== false ) { $ list = explode ( ',' , $ list ) ... | Returns the list of Campaign parameter names that will be read to classify a visit as coming from a Campaign |
25,022 | public static function sendHeader ( $ header , $ replace = true ) { if ( ! Common :: isPhpCliMode ( ) and ! headers_sent ( ) ) { header ( $ header , $ replace ) ; } } | Sets outgoing header . |
25,023 | public static function sendResponseCode ( $ code ) { $ messages = array ( 200 => 'Ok' , 204 => 'No Response' , 301 => 'Moved Permanently' , 302 => 'Found' , 304 => 'Not Modified' , 400 => 'Bad Request' , 401 => 'Unauthorized' , 403 => 'Forbidden' , 404 => 'Not Found' , 500 => 'Internal Server Error' , 503 => 'Service U... | Sends the given response code if supported . |
25,024 | public function toString ( $ format = 'ignored' ) { $ this -> generate ( ) ; $ stringMonth = array ( ) ; foreach ( $ this -> subperiods as $ month ) { $ stringMonth [ ] = $ month -> getDateStart ( ) -> toString ( "Y" ) . "-" . $ month -> getDateStart ( ) -> toString ( "m" ) . "-01" ; } return $ stringMonth ; } | Returns the current period as a string |
25,025 | public function getUsers ( $ idSite , $ period , $ date , $ segment = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ archive = Archive :: build ( $ idSite , $ period , $ date , $ segment ) ; $ dataTable = $ archive -> getDataTable ( Archiver :: USERID_ARCHIVE_RECORD ) ; $ dataTable -> queueFilter ( 'Replace... | Get a report of all User Ids . |
25,026 | public function fetchAll ( $ query , $ parameters = array ( ) ) { try { if ( self :: $ profiling ) { $ timer = $ this -> initProfiler ( ) ; } $ rows = array ( ) ; $ query = $ this -> prepare ( $ query , $ parameters ) ; $ rs = mysqli_query ( $ this -> connection , $ query ) ; if ( is_bool ( $ rs ) ) { throw new DbExcep... | Returns an array containing all the rows of a query result using optional bound parameters . |
25,027 | private function prepare ( $ query , $ parameters ) { if ( ! $ parameters ) { $ parameters = array ( ) ; } elseif ( ! is_array ( $ parameters ) ) { $ parameters = array ( $ parameters ) ; } $ this -> paramNb = 0 ; $ this -> params = & $ parameters ; $ query = preg_replace_callback ( '/\?/' , array ( $ this , 'replacePa... | Input is a prepared SQL statement and parameters Returns the SQL statement |
25,028 | public static function getNumUsableCustomVariables ( ) { $ cache = Cache :: getCacheGeneral ( ) ; $ cacheKey = self :: MAX_NUM_CUSTOMVARS_CACHEKEY ; if ( ! array_key_exists ( $ cacheKey , $ cache ) ) { $ minCustomVar = null ; foreach ( Model :: getScopes ( ) as $ scope ) { $ model = new Model ( $ scope ) ; $ highestInd... | Returns the number of available custom variables that can be used . |
25,029 | public function fetch ( $ id ) { if ( empty ( $ id ) ) { return false ; } if ( array_key_exists ( $ id , self :: $ staticCache ) ) { return self :: $ staticCache [ $ id ] ; } if ( ! $ this -> cache -> contains ( $ id ) ) { return false ; } return $ this -> cache -> fetch ( $ id ) ; } | Function to fetch a cache entry |
25,030 | public function save ( $ id , $ content , $ ttl = 0 ) { if ( empty ( $ id ) ) { return false ; } self :: $ staticCache [ $ id ] = $ content ; return $ this -> cache -> save ( $ id , $ content , $ this -> ttl ) ; } | A function to store content a cache entry . |
25,031 | public static function setSites ( $ sites ) { self :: triggerSetSitesEvent ( $ sites ) ; foreach ( $ sites as $ idsite => $ site ) { self :: setSiteFromArray ( $ idsite , $ site ) ; } } | Sets the cached site data with an array that associates site IDs with individual site data . |
25,032 | public static function setSitesFromArray ( $ sites ) { self :: triggerSetSitesEvent ( $ sites ) ; foreach ( $ sites as $ site ) { $ idSite = null ; if ( ! empty ( $ site [ 'idsite' ] ) ) { $ idSite = $ site [ 'idsite' ] ; } self :: setSiteFromArray ( $ idSite , $ site ) ; } return $ sites ; } | Sets the cached Site data with a non - associated array of site data . |
25,033 | public static function getMinMaxDateAcrossWebsites ( $ siteIds ) { $ siteIds = self :: getIdSitesFromIdSitesString ( $ siteIds ) ; $ now = Date :: now ( ) ; $ minDate = null ; $ maxDate = $ now -> subDay ( 1 ) -> getTimestamp ( ) ; foreach ( $ siteIds as $ idsite ) { $ timezone = Site :: getTimezoneFor ( $ idsite ) ; $... | The Multisites reports displays the first calendar date as the earliest day available for all websites . Also today is the later today available across all timezones . |
25,034 | protected function get ( $ name ) { if ( isset ( $ this -> site [ $ name ] ) ) { return $ this -> site [ $ name ] ; } throw new Exception ( "The property $name could not be found on the website ID " . ( int ) $ this -> id ) ; } | Returns a site property by name . |
25,035 | public static function getIdSitesFromIdSitesString ( $ ids , $ _restrictSitesToLogin = false ) { if ( $ ids === 'all' ) { return API :: getInstance ( ) -> getSitesIdWithAtLeastViewAccess ( $ _restrictSitesToLogin ) ; } if ( is_bool ( $ ids ) ) { return array ( ) ; } if ( ! is_array ( $ ids ) ) { $ ids = explode ( ',' ,... | Checks the given string for valid site IDs and returns them as an array . |
25,036 | protected static function getFor ( $ idsite , $ field ) { if ( ! isset ( self :: $ infoSites [ $ idsite ] ) ) { $ site = API :: getInstance ( ) -> getSiteFromId ( $ idsite ) ; self :: setSiteFromArray ( $ idsite , $ site ) ; } return self :: $ infoSites [ $ idsite ] [ $ field ] ; } | Utility function . Returns the value of the specified field for the site with the specified ID . |
25,037 | public static function getCurrencySymbolFor ( $ idsite ) { $ currencyCode = self :: getCurrencyFor ( $ idsite ) ; $ key = 'Intl_CurrencySymbol_' . $ currencyCode ; $ symbol = Piwik :: translate ( $ key ) ; if ( $ key === $ symbol ) { return $ currencyCode ; } return $ symbol ; } | Returns the currency of the site with the specified ID . |
25,038 | public function getCountryCodeMapping ( ) { $ regionDataProvider = StaticContainer :: get ( 'Piwik\Intl\Data\Provider\RegionDataProvider' ) ; $ countryCodeList = $ regionDataProvider -> getCountryList ( ) ; array_walk ( $ countryCodeList , function ( & $ item , $ key ) { $ item = Piwik :: translate ( 'Intl_Country_' . ... | Returns a simple mapping from country code to country name |
25,039 | public function setLocationProvider ( $ providerId ) { Piwik :: checkUserHasSuperUserAccess ( ) ; if ( ! UserCountry :: isGeoLocationAdminEnabled ( ) ) { throw new \ Exception ( 'Setting geo location has been disabled in config.' ) ; } $ provider = LocationProvider :: setCurrentProvider ( $ providerId ) ; if ( $ provid... | Set the location provider |
25,040 | public function getLocalizedShortString ( ) { $ date = $ this -> getDateStart ( ) ; $ out = $ date -> getLocalized ( Date :: DATE_FORMAT_DAY_MONTH ) ; return $ out ; } | Returns the day of the period as a localized short string |
25,041 | public function getLocalizedLongString ( ) { $ date = $ this -> getDateStart ( ) ; $ out = $ date -> getLocalized ( Date :: DATE_FORMAT_LONG ) ; return $ out ; } | Returns the day of the period as a localized long string |
25,042 | protected function recordQueryProfile ( $ query , $ timer ) { if ( ! isset ( $ this -> queriesProfiling [ $ query ] ) ) { $ this -> queriesProfiling [ $ query ] = array ( 'sum_time_ms' => 0 , 'count' => 0 ) ; } $ time = $ timer -> getTimeMs ( 2 ) ; $ time += $ this -> queriesProfiling [ $ query ] [ 'sum_time_ms' ] ; $ ... | Record query profile |
25,043 | public function recordProfiling ( ) { if ( is_null ( $ this -> connection ) ) { return ; } self :: $ profiling = false ; foreach ( $ this -> queriesProfiling as $ query => $ info ) { $ time = $ info [ 'sum_time_ms' ] ; $ time = Common :: forceDotAsSeparatorForDecimalPoint ( $ time ) ; $ count = $ info [ 'count' ] ; $ q... | When destroyed if SQL profiled enabled logs the SQL profiling information |
25,044 | public static function factory ( $ configDb ) { Piwik :: postEvent ( 'Tracker.getDatabaseConfig' , array ( & $ configDb ) ) ; switch ( $ configDb [ 'adapter' ] ) { case 'PDO\MYSQL' : case 'PDO_MYSQL' : require_once PIWIK_INCLUDE_PATH . '/core/Tracker/Db/Pdo/Mysql.php' ; return new Mysql ( $ configDb ) ; case 'MYSQLI' :... | Factory to create database objects |
25,045 | public static function getDateRangeAndLastN ( $ period , $ endDate , $ defaultLastN = null ) { if ( $ defaultLastN === null ) { $ defaultLastN = self :: getDefaultLastN ( $ period ) ; } $ lastNParamName = self :: getLastNParamName ( $ period ) ; $ lastN = Common :: getRequestVar ( $ lastNParamName , $ defaultLastN , 'i... | Returns the entire date range and lastN value for the current request based on a period type and end date . |
25,046 | public function render ( ) { $ iniString = '' ; $ extends = $ this -> _config -> getExtends ( ) ; $ sectionName = $ this -> _config -> getSectionName ( ) ; if ( $ this -> _renderWithoutSections == true ) { $ iniString .= $ this -> _addBranch ( $ this -> _config ) ; } else if ( is_string ( $ sectionName ) ) { $ iniStrin... | Render a Zend_Config into a INI config string . |
25,047 | protected function _addBranch ( Zend_Config $ config , $ parents = array ( ) ) { $ iniString = '' ; foreach ( $ config as $ key => $ value ) { $ group = array_merge ( $ parents , array ( $ key ) ) ; if ( $ value instanceof Zend_Config ) { $ iniString .= $ this -> _addBranch ( $ value , $ group ) ; } else { $ iniString ... | Add a branch to an INI string recursively |
25,048 | protected function _sortRootElements ( Zend_Config $ config ) { $ configArray = $ config -> toArray ( ) ; $ sections = array ( ) ; foreach ( $ configArray as $ key => $ value ) { if ( is_array ( $ value ) ) { $ sections [ $ key ] = $ value ; unset ( $ configArray [ $ key ] ) ; } } foreach ( $ sections as $ key => $ val... | Root elements that are not assigned to any section needs to be on the top of config . |
25,049 | protected function removeVisitsMetricsFromActionsAggregate ( ) { $ dataArray = & $ this -> dataArray -> getDataArray ( ) ; foreach ( $ dataArray as $ key => & $ row ) { if ( ! self :: isReservedKey ( $ key ) && DataArray :: isRowActions ( $ row ) ) { unset ( $ row [ Metrics :: INDEX_NB_UNIQ_VISITORS ] ) ; unset ( $ row... | Delete Visit Unique Visitor and Users metric from page scope custom variables . |
25,050 | public function getPluginStorage ( $ pluginName , $ userLogin ) { $ id = $ pluginName . '#' . $ userLogin ; if ( ! isset ( $ this -> cache [ $ id ] ) ) { $ backend = new Backend \ PluginSettingsTable ( $ pluginName , $ userLogin ) ; $ this -> cache [ $ id ] = $ this -> makeStorage ( $ backend ) ; } return $ this -> cac... | Get a storage instance for plugin settings . |
25,051 | public function getMeasurableSettingsStorage ( $ idSite , $ pluginName ) { $ id = 'measurableSettings' . ( int ) $ idSite . '#' . $ pluginName ; if ( empty ( $ idSite ) ) { return $ this -> getNonPersistentStorage ( $ id . '#nonpersistent' ) ; } if ( ! isset ( $ this -> cache [ $ id ] ) ) { $ backend = new Backend \ Me... | Get a storage instance for measurable settings . |
25,052 | public function getSitesTable ( $ idSite ) { $ id = 'sitesTable#' . $ idSite ; if ( empty ( $ idSite ) ) { return $ this -> getNonPersistentStorage ( $ id . '#nonpersistent' ) ; } if ( ! isset ( $ this -> cache [ $ id ] ) ) { $ backend = new Backend \ SitesTable ( $ idSite ) ; $ this -> cache [ $ id ] = $ this -> makeS... | Get a storage instance for settings that will be saved in the site table . |
25,053 | public function makeStorage ( BackendInterface $ backend ) { if ( SettingsServer :: isTrackerApiRequest ( ) ) { $ backend = new Backend \ Cache ( $ backend ) ; } return new Storage ( $ backend ) ; } | Makes a new storage object based on a custom backend interface . |
25,054 | public function create ( array $ visitorRawData = array ( ) ) { $ visitor = null ; Piwik :: postEvent ( 'Live.makeNewVisitorObject' , array ( & $ visitor , $ visitorRawData ) ) ; if ( is_null ( $ visitor ) ) { $ visitor = new Visitor ( $ visitorRawData ) ; } elseif ( ! ( $ visitor instanceof VisitorInterface ) ) { thro... | Returns Visitor object . This method can be overwritten to use a different Visitor object |
25,055 | private function linkToLevelAbove ( & $ top , $ elements , $ inGroup = false ) { $ key = $ this -> options [ 'key_id' ] ? 'id' : 'name' ; foreach ( $ elements as & $ elem ) { $ top_key = $ elem [ $ key ] ; if ( ! $ this -> options [ 'key_id' ] && $ inGroup && $ top_key != '' ) { if ( ! ( preg_match ( "/\[?([\w_]+)\]?$/... | Key is name or id . |
25,056 | public function markMoversAndShakers ( DataTable $ insight , $ currentReport , $ lastReport , $ totalValue , $ lastTotalValue ) { if ( ! $ insight -> getRowsCount ( ) ) { return ; } $ limitIncreaser = max ( $ insight -> getRowsCount ( ) , 3 ) ; $ limitDecreaser = max ( $ insight -> getRowsCount ( ) , 3 ) ; $ lastDate =... | Extends an already generated insight report by adding a column isMoverAndShaker whether a row is also a Mover and Shaker or not . |
25,057 | public function filter ( $ className , $ parameters = array ( ) ) { foreach ( $ this -> getDataTables ( ) as $ table ) { $ table -> filter ( $ className , $ parameters ) ; } } | Apply a filter to all tables contained by this instance . |
25,058 | public function filterSubtables ( $ className , $ parameters = array ( ) ) { foreach ( $ this -> getDataTables ( ) as $ table ) { $ table -> filterSubtables ( $ className , $ parameters ) ; } } | Apply a filter to all subtables contained by this instance . |
25,059 | public function queueFilterSubtables ( $ className , $ parameters = array ( ) ) { foreach ( $ this -> getDataTables ( ) as $ table ) { $ table -> queueFilterSubtables ( $ className , $ parameters ) ; } } | Apply a queued filter to all subtables contained by this instance . |
25,060 | private function copyRowsAndSetLabel ( $ toTable , $ fromTable , $ label ) { foreach ( $ fromTable -> getRows ( ) as $ fromRow ) { $ oldColumns = $ fromRow -> getColumns ( ) ; unset ( $ oldColumns [ 'label' ] ) ; $ columns = array_merge ( array ( 'label' => $ label ) , $ oldColumns ) ; $ row = new Row ( array ( Row :: ... | Utility function used by mergeChildren . Copies the rows from one table sets their label columns to a value and adds them to another table . |
25,061 | public function addDataTable ( DataTable $ tableToSum ) { foreach ( $ this -> getDataTables ( ) as $ childTable ) { $ childTable -> addDataTable ( $ tableToSum ) ; } } | Sums a DataTable to all the tables in this array . |
25,062 | protected function detectActionIsOutlinkOnAliasHost ( Action $ action , $ idSite ) { $ decodedActionUrl = $ action -> getActionUrl ( ) ; $ actionUrlParsed = @ parse_url ( $ decodedActionUrl ) ; if ( ! isset ( $ actionUrlParsed [ 'host' ] ) ) { return false ; } return Visit :: isHostKnownAliasHost ( $ actionUrlParsed [ ... | Detect whether action is an outlink given host aliases |
25,063 | public static function isPhpOutputCompressed ( ) { $ zlibOutputCompression = ini_get ( 'zlib.output_compression' ) ; $ outputHandler = ini_get ( 'output_handler' ) ; $ obHandlers = array_filter ( ob_list_handlers ( ) , function ( $ var ) { return $ var !== "default output handler" ; } ) ; if ( ! defined ( 'PIWIK_TEST_M... | Test if php output is compressed |
25,064 | public function registerClass ( $ className ) { if ( isset ( $ this -> alreadyRegistered [ $ className ] ) ) { return ; } $ this -> includeApiFile ( $ className ) ; $ this -> checkClassIsSingleton ( $ className ) ; $ rClass = new ReflectionClass ( $ className ) ; if ( ! $ this -> shouldHideAPIMethod ( $ rClass -> getDo... | Registers the API information of a given module . |
25,065 | private function setDocumentation ( $ rClass , $ className ) { $ doc = $ rClass -> getDocComment ( ) ; $ doc = str_replace ( " * " . PHP_EOL , "<br>" , $ doc ) ; if ( substr_count ( $ doc , '<br>' ) > 1 ) { $ firstLineBreak = strpos ( $ doc , "<br>" ) ; $ doc = "<div class='apiFirstLine'>" . substr ( $ doc , 0 , $ firs... | Will be displayed in the API page |
25,066 | private function getRequestParametersArray ( $ requiredParameters , $ parametersRequest ) { $ finalParameters = array ( ) ; foreach ( $ requiredParameters as $ name => $ defaultValue ) { try { if ( $ defaultValue instanceof NoDefaultValue ) { $ requestValue = Common :: getRequestVar ( $ name , null , null , $ parameter... | Returns an array containing the values of the parameters to pass to the method to call |
25,067 | private function checkMethodExists ( $ className , $ methodName ) { if ( ! $ this -> isMethodAvailable ( $ className , $ methodName ) ) { throw new Exception ( Piwik :: translate ( 'General_ExceptionMethodNotFound' , array ( $ methodName , $ className ) ) ) ; } } | Checks that the method exists in the class |
25,068 | public static function factory ( Request $ request ) { $ actions = self :: getAllActions ( $ request ) ; foreach ( $ actions as $ actionType ) { if ( empty ( $ action ) ) { $ action = $ actionType ; continue ; } $ posPrevious = self :: getPriority ( $ action ) ; $ posCurrent = self :: getPriority ( $ actionType ) ; if ... | Makes the correct Action object based on the request . |
25,069 | public function record ( Visitor $ visitor , $ idReferrerActionUrl , $ idReferrerActionName ) { $ this -> loadIdsFromLogActionTable ( ) ; $ visitAction = array ( 'idvisit' => $ visitor -> getVisitorColumn ( 'idvisit' ) , 'idsite' => $ this -> request -> getIdSite ( ) , 'idvisitor' => $ visitor -> getVisitorColumn ( 'id... | Records in the DB the association between the visit and this action . |
25,070 | public function setXFrameOptions ( $ option = 'deny' ) { if ( $ option === 'deny' || $ option === 'sameorigin' ) { $ this -> xFrameOptions = $ option ; } if ( $ option == 'allow' ) { $ this -> xFrameOptions = null ; } } | Set X - Frame - Options field in the HTTP response . The header is set just before rendering . |
25,071 | public function addForm ( QuickForm2 $ form ) { $ this -> assign ( 'form_data' , $ form -> getFormData ( ) ) ; $ this -> assign ( 'element_list' , $ form -> getElementList ( ) ) ; } | Add form to view |
25,072 | public function assign ( $ var , $ value = null ) { if ( is_string ( $ var ) ) { $ this -> $ var = $ value ; } elseif ( is_array ( $ var ) ) { foreach ( $ var as $ key => $ value ) { $ this -> $ key = $ value ; } } } | Assign value to a variable for use in a template |
25,073 | public static function clearCompiledTemplates ( ) { $ twig = StaticContainer :: get ( Twig :: class ) ; $ environment = $ twig -> getTwigEnvironment ( ) ; $ environment -> clearTemplateCache ( ) ; $ cacheDirectory = $ environment -> getCache ( ) ; if ( ! empty ( $ cacheDirectory ) && is_dir ( $ cacheDirectory ) ) { $ e... | Clear compiled Twig templates |
25,074 | public static function singleReport ( $ title , $ reportHtml ) { $ view = new View ( '@CoreHome/_singleReport' ) ; $ view -> title = $ title ; $ view -> report = $ reportHtml ; return $ view -> render ( ) ; } | Creates a View for and then renders the single report template . |
25,075 | protected function _getPos ( $ id ) { if ( ! isset ( $ this -> _positions [ $ id - 1 ] ) ) { throw new Zend_Mail_Storage_Exception ( 'id does not exist' ) ; } return $ this -> _positions [ $ id - 1 ] ; } | Get positions for mail message or throw exeption if id is invalid |
25,076 | protected function _isMboxFile ( $ file , $ fileIsString = true ) { if ( $ fileIsString ) { $ file = @ fopen ( $ file , 'r' ) ; if ( ! $ file ) { return false ; } } else { fseek ( $ file , 0 ) ; } $ result = false ; $ line = fgets ( $ file ) ; if ( strpos ( $ line , 'From ' ) === 0 ) { $ result = true ; } if ( $ fileIs... | check if given file is a mbox file |
25,077 | protected function _openMboxFile ( $ filename ) { if ( $ this -> _fh ) { $ this -> close ( ) ; } $ this -> _fh = @ fopen ( $ filename , 'r' ) ; if ( ! $ this -> _fh ) { throw new Zend_Mail_Storage_Exception ( 'cannot open mbox file' ) ; } $ this -> _filename = $ filename ; $ this -> _filemtime = filemtime ( $ this -> _... | open given file as current mbox file |
25,078 | protected function getFrozenHtml ( ) { $ value = $ this -> getAttribute ( 'value' ) ; return ( ( '' != $ value ) ? htmlspecialchars ( $ value , ENT_QUOTES , self :: getOption ( 'charset' ) ) : ' ' ) . $ this -> getPersistentContent ( ) ; } | Returns the field s value without HTML tags |
25,079 | public function getValue ( ) { return $ this -> storage -> getValue ( $ this -> name , $ this -> defaultValue , $ this -> type ) ; } | Returns the previously persisted setting value . If no value was set the default value is returned . |
25,080 | public function setValue ( $ value ) { $ this -> checkHasEnoughWritePermission ( ) ; $ config = $ this -> configureField ( ) ; $ this -> validateValue ( $ value ) ; if ( $ config -> transform && $ config -> transform instanceof \ Closure ) { $ value = call_user_func ( $ config -> transform , $ value , $ this ) ; } if (... | Sets and persists this setting s value overwriting any existing value . |
25,081 | private function _isReserved ( $ host ) { if ( ! preg_match ( '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/' , $ host ) ) { $ host = gethostbyname ( $ host ) ; } $ octet = explode ( '.' , $ host ) ; if ( ( int ) $ octet [ 0 ] >= 224 ) { return true ; } else if ( array_key_exists ( $ octet [ 0 ] , $ this -> _invalidIp ) ) { foreach ... | Returns if the given host is reserved |
25,082 | private function _toIp ( $ binary ) { $ ip = array ( ) ; $ tmp = explode ( "." , chunk_split ( $ binary , 8 , "." ) ) ; for ( $ i = 0 ; $ i < 4 ; $ i ++ ) { $ ip [ $ i ] = bindec ( $ tmp [ $ i ] ) ; } return $ ip ; } | Converts a binary string to an IP address |
25,083 | private function _validateLocalPart ( ) { $ result = false ; $ atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e' ; if ( preg_match ( '/^[' . $ atext . ']+(\x2e+[' . $ atext . ']+)*$/' , $ this -> _localPart ) ) { $ result = true ; } else { $ noWsCtl = '\x01-\x08\x0b\x0c\x0e... | Internal method to validate the local part of the email address |
25,084 | private function _validateMXRecords ( ) { $ mxHosts = array ( ) ; $ result = getmxrr ( $ this -> _hostname , $ mxHosts ) ; if ( ! $ result ) { $ this -> _error ( self :: INVALID_MX_RECORD ) ; } else if ( $ this -> _options [ 'deep' ] && function_exists ( 'checkdnsrr' ) ) { $ validAddress = false ; $ reserved = true ; f... | Internal method to validate the servers MX records |
25,085 | private function _validateHostnamePart ( ) { $ hostname = $ this -> _options [ 'hostname' ] -> setTranslator ( $ this -> getTranslator ( ) ) -> isValid ( $ this -> _hostname ) ; if ( ! $ hostname ) { $ this -> _error ( self :: INVALID_HOSTNAME ) ; foreach ( $ this -> _options [ 'hostname' ] -> getMessages ( ) as $ code... | Internal method to validate the hostname part of the email address |
25,086 | public function addHtml ( $ menuName , $ data , $ displayedForCurrentUser , $ order , $ tooltip ) { if ( $ displayedForCurrentUser ) { if ( ! isset ( $ this -> menu [ $ menuName ] ) ) { $ this -> menu [ $ menuName ] [ '_name' ] = $ menuName ; $ this -> menu [ $ menuName ] [ '_html' ] = $ data ; $ this -> menu [ $ menuN... | Directly adds a menu entry containing html . |
25,087 | public function getMenu ( ) { if ( ! $ this -> menu ) { foreach ( $ this -> getAllMenus ( ) as $ menu ) { $ menu -> configureTopMenu ( $ this ) ; } } return parent :: getMenu ( ) ; } | Triggers the Menu . Top . addItems hook and returns the menu . |
25,088 | public function isLanguageAvailable ( $ languageCode ) { return $ languageCode !== false && Filesystem :: isValidFilename ( $ languageCode ) && in_array ( $ languageCode , $ this -> getAvailableLanguages ( ) ) ; } | Returns true if specified language is available |
25,089 | public function getAvailableLanguages ( ) { if ( ! is_null ( $ this -> languageNames ) ) { return $ this -> languageNames ; } $ path = PIWIK_INCLUDE_PATH . "/lang/" ; $ languagesPath = _glob ( $ path . "*.json" ) ; $ pathLength = strlen ( $ path ) ; $ languages = array ( ) ; if ( $ languagesPath ) { foreach ( $ languag... | Return array of available languages |
25,090 | public function getTranslationsForLanguage ( $ languageCode ) { if ( ! $ this -> isLanguageAvailable ( $ languageCode ) ) { return false ; } $ data = file_get_contents ( PIWIK_INCLUDE_PATH . "/lang/$languageCode.json" ) ; $ translations = json_decode ( $ data , true ) ; $ languageInfo = array ( ) ; foreach ( $ translat... | Returns translation strings by language |
25,091 | public function getPluginTranslationsForLanguage ( $ pluginName , $ languageCode ) { if ( ! $ this -> isLanguageAvailable ( $ languageCode ) ) { return false ; } $ languageFile = Manager :: getPluginDirectory ( $ pluginName ) . "/lang/$languageCode.json" ; if ( ! file_exists ( $ languageFile ) ) { return false ; } $ da... | Returns translation strings by language for given plugin |
25,092 | public function getLanguageForUser ( $ login ) { if ( $ login == 'anonymous' ) { return false ; } Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ login ) ; $ lang = $ this -> getModel ( ) -> getLanguageForUser ( $ login ) ; return $ lang ; } | Returns the language for the user |
25,093 | public static function getAllProviders ( ) { if ( is_null ( self :: $ providers ) ) { self :: $ providers = array ( ) ; $ plugins = PluginManager :: getInstance ( ) -> getPluginsLoadedAndActivated ( ) ; foreach ( $ plugins as $ plugin ) { foreach ( self :: getLocationProviders ( $ plugin ) as $ instance ) { self :: $ p... | Returns every available provider instance . |
25,094 | protected static function getLocationProviders ( Plugin $ plugin ) { $ locationProviders = $ plugin -> findMultipleComponents ( 'LocationProvider' , 'Piwik\\Plugins\\UserCountry\\LocationProvider' ) ; $ instances = [ ] ; foreach ( $ locationProviders as $ locationProvider ) { $ instances [ ] = new $ locationProvider ( ... | Get all lo that are defined by the given plugin . |
25,095 | public static function getAvailableProviders ( ) { $ result = array ( ) ; foreach ( self :: getAllProviders ( ) as $ provider ) { if ( $ provider -> isAvailable ( ) ) { $ result [ ] = $ provider ; } } return $ result ; } | Returns all provider instances that are available . An available provider is one that is available for use . They may not necessarily be working . |
25,096 | public static function getCurrentProviderId ( ) { try { $ optionValue = Option :: get ( self :: CURRENT_PROVIDER_OPTION_NAME ) ; } catch ( \ Exception $ e ) { $ optionValue = false ; } return $ optionValue === false ? DefaultProvider :: ID : $ optionValue ; } | Returns the ID of the currently used location provider . |
25,097 | public static function setCurrentProvider ( $ providerId ) { $ provider = self :: getProviderById ( $ providerId ) ; if ( empty ( $ provider ) ) { throw new Exception ( "Invalid provider ID '$providerId'. The provider either does not exist or is not available" ) ; } $ provider -> activate ( ) ; Option :: set ( self :: ... | Sets the provider to use when tracking . |
25,098 | public static function getProviderById ( $ providerId ) { foreach ( self :: getAllProviders ( ) as $ provider ) { if ( $ provider -> getId ( ) == $ providerId && $ provider -> isAvailable ( ) ) { return $ provider ; } } return null ; } | Returns a provider instance by ID or false if the ID is invalid or unavailable . |
25,099 | public function completeLocationResult ( & $ location ) { if ( empty ( $ location [ self :: CONTINENT_CODE_KEY ] ) && ! empty ( $ location [ self :: COUNTRY_CODE_KEY ] ) ) { $ countryCode = strtolower ( $ location [ self :: COUNTRY_CODE_KEY ] ) ; $ location [ self :: CONTINENT_CODE_KEY ] = Common :: getContinent ( $ co... | Tries to fill in any missing information in a location result . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.