idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
24,500 | private static function getFooterIconFor ( $ viewDataTableId ) { $ tables = static :: getAvailableViewDataTables ( ) ; if ( ! array_key_exists ( $ viewDataTableId , $ tables ) ) { return ; } $ klass = $ tables [ $ viewDataTableId ] ; return array ( 'id' => $ klass :: getViewDataTableId ( ) , 'title' => Piwik :: transla... | Returns an array with information necessary for adding the viewDataTable to the footer . |
24,501 | public function getKnownSegmentsToArchiveForSite ( & $ segments , $ idSite ) { $ model = new Model ( ) ; $ segmentToAutoArchive = $ model -> getSegmentsToAutoArchive ( $ idSite ) ; foreach ( $ segmentToAutoArchive as $ segmentInfo ) { $ segments [ ] = $ segmentInfo [ 'definition' ] ; } $ segments = array_unique ( $ seg... | Adds the pre - processed segments to the list of Segments . Used by CronArchive ArchiveProcessor \ Rules etc . |
24,502 | protected function setIndividualSummaryFooterMessage ( ViewDataTable $ view ) { $ lastGenerated = self :: getDateOfLastCachingRun ( ) ; if ( $ lastGenerated !== false ) { $ view -> config -> show_footer_message = Piwik :: translate ( 'Mobile_LastUpdated' , $ lastGenerated ) ; } } | Sets the footer message for the Individual ... Summary reports . |
24,503 | public static function getProtocolInformation ( ) { if ( isset ( $ _SERVER [ 'SERVER_PORT' ] ) && $ _SERVER [ 'SERVER_PORT' ] == 443 ) { return 'SERVER_PORT=443' ; } if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) && strtolower ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) == 'https' ) { return 'X-Forwarded-Proto' ;... | Get protocol information with the exception of HTTPS |
24,504 | private static function getHeaders ( $ recognizedHeaders ) { $ headers = array ( ) ; foreach ( $ recognizedHeaders as $ header ) { if ( isset ( $ _SERVER [ $ header ] ) ) { $ headers [ ] = $ header ; } } return $ headers ; } | Get headers present in the HTTP request |
24,505 | public function getReferrerType ( $ idSite , $ period , $ date , $ segment = false , $ typeReferrer = false , $ idSubtable = false , $ expanded = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ this -> checkSingleSite ( $ idSite , 'getReferrerType' ) ; if ( $ idSubtable !== false ) { $ result = false ; switc... | Returns a report describing visit information for each possible referrer type . The result is a datatable whose subtables are the reports for each parent row s referrer type . |
24,506 | public function getAll ( $ idSite , $ period , $ date , $ segment = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ this -> checkSingleSite ( $ idSite , 'getAll' ) ; $ dataTable = $ this -> getReferrerType ( $ idSite , $ period , $ date , $ segment , $ typeReferrer = false , $ idSubtable = false , $ expanded... | Returns a report that shows |
24,507 | public function getUrlsForSocial ( $ idSite , $ period , $ date , $ segment = false , $ idSubtable = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ dataTable = $ this -> getDataTable ( Archiver :: SOCIAL_NETWORKS_RECORD_NAME , $ idSite , $ period , $ date , $ segment , $ expanded = true , $ idSubtable ) ; i... | Returns report containing individual referrer URLs for a specific social networking site . |
24,508 | private function removeSubtableMetadata ( $ dataTable ) { if ( $ dataTable instanceof DataTable \ Map ) { foreach ( $ dataTable -> getDataTables ( ) as $ childTable ) { $ this -> removeSubtableMetadata ( $ childTable ) ; } } else { foreach ( $ dataTable -> getRows ( ) as $ row ) { $ row -> deleteMetadata ( 'idsubdatata... | Removes idsubdatatable_in_db metadata from a DataTable . Used by Social tables since they use fake subtable IDs . |
24,509 | private function setSocialIdSubtables ( $ dataTable ) { if ( $ dataTable instanceof DataTable \ Map ) { foreach ( $ dataTable -> getDataTables ( ) as $ childTable ) { $ this -> setSocialIdSubtables ( $ childTable ) ; } } else { foreach ( $ dataTable -> getRows ( ) as $ row ) { $ socialName = $ row -> getColumn ( 'label... | Sets the subtable IDs for the DataTable returned by getSocial . |
24,510 | public static function factory ( $ adapter , $ config = array ( ) ) { if ( $ config instanceof Zend_Config ) { $ config = $ config -> toArray ( ) ; } if ( $ adapter instanceof Zend_Config ) { if ( isset ( $ adapter -> params ) ) { $ config = $ adapter -> params -> toArray ( ) ; } if ( isset ( $ adapter -> adapter ) ) {... | Factory for Zend_Db_Adapter_Abstract classes . |
24,511 | public function getDefinitions ( ) { $ cache = Cache :: getEagerCache ( ) ; $ cacheId = 'SearchEngine-' . self :: OPTION_STORAGE_NAME ; if ( $ cache -> contains ( $ cacheId ) ) { $ list = $ cache -> fetch ( $ cacheId ) ; } else { $ list = $ this -> loadDefinitions ( ) ; $ cache -> save ( $ cacheId , $ list ) ; } return... | Returns list of search engines by URL |
24,512 | public function getNames ( ) { $ cacheId = 'SearchEngine.getSearchEngineNames' ; $ cache = Cache :: getTransientCache ( ) ; $ nameToUrl = $ cache -> fetch ( $ cacheId ) ; if ( empty ( $ nameToUrl ) ) { $ searchEngines = $ this -> getDefinitions ( ) ; $ nameToUrl = array ( ) ; foreach ( $ searchEngines as $ url => $ inf... | Returns list of search engines by name |
24,513 | public function getDefinitionByHost ( $ host ) { $ searchEngines = $ this -> getDefinitions ( ) ; if ( ! array_key_exists ( $ host , $ searchEngines ) ) { return array ( ) ; } return $ searchEngines [ $ host ] ; } | Returns definitions for the given search engine host |
24,514 | protected function convertCharset ( $ string , $ charsets ) { if ( function_exists ( 'iconv' ) && ! empty ( $ charsets ) ) { $ charset = $ charsets [ 0 ] ; if ( count ( $ charsets ) > 1 && function_exists ( 'mb_detect_encoding' ) ) { $ charset = mb_detect_encoding ( $ string , $ charsets ) ; if ( $ charset === false ) ... | Tries to convert the given string from one of the given charsets to UTF - 8 |
24,515 | public function getUrlFromName ( $ name ) { $ searchEngineNames = $ this -> getNames ( ) ; if ( isset ( $ searchEngineNames [ $ name ] ) ) { $ url = 'http://' . $ searchEngineNames [ $ name ] ; } else { $ url = 'URL unknown!' ; } return $ url ; } | Return search engine URL by name |
24,516 | private function getHostFromUrl ( $ url ) { if ( strpos ( $ url , '//' ) ) { $ url = substr ( $ url , strpos ( $ url , '//' ) + 2 ) ; } if ( ( $ p = strpos ( $ url , '/' ) ) !== false ) { $ url = substr ( $ url , 0 , $ p ) ; } return $ url ; } | Return search engine host in URL |
24,517 | public function getLogoFromUrl ( $ url ) { $ pathInPiwik = 'plugins/Morpheus/icons/dist/searchEngines/%s.png' ; $ pathWithCode = sprintf ( $ pathInPiwik , $ this -> getHostFromUrl ( $ url ) ) ; $ absolutePath = PIWIK_INCLUDE_PATH . '/' . $ pathWithCode ; if ( file_exists ( $ absolutePath ) ) { return $ pathWithCode ; }... | Return search engine logo path by URL |
24,518 | public function getBackLinkFromUrlAndKeyword ( $ url , $ keyword ) { if ( $ keyword === API :: LABEL_KEYWORD_NOT_DEFINED ) { return 'https://matomo.org/faq/general/#faq_144' ; } $ keyword = urlencode ( $ keyword ) ; $ keyword = str_replace ( urlencode ( '+' ) , urlencode ( ' ' ) , $ keyword ) ; $ host = substr ( $ url ... | Return search engine URL for URL and keyword |
24,519 | protected function _hmacMd5 ( $ key , $ data , $ block = 64 ) { if ( strlen ( $ key ) > 64 ) { $ key = pack ( 'H32' , md5 ( $ key ) ) ; } elseif ( strlen ( $ key ) < 64 ) { $ key = str_pad ( $ key , $ block , "\0" ) ; } $ k_ipad = substr ( $ key , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ; $ k_opad = substr ( $ key ... | Prepare CRAM - MD5 response to server s ticket |
24,520 | public function noAccess ( Exception $ exception ) { $ frontController = FrontController :: getInstance ( ) ; if ( Common :: isXmlHttpRequest ( ) ) { echo $ frontController -> dispatch ( Piwik :: getLoginPluginName ( ) , 'ajaxNoAccess' , array ( $ exception -> getMessage ( ) ) ) ; return ; } echo $ frontController -> d... | Redirects to Login form with error message . Listens to User . isNotAuthorized hook . |
24,521 | public function ApiRequestAuthenticate ( $ tokenAuth ) { $ this -> beforeLoginCheckBruteForce ( ) ; $ auth = StaticContainer :: get ( 'Piwik\Auth' ) ; $ auth -> setLogin ( $ login = null ) ; $ auth -> setTokenAuth ( $ tokenAuth ) ; } | Set login name and authentication token for API request . Listens to API . Request . authenticate hook . |
24,522 | public function getAllSegmentsAndIgnoreVisibility ( ) { $ sql = "SELECT * FROM " . $ this -> getTable ( ) . " WHERE deleted = 0" ; $ segments = $ this -> getDb ( ) -> fetchAll ( $ sql ) ; return $ segments ; } | Returns all stored segments that haven t been deleted . Ignores the site the segments are enabled for and whether to auto archive or not . |
24,523 | public function getAllSegments ( $ userLogin ) { $ bind = array ( $ userLogin ) ; $ sql = $ this -> buildQuerySortedByName ( 'deleted = 0 AND (enable_all_users = 1 OR login = ?)' ) ; $ segments = $ this -> getDb ( ) -> fetchAll ( $ sql , $ bind ) ; return $ segments ; } | Returns all stored segments that are available to the given login . |
24,524 | public function getAllSegmentsForSite ( $ idSite , $ userLogin ) { $ bind = array ( $ idSite , $ userLogin ) ; $ sql = $ this -> buildQuerySortedByName ( '(enable_only_idsite = ? OR enable_only_idsite = 0) AND deleted = 0 AND (e... | Returns all stored segments that are available for the given site and login . |
24,525 | public function getAllSegmentsForAllUsers ( $ idSite = false ) { $ bind = array ( ) ; $ sqlWhereCondition = '' ; if ( ! empty ( $ idSite ) ) { $ bind = array ( $ idSite ) ; $ sqlWhereCondition = '(enable_only_idsite = ? OR enable_only_idsite = 0) AND' ; } $ sqlWhereCondition = $ this -> buildQuerySortedByName ( $ sqlWh... | This should be used _only_ by Super Users |
24,526 | public function doesIncludePluginTrackersAutomatically ( ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; try { $ updater = StaticContainer :: get ( 'Piwik\Plugins\CustomPiwikJs\TrackerUpdater' ) ; $ updater -> checkWillSucceed ( ) ; return true ; } catch ( AccessDeniedException $ e ) { return false ; } catch ( \ Excepti... | Detects whether plugin trackers will be automatically added to piwik . js or not . If not the plugin tracker files need to be loaded manually . |
24,527 | public static function exitWithErrorMessage ( $ message ) { Common :: sendHeader ( 'Content-Type: text/html; charset=utf-8' ) ; $ message = str_replace ( "\n" , "<br/>" , $ message ) ; $ output = "<html><body>" . "<style>a{color:red;}</style>\n" . "<div style='color:red;font-size:120%; width:100%;margin: 30px;'>" . " <... | Display the message in a nice red font with a nice icon ... and dies |
24,528 | public static function secureDiv ( $ i1 , $ i2 ) { if ( is_numeric ( $ i1 ) && is_numeric ( $ i2 ) && floatval ( $ i2 ) != 0 ) { return $ i1 / $ i2 ; } return 0 ; } | Computes the division of i1 by i2 . If either i1 or i2 are not number or if i2 has a value of zero we return 0 to avoid the division by zero . |
24,529 | public static function getRandomTitle ( ) { static $ titles = array ( 'Web analytics' , 'Open analytics platform' , 'Real Time Web Analytics' , 'Analytics' , 'Real Time Analytics' , 'Analytics in Real time' , 'Analytics Platform' , 'Data Platform' , ) ; $ id = abs ( intval ( md5 ( Url :: getCurrentHost ( ) ) ) ) ; $ ti... | Generate a title for image tags |
24,530 | public static function getAllSuperUserAccessEmailAddresses ( ) { $ emails = array ( ) ; try { $ superUsers = APIUsersManager :: getInstance ( ) -> getUsersHavingSuperUserAccess ( ) ; } catch ( \ Exception $ e ) { return $ emails ; } foreach ( $ superUsers as $ superUser ) { $ emails [ $ superUser [ 'login' ] ] = $ supe... | Get a list of all email addresses having Super User access . |
24,531 | public static function checkUserHasSuperUserAccessOrIsTheUser ( $ theUser ) { try { if ( Piwik :: getCurrentUserLogin ( ) !== $ theUser ) { Piwik :: checkUserHasSuperUserAccess ( ) ; } } catch ( NoAccessException $ e ) { throw new NoAccessException ( Piwik :: translate ( 'General_ExceptionCheckUserHasSuperUserAccessOrI... | Check that the current user is either the specified user or the superuser . |
24,532 | public static function hasTheUserSuperUserAccess ( $ theUser ) { if ( empty ( $ theUser ) ) { return false ; } if ( Piwik :: getCurrentUserLogin ( ) === $ theUser && Piwik :: hasUserSuperUserAccess ( ) ) { return true ; } try { $ superUsers = APIUsersManager :: getInstance ( ) -> getUsersHavingSuperUserAccess ( ) ; } c... | Check whether the given user has superuser access . |
24,533 | public static function isUserHasCapability ( $ idSites , $ capability ) { try { self :: checkUserHasCapability ( $ idSites , $ capability ) ; return true ; } catch ( Exception $ e ) { return false ; } } | Returns true if the current user has the given capability for the given sites . |
24,534 | public static function redirectToModule ( $ newModule , $ newAction = '' , $ parameters = array ( ) ) { $ newUrl = 'index.php' . Url :: getCurrentQueryStringWithParametersModified ( array ( 'module' => $ newModule , 'action' => $ newAction ) + $ parameters ) ; Url :: redirectToUrl ( $ newUrl ) ; } | Redirects the current request to a new module and action . |
24,535 | public static function checkObjectTypeIs ( $ o , $ types ) { foreach ( $ types as $ type ) { if ( $ o instanceof $ type ) { return ; } } $ oType = is_object ( $ o ) ? get_class ( $ o ) : gettype ( $ o ) ; throw new Exception ( "Invalid variable type '$oType', expected one of following: " . implode ( ', ' , $ types ) ) ... | Utility function that checks if an object type is in a set of types . |
24,536 | public static function isAssociativeArray ( $ array ) { reset ( $ array ) ; if ( ! is_numeric ( key ( $ array ) ) || key ( $ array ) != 0 ) { return true ; } while ( true ) { $ current = key ( $ array ) ; next ( $ array ) ; $ next = key ( $ array ) ; if ( $ next === null ) { break ; } elseif ( $ current + 1 != $ next )... | Returns true if an array is an associative array false if otherwise . |
24,537 | public static function getUnnamespacedClassName ( $ object ) { $ className = is_string ( $ object ) ? $ object : get_class ( $ object ) ; $ parts = explode ( '\\' , $ className ) ; return end ( $ parts ) ; } | Returns the class name of an object without its namespace . |
24,538 | public static function postEvent ( $ eventName , $ params = array ( ) , $ pending = false , $ plugins = null ) { EventDispatcher :: getInstance ( ) -> postEvent ( $ eventName , $ params , $ pending , $ plugins ) ; } | Post an event to Piwik s event dispatcher which will execute the event s observers . |
24,539 | public static function translate ( $ translationId , $ args = array ( ) , $ language = null ) { $ translator = StaticContainer :: get ( 'Piwik\Translation\Translator' ) ; return $ translator -> translate ( $ translationId , $ args , $ language ) ; } | Returns an internationalized string using a translation token . If a translation cannot be found for the token the token is returned . |
24,540 | public function isExcluded ( ) { $ excluded = false ; if ( $ this -> isNonHumanBot ( ) ) { Common :: printDebug ( 'Search bot detected, visit excluded' ) ; $ excluded = true ; } if ( ! $ excluded ) { $ toRecord = $ this -> request -> getParam ( $ parameterForceRecord = 'rec' ) ; if ( ! $ toRecord ) { Common :: printDeb... | Test if the current visitor is excluded from the statistics . |
24,541 | protected function isVisitorIpExcluded ( ) { $ excludedIps = $ this -> getAttributes ( 'excluded_ips' , 'global_excluded_ips' ) ; if ( ! empty ( $ excludedIps ) ) { $ ip = IP :: fromBinaryIP ( $ this -> ip ) ; if ( $ ip -> isInRanges ( $ excludedIps ) ) { Common :: printDebug ( 'Visitor IP ' . $ ip -> toString ( ) . ' ... | Checks if the visitor ip is in the excluded list |
24,542 | protected function isUrlExcluded ( ) { $ excludedUrls = $ this -> getAttributes ( 'exclude_unknown_urls' , null ) ; $ siteUrls = $ this -> getAttributes ( 'urls' , null ) ; if ( ! empty ( $ excludedUrls ) && ! empty ( $ siteUrls ) ) { $ url = $ this -> request -> getParam ( 'url' ) ; $ parsedUrl = parse_url ( $ url ) ;... | Checks if request URL is excluded |
24,543 | protected function isUserAgentExcluded ( ) { $ excludedAgents = $ this -> getAttributes ( 'excluded_user_agents' , 'global_excluded_user_agents' ) ; if ( ! empty ( $ excludedAgents ) ) { foreach ( $ excludedAgents as $ excludedUserAgent ) { if ( stripos ( $ this -> userAgent , $ excludedUserAgent ) !== false ) { return... | Returns true if the specified user agent should be excluded for the current site or not . |
24,544 | public function deleteGoalConversions ( $ idSite , $ idGoal ) { $ table = Common :: prefixTable ( "log_conversion" ) ; Db :: deleteAllRows ( $ table , "WHERE idgoal = ? AND idsite = ?" , "idvisit" , 100000 , array ( $ idGoal , $ idSite ) ) ; } | actually this should be in a log_conversion model |
24,545 | private static function getAdapterClassName ( $ adapterName ) { $ className = 'Piwik\Db\Adapter\\' . str_replace ( ' ' , '\\' , ucwords ( str_replace ( array ( '_' , '\\' ) , ' ' , strtolower ( $ adapterName ) ) ) ) ; if ( ! class_exists ( $ className ) ) { throw new \ Exception ( sprintf ( "Adapter '%s' is not valid. ... | Get adapter class name |
24,546 | public static function getAdapters ( ) { static $ adapterNames = array ( 'Pdo\Mysql' , 'Mysqli' , ) ; $ adapters = array ( ) ; foreach ( $ adapterNames as $ adapterName ) { $ className = '\Piwik\Db\Adapter\\' . $ adapterName ; if ( call_user_func ( array ( $ className , 'isEnabled' ) ) ) { $ adapters [ strtoupper ( $ a... | Get list of adapters |
24,547 | public function getValue ( $ key , $ defaultValue , $ type ) { $ this -> loadSettingsIfNotDoneYet ( ) ; if ( array_key_exists ( $ key , $ this -> settingsValues ) ) { settype ( $ this -> settingsValues [ $ key ] , $ type ) ; return $ this -> settingsValues [ $ key ] ; } return $ defaultValue ; } | Returns the current value for a setting . If no value is stored the default value is be returned . |
24,548 | public function render ( HTML_QuickForm2_Renderer $ renderer ) { $ renderer -> startGroup ( $ this ) ; foreach ( $ this as $ element ) { $ element -> render ( $ renderer ) ; } $ renderer -> finishGroup ( $ this ) ; return $ renderer ; } | Renders the group using the given renderer |
24,549 | public function urlForDefaultUserParams ( $ websiteId = false , $ defaultPeriod = false , $ defaultDate = false ) { $ userPreferences = new UserPreferences ( ) ; if ( empty ( $ websiteId ) ) { $ websiteId = $ userPreferences -> getDefaultWebsiteId ( ) ; } if ( empty ( $ websiteId ) ) { throw new \ Exception ( "A websit... | Returns the &idSite = X&period = Y&date = Z query string fragment fetched from current logged - in user s preferences . |
24,550 | public static function factory ( $ pluginName , $ componentClassSimpleName , $ componentTypeClass ) { if ( empty ( $ pluginName ) || empty ( $ componentClassSimpleName ) ) { Log :: debug ( "ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)" , __FUNCTION__ , $ pluginName , $ componentCl... | Create a component instance that exists within a specific plugin . Uses the component s unqualified class name and expected base type . |
24,551 | public static function getComponentIf ( $ componentTypeClass , $ pluginName , $ predicate ) { $ pluginManager = PluginManager :: getInstance ( ) ; $ subnamespace = $ componentTypeClass :: COMPONENT_SUBNAMESPACE ; if ( empty ( $ pluginName ) ) { $ components = $ pluginManager -> findMultipleComponents ( $ subnamespace ,... | Finds a component instance that satisfies a given predicate . |
24,552 | public function callAggregateAllPlugins ( $ visits , $ visitsConverted , $ forceArchivingWithoutVisits = false ) { Log :: debug ( "PluginsArchiver::%s: Initializing archiving process for all plugins [visits = %s, visits converted = %s]" , __FUNCTION__ , $ visits , $ visitsConverted ) ; $ performanceLogger = StaticConta... | Instantiates the Archiver class in each plugin that defines it and triggers Aggregation processing on these plugins . |
24,553 | public static function doesAnyPluginArchiveWithoutVisits ( ) { $ archivers = static :: getPluginArchivers ( ) ; foreach ( $ archivers as $ pluginName => $ archiverClass ) { if ( $ archiverClass :: shouldRunEvenWhenNoVisits ( ) ) { return true ; } } return false ; } | Returns if any plugin archiver archives without visits |
24,554 | protected static function getPluginArchivers ( ) { if ( empty ( static :: $ archivers ) ) { $ pluginNames = \ Piwik \ Plugin \ Manager :: getInstance ( ) -> getActivatedPlugins ( ) ; $ archivers = array ( ) ; foreach ( $ pluginNames as $ pluginName ) { $ archivers [ $ pluginName ] = self :: getPluginArchiverClass ( $ p... | Loads Archiver class from any plugin that defines one . |
24,555 | protected function shouldProcessReportsForPlugin ( $ pluginName ) { if ( $ this -> params -> getRequestedPlugin ( ) == $ pluginName ) { return true ; } if ( $ this -> params -> shouldOnlyArchiveRequestedPlugin ( ) ) { return false ; } if ( Rules :: shouldProcessReportsAllPlugins ( $ this -> params -> getIdSites ( ) , $... | Whether the specified plugin s reports should be archived |
24,556 | public function addValidator ( Zend_Validate_Interface $ validator , $ breakChainOnFailure = false ) { $ this -> _validators [ ] = array ( 'instance' => $ validator , 'breakChainOnFailure' => ( boolean ) $ breakChainOnFailure ) ; return $ this ; } | Adds a validator to the end of the chain |
24,557 | public function setDayOfWeek ( $ _day , $ _week ) { if ( ! ( $ _day >= 0 && $ _day < 7 ) ) { throw new Exception ( "Invalid day of week parameter, must be >= 0 & < 7" ) ; } if ( ! ( $ _week >= 0 && $ _week < 4 ) ) { throw new Exception ( "Invalid week number, must be >= 1 & < 4" ) ; } $ this -> dayOfWeek = $ _day ; $ t... | Makes this scheduled time execute on a particular day of the week on each month . |
24,558 | public function getPrimaryColumnToSort ( DataTable $ table , $ columnToSort ) { $ columnsToCheck = array ( $ columnToSort , 'nb_visits' ) ; $ row = $ table -> getFirstRow ( ) ; foreach ( $ columnsToCheck as $ column ) { $ column = Metric :: getActualMetricColumn ( $ table , $ column ) ; if ( $ row -> hasColumn ( $ colu... | Detect the column to be used for sorting |
24,559 | public function getSecondaryColumnToSort ( Row $ row , $ primaryColumnToSort ) { $ defaultSecondaryColumn = array ( Metrics :: INDEX_NB_VISITS , 'nb_visits' ) ; if ( in_array ( $ primaryColumnToSort , $ defaultSecondaryColumn ) ) { $ column = 'label' ; $ value = $ row -> hasColumn ( $ column ) ; if ( $ value !== false ... | Detect the secondary sort column to be used for sorting |
24,560 | public function addWord ( $ word , $ value = 1 ) { if ( isset ( $ this -> wordsArray [ $ word ] ) ) { $ this -> wordsArray [ $ word ] += $ value ; } else { $ this -> wordsArray [ $ word ] = $ value ; } } | Assign word to array |
24,561 | protected function shuffleCloud ( ) { if ( self :: $ debugDisableShuffle ) { return ; } $ keys = array_keys ( $ this -> wordsArray ) ; shuffle ( $ keys ) ; if ( count ( $ keys ) && is_array ( $ keys ) ) { $ tmpArray = $ this -> wordsArray ; $ this -> wordsArray = array ( ) ; foreach ( $ keys as $ value ) { $ this -> wo... | Shuffle associated names in array |
24,562 | protected function getClassFromPercent ( $ percent ) { $ mapping = array ( 95 , 70 , 50 , 30 , 15 , 5 , 0 ) ; foreach ( $ mapping as $ key => $ value ) { if ( $ percent >= $ value ) { return $ key ; } } return 0 ; } | Get the class range using a percentage |
24,563 | public function generateMessage ( $ EOL = Zend_Mime :: LINEEND ) { if ( ! $ this -> isMultiPart ( ) ) { $ body = array_shift ( $ this -> _parts ) ; $ body = $ body -> getContent ( $ EOL ) ; } else { $ mime = $ this -> getMime ( ) ; $ boundaryLine = $ mime -> boundaryLine ( $ EOL ) ; $ body = 'This is a message in Mime ... | Generate MIME - compliant message from the current configuration |
24,564 | public function getPartHeaders ( $ partnum , $ EOL = Zend_Mime :: LINEEND ) { return $ this -> _parts [ $ partnum ] -> getHeaders ( $ EOL ) ; } | Get the headers of a given part as a string |
24,565 | public static function createFromMessage ( $ message , $ boundary , $ EOL = Zend_Mime :: LINEEND ) { $ parts = Zend_Mime_Decode :: splitMessageStruct ( $ message , $ boundary , $ EOL ) ; $ res = new self ( ) ; foreach ( $ parts as $ part ) { $ newPart = new Zend_Mime_Part ( $ part [ 'body' ] ) ; foreach ( $ part [ 'hea... | Decodes a MIME encoded string and returns a Zend_Mime_Message object with all the MIME parts set according to the given string |
24,566 | public function getPromoUrlForProfessionalServices ( $ campaignMedium , $ campaignContent = '' ) { $ url = 'https://matomo.org/support/?' ; $ campaign = $ this -> getCampaignParametersForPromoUrl ( $ name = self :: CAMPAIGN_NAME_PROFESSIONAL_SERVICES , $ campaignMedium , $ campaignContent ) ; return $ url . $ campaign ... | Get URL for promoting Professional Services for Piwik |
24,567 | public function addPromoCampaignParametersToUrl ( $ url , $ campaignName , $ campaignMedium , $ campaignContent = '' ) { if ( empty ( $ url ) ) { return '' ; } if ( strpos ( $ url , '?' ) === false ) { $ url .= '?' ; } else { $ url .= '&' ; } $ url .= $ this -> getCampaignParametersForPromoUrl ( $ campaignName , $ camp... | Appends campaign parameters to the given URL for promoting any Professional Support for Piwik service . |
24,568 | private function getCampaignParametersForPromoUrl ( $ campaignName , $ campaignMedium , $ campaignContent = '' ) { $ campaignName = sprintf ( 'pk_campaign=%s&pk_medium=%s&pk_source=Piwik_App' , $ campaignName , $ campaignMedium ) ; if ( ! empty ( $ campaignContent ) ) { $ campaignName .= '&pk_content=' . $ campaignCont... | Generates campaign URL parameters that can be used with promoting Professional Support service . |
24,569 | public function getEncodedStream ( ) { if ( ! $ this -> _isStream ) { throw new Zend_Mime_Exception ( 'Attempt to get a stream from a string part' ) ; } switch ( $ this -> encoding ) { case Zend_Mime :: ENCODING_QUOTEDPRINTABLE : $ filter = stream_filter_append ( $ this -> _content , 'convert.quoted-printable-encode' ,... | if this was created with a stream return a filtered stream for reading the content . very useful for large file attachments . |
24,570 | public function getContent ( $ EOL = Zend_Mime :: LINEEND ) { if ( $ this -> _isStream ) { return stream_get_contents ( $ this -> getEncodedStream ( ) ) ; } else { return Zend_Mime :: encode ( $ this -> _content , $ this -> encoding , $ EOL ) ; } } | Get the Content of the current Mime Part in the given encoding . |
24,571 | public function getHeadersArray ( $ EOL = Zend_Mime :: LINEEND ) { $ headers = array ( ) ; $ contentType = $ this -> type ; if ( $ this -> charset ) { $ contentType .= '; charset=' . $ this -> charset ; } if ( $ this -> boundary ) { $ contentType .= ';' . $ EOL . " boundary=\"" . $ this -> boundary . '"' ; } $ headers ... | Create and return the array of headers for this MIME part |
24,572 | public function getHeaders ( $ EOL = Zend_Mime :: LINEEND ) { $ res = '' ; foreach ( $ this -> getHeadersArray ( $ EOL ) as $ header ) { $ res .= $ header [ 0 ] . ': ' . $ header [ 1 ] . $ EOL ; } return $ res ; } | Return the headers for this part as a string |
24,573 | public static function mkdir ( $ path ) { if ( ! is_dir ( $ path ) ) { @ mkdir ( $ path , self :: getChmodForPath ( $ path ) , $ recursive = true ) ; } if ( ! is_writable ( $ path ) ) { @ chmod ( $ path , 0755 ) ; if ( ! is_writable ( $ path ) ) { @ chmod ( $ path , 0775 ) ; } } self :: createIndexFilesToPreventDirecto... | Attempts to create a new directory . All errors are silenced . |
24,574 | public static function checkIfFileSystemIsNFS ( ) { $ sessionsPath = Session :: getSessionsDirectory ( ) ; $ command = "df -T -t nfs \"$sessionsPath\" 2>&1" ; if ( function_exists ( 'exec' ) ) { $ output = $ returnCode = null ; @ exec ( $ command , $ output , $ returnCode ) ; if ( $ returnCode == 0 && count ( $ output ... | Checks if the filesystem Piwik stores sessions in is NFS or not . This check is done in order to avoid using file based sessions on NFS system since on such a filesystem file locking can make file based sessions incredibly slow . |
24,575 | public static function globr ( $ sDir , $ sPattern , $ nFlags = null ) { if ( ( $ aFiles = \ _glob ( "$sDir/$sPattern" , $ nFlags ) ) == false ) { $ aFiles = array ( ) ; } if ( ( $ aDirs = \ _glob ( "$sDir/*" , GLOB_ONLYDIR ) ) != false ) { foreach ( $ aDirs as $ sSubDir ) { if ( is_link ( $ sSubDir ) ) { continue ; } ... | Recursively find pathnames that match a pattern . |
24,576 | public static function unlinkRecursive ( $ dir , $ deleteRootToo , \ Closure $ beforeUnlink = null ) { if ( ! $ dh = @ opendir ( $ dir ) ) { return ; } while ( false !== ( $ obj = readdir ( $ dh ) ) ) { if ( $ obj == '.' || $ obj == '..' ) { continue ; } $ path = $ dir . '/' . $ obj ; if ( $ beforeUnlink ) { $ beforeUn... | Recursively deletes a directory . |
24,577 | public static function unlinkTargetFilesNotPresentInSource ( $ source , $ target ) { $ diff = self :: directoryDiff ( $ source , $ target ) ; $ diff = self :: sortFilesDescByPathLength ( $ diff ) ; foreach ( $ diff as $ file ) { $ remove = $ target . $ file ; if ( is_dir ( $ remove ) ) { @ rmdir ( $ remove ) ; } else {... | Removes all files and directories that are present in the target directory but are not in the source directory . |
24,578 | public static function getFileSize ( $ pathToFile , $ unit = 'B' ) { $ unit = strtoupper ( $ unit ) ; $ units = array ( 'TB' => pow ( 1024 , 4 ) , 'GB' => pow ( 1024 , 3 ) , 'MB' => pow ( 1024 , 2 ) , 'KB' => 1024 , 'B' => 1 ) ; if ( ! array_key_exists ( $ unit , $ units ) ) { throw new \ Exception ( 'Invalid unit give... | Get the size of a file in the specified unit . |
24,579 | public function dispatch ( $ module = null , $ action = null , $ parameters = null ) { if ( self :: $ enableDispatch === false ) { return ; } $ filter = new Router ( ) ; $ redirection = $ filter -> filterUrl ( Url :: getCurrentUrl ( ) ) ; if ( $ redirection !== null ) { Url :: redirectToUrl ( $ redirection ) ; return ;... | Executes the requested plugin controller method . |
24,580 | public function fetchDispatch ( $ module = null , $ actionName = null , $ parameters = null ) { ob_start ( ) ; $ output = $ this -> dispatch ( $ module , $ actionName , $ parameters ) ; if ( empty ( $ output ) ) { $ output = ob_get_contents ( ) ; } else { ob_flush ( ) ; } ob_end_clean ( ) ; return $ output ; } | Executes the requested plugin controller method and returns the data capturing anything the method echo s . |
24,581 | private function throwIfPiwikVersionIsOlderThanDBSchema ( ) { if ( Development :: isEnabled ( ) ) { return ; } if ( ! StaticContainer :: get ( 'EnableDbVersionCheck' ) ) { return ; } $ updater = new Updater ( ) ; $ dbSchemaVersion = $ updater -> getCurrentComponentVersion ( 'core' ) ; $ current = Version :: VERSION ; i... | This method ensures that Piwik Platform cannot be running when using a NEWER database . |
24,582 | public function mergeDataTables ( $ table1 , $ table2 ) { if ( $ table1 instanceof DataTable \ Map && $ table2 instanceof DataTable \ Map ) { $ subTables2 = $ table2 -> getDataTables ( ) ; foreach ( $ table1 -> getDataTables ( ) as $ index => $ subTable1 ) { if ( ! array_key_exists ( $ index , $ subTables2 ) ) { contin... | Merge the columns of two data tables . Manipulates the first table . |
24,583 | public static function initMaildir ( $ dir ) { if ( file_exists ( $ dir ) ) { if ( ! is_dir ( $ dir ) ) { throw new Zend_Mail_Storage_Exception ( 'maildir must be a directory if already exists' ) ; } } else { if ( ! mkdir ( $ dir ) ) { $ dir = dirname ( $ dir ) ; if ( ! file_exists ( $ dir ) ) { throw new Zend_Mail_Sto... | create a new maildir |
24,584 | protected function _createUniqueId ( ) { $ id = '' ; $ id .= function_exists ( 'microtime' ) ? microtime ( true ) : ( time ( ) . ' ' . rand ( 0 , 100000 ) ) ; $ id .= '.' . ( function_exists ( 'posix_getpid' ) ? posix_getpid ( ) : rand ( 50 , 65535 ) ) ; $ id .= '.' . php_uname ( 'n' ) ; return $ id ; } | create a uniqueid for maildir filename |
24,585 | protected function _createTmpFile ( $ folder = 'INBOX' ) { if ( $ folder == 'INBOX' ) { $ tmpdir = $ this -> _rootdir . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR ; } else { $ tmpdir = $ this -> _rootdir . '.' . $ folder . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR ; } if ( ! file_exists ( $ tmpdir ) ) { ... | open a temporary maildir file |
24,586 | protected function _getInfoString ( & $ flags ) { $ wanted_flags = array_flip ( $ flags ) ; if ( isset ( $ wanted_flags [ Zend_Mail_Storage :: FLAG_RECENT ] ) ) { throw new Zend_Mail_Storage_Exception ( 'recent flag may not be set' ) ; } $ info = ':2,' ; $ flags = array ( ) ; foreach ( Zend_Mail_Storage_Maildir :: $ _k... | create an info string for filenames with given flags |
24,587 | public function copyMessage ( $ id , $ folder ) { if ( $ this -> _quota && $ this -> checkQuota ( ) ) { throw new Zend_Mail_Storage_Exception ( 'storage is over quota!' ) ; } if ( ! ( $ folder instanceof Zend_Mail_Storage_Folder ) ) { $ folder = $ this -> getFolders ( $ folder ) ; } $ filedata = $ this -> _getFileData ... | copy an existing message |
24,588 | public function setFlags ( $ id , $ flags ) { $ info = $ this -> _getInfoString ( $ flags ) ; $ filedata = $ this -> _getFileData ( $ id ) ; $ new_filename = dirname ( dirname ( $ filedata [ 'filename' ] ) ) . DIRECTORY_SEPARATOR . 'cur' . DIRECTORY_SEPARATOR . "$filedata[uniq]$info" ; if ( ! @ rename ( $ filedata [ 'f... | set flags for message |
24,589 | public function removeMessage ( $ id ) { $ filename = $ this -> _getFileData ( $ id , 'filename' ) ; if ( $ this -> _quota ) { $ size = filesize ( $ filename ) ; } if ( ! @ unlink ( $ filename ) ) { throw new Zend_Mail_Storage_Exception ( 'cannot remove message' ) ; } unset ( $ this -> _files [ $ id - 1 ] ) ; $ this ->... | stub for not supported message deletion |
24,590 | public function getQuota ( $ fromStorage = false ) { if ( $ fromStorage ) { $ fh = @ fopen ( $ this -> _rootdir . 'maildirsize' , 'r' ) ; if ( ! $ fh ) { throw new Zend_Mail_Storage_Exception ( 'cannot open maildirsize' ) ; } $ definition = fgets ( $ fh ) ; fclose ( $ fh ) ; $ definition = explode ( ',' , trim ( $ defi... | get currently set quota |
24,591 | public function checkQuota ( $ detailedResponse = false , $ forceRecalc = false ) { $ result = $ this -> _calculateQuota ( $ forceRecalc ) ; return $ detailedResponse ? $ result : $ result [ 'over_quota' ] ; } | check if storage is currently over quota |
24,592 | public function beforeRender ( ) { $ this -> config -> show_as_content_block = false ; $ this -> config -> title = Piwik :: translate ( 'Live_VisitorLog' ) ; $ this -> config -> disable_row_actions = true ; $ this -> config -> datatable_js_type = 'VisitorLog' ; $ this -> config -> enable_sort = false ; $ this -> config... | Configure visualization . |
24,593 | public function getLanguagesSelector ( ) { $ view = new View ( "@LanguagesManager/getLanguagesSelector" ) ; $ view -> languages = API :: getInstance ( ) -> getAvailableLanguageNames ( ) ; $ view -> currentLanguageCode = self :: getLanguageCodeForCurrentUser ( ) ; $ view -> currentLanguageName = self :: getLanguageNameF... | Renders and returns the language selector HTML . |
24,594 | public static function getLanguageForSession ( ) { $ cookieName = Config :: getInstance ( ) -> General [ 'language_cookie_name' ] ; $ cookie = new Cookie ( $ cookieName ) ; if ( $ cookie -> isCookieFound ( ) ) { return $ cookie -> get ( 'language' ) ; } return null ; } | Returns the language for the session |
24,595 | public static function setLanguageForSession ( $ languageCode ) { if ( ! API :: getInstance ( ) -> isLanguageAvailable ( $ languageCode ) ) { return false ; } $ cookieName = Config :: getInstance ( ) -> General [ 'language_cookie_name' ] ; $ cookie = new Cookie ( $ cookieName , 0 ) ; $ cookie -> set ( 'language' , $ la... | Set the language for the session |
24,596 | public static function anonymizeUserId ( $ userId ) { $ trackerCache = Tracker \ Cache :: getCacheGeneral ( ) ; $ salt = '' ; if ( ! empty ( $ trackerCache [ PrivacyManager :: OPTION_USERID_SALT ] ) ) { $ salt = $ trackerCache [ PrivacyManager :: OPTION_USERID_SALT ] ; } if ( empty ( $ salt ) ) { return $ userId ; } re... | pseudo anonymization as we need to make sure to always generate the same UserId for the same original UserID |
24,597 | private function getAvailableCommands ( ) { $ commands = $ this -> getDefaultPiwikCommands ( ) ; $ detected = PluginManager :: getInstance ( ) -> findMultipleComponents ( 'Commands' , 'Piwik\\Plugin\\ConsoleCommand' ) ; $ commands = array_merge ( $ commands , $ detected ) ; Piwik :: postEvent ( 'Console.filterCommands'... | Returns a list of available command classnames . |
24,598 | public static function getAllPluginColumns ( ) { $ cacheId = CacheId :: pluginAware ( 'DevicePluginColumns' ) ; $ cache = Cache :: getTransientCache ( ) ; if ( ! $ cache -> contains ( $ cacheId ) ) { $ instances = [ ] ; foreach ( self :: getAllDevicePluginsColumnClasses ( ) as $ className ) { $ instance = new $ classNa... | Returns all available DevicePlugins Columns |
24,599 | protected function detectReferrerSearchEngine ( ) { $ cache = \ Piwik \ Cache :: getTransientCache ( ) ; $ cacheKey = 'cachedReferrerSearchEngine' ; $ cachedReferrerSearchEngine = [ ] ; if ( $ cache -> contains ( $ cacheKey ) ) { $ cachedReferrerSearchEngine = $ cache -> fetch ( $ cacheKey ) ; } if ( isset ( $ cachedRe... | Search engine detection |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.