idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
24,900 | public function getDimensions ( ) { $ dimensions = [ ] ; if ( ! empty ( $ this -> getDimension ( ) ) ) { $ dimensionId = str_replace ( '.' , '_' , $ this -> getDimension ( ) -> getId ( ) ) ; $ dimensions [ $ dimensionId ] = $ this -> getDimension ( ) -> getName ( ) ; } if ( ! empty ( $ this -> getSubtableDimension ( ) ... | Get dimensions used for current report and its subreports |
24,901 | public function getSubtableDimension ( ) { if ( empty ( $ this -> actionToLoadSubTables ) ) { return null ; } list ( $ subtableReportModule , $ subtableReportAction ) = $ this -> getSubtableApiMethod ( ) ; $ subtableReport = ReportsProvider :: factory ( $ subtableReportModule , $ subtableReportAction ) ; if ( empty ( $... | Returns the Dimension instance of this report s subtable report . |
24,902 | public function getThirdLeveltableDimension ( ) { if ( empty ( $ this -> actionToLoadSubTables ) ) { return null ; } list ( $ subtableReportModule , $ subtableReportAction ) = $ this -> getSubtableApiMethod ( ) ; $ subtableReport = ReportsProvider :: factory ( $ subtableReportModule , $ subtableReportAction ) ; if ( em... | Returns the Dimension instance of the subtable report of this report s subtable report . |
24,903 | public function fetchSubtable ( $ idSubtable , $ paramOverride = array ( ) ) { $ paramOverride = array ( 'idSubtable' => $ idSubtable ) + $ paramOverride ; list ( $ module , $ action ) = $ this -> getSubtableApiMethod ( ) ; return Request :: processRequest ( $ module . '.' . $ action , $ paramOverride ) ; } | Fetches a subtable for the report represented by this instance . |
24,904 | public static function getForDimension ( Dimension $ dimension ) { $ provider = new ReportsProvider ( ) ; $ reports = $ provider -> getAllReports ( ) ; foreach ( $ reports as $ report ) { if ( ! $ report -> isSubtableReport ( ) && $ report -> getDimension ( ) && $ report -> getDimension ( ) -> getId ( ) == $ dimension ... | Finds a top level report that provides stats for a specific Dimension . |
24,905 | public function getProcessedMetricsById ( ) { $ processedMetrics = $ this -> processedMetrics ? : array ( ) ; $ result = array ( ) ; foreach ( $ processedMetrics as $ processedMetric ) { if ( $ processedMetric instanceof ProcessedMetric || $ processedMetric instanceof ArchivedMetric ) { $ result [ $ processedMetric -> ... | Returns an array mapping the ProcessedMetrics served by this report by their string names . |
24,906 | public static function getMetricsForTable ( DataTable $ dataTable , Report $ report = null , $ baseType = 'Piwik\\Plugin\\Metric' ) { $ metrics = $ dataTable -> getMetadata ( DataTable :: EXTRA_PROCESSED_METRICS_METADATA_NAME ) ? : array ( ) ; if ( ! empty ( $ report ) ) { $ metrics = array_merge ( $ metrics , $ report... | Returns the Metrics that are displayed by a DataTable of a certain Report type . |
24,907 | public static function getProcessedMetricsForTable ( DataTable $ dataTable , Report $ report = null ) { $ metrics = self :: getMetricsForTable ( $ dataTable , $ report , 'Piwik\\Plugin\\ProcessedMetric' ) ; $ result = [ ] ; self :: processedMetricDfs ( $ metrics , function ( $ metricName ) use ( & $ result , $ metrics ... | Returns the ProcessedMetrics that should be computed and formatted for a DataTable of a certain report . The ProcessedMetrics returned are those specified by the Report metadata as well as the DataTable metadata . |
24,908 | public function getTranslations ( $ lang ) { $ path = $ this -> getTranslationPathBaseDirectory ( 'lang' , $ lang ) ; if ( ! is_readable ( $ path ) ) { return array ( ) ; } $ data = file_get_contents ( $ path ) ; $ translations = json_decode ( $ data , true ) ; return $ translations ; } | Get translations from file |
24,909 | protected function getTranslationPathBaseDirectory ( $ base , $ lang = null ) { if ( empty ( $ lang ) ) { $ lang = $ this -> getLanguage ( ) ; } if ( ! empty ( $ this -> pluginName ) ) { if ( $ base == 'tmp' ) { return sprintf ( '%s/plugins/%s/lang/%s.json' , StaticContainer :: get ( 'path.tmp' ) , $ this -> pluginName... | Get translation file path based on given params |
24,910 | public function save ( ) { $ this -> applyFilters ( ) ; if ( ! $ this -> hasTranslations ( ) || ! $ this -> isValid ( ) ) { throw new Exception ( 'unable to save empty or invalid translations' ) ; } $ path = $ this -> getTranslationPath ( ) ; Filesystem :: mkdir ( dirname ( $ path ) ) ; return file_put_contents ( $ pat... | Save translations to file ; translations should already be cleaned . |
24,911 | public function saveTemporary ( ) { $ this -> applyFilters ( ) ; if ( ! $ this -> hasTranslations ( ) || ! $ this -> isValid ( ) ) { throw new Exception ( 'unable to save empty or invalid translations' ) ; } $ path = $ this -> getTemporaryTranslationPath ( ) ; Filesystem :: mkdir ( dirname ( $ path ) ) ; return file_pu... | Save translations to temporary file ; translations should already be cleansed . |
24,912 | public function isValid ( ) { $ this -> applyFilters ( ) ; $ this -> validationMessage = null ; foreach ( $ this -> validators as $ validator ) { if ( ! $ validator -> isValid ( $ this -> translations ) ) { $ this -> validationMessage = $ validator -> getMessage ( ) ; return false ; } } return true ; } | Returns if translations are valid to save or not |
24,913 | public function getLocation ( $ info ) { $ ip = $ this -> getIpFromInfo ( $ info ) ; $ result = array ( ) ; if ( self :: isCityDatabaseAvailable ( ) ) { $ location = @ geoip_record_by_name ( $ ip ) ; if ( ! empty ( $ location ) ) { $ result [ self :: COUNTRY_CODE_KEY ] = $ location [ 'country_code' ] ; $ result [ self ... | Uses the GeoIP PECL module to get a visitor s location based on their IP address . |
24,914 | public function isWorking ( ) { if ( ! self :: isLocationDatabaseAvailable ( ) ) { $ dbDir = dirname ( geoip_db_filename ( GEOIP_COUNTRY_EDITION ) ) . '/' ; $ quotedDir = "'$dbDir'" ; if ( ! is_dir ( $ dbDir ) ) { return Piwik :: translate ( 'UserCountry_PeclGeoIPNoDBDir' , array ( $ quotedDir , "'geoip.custom_director... | Returns true if the PECL module that is installed can be successfully used to get the location of an IP address . |
24,915 | public function setTable ( Zend_Db_Table_Abstract $ table = null ) { if ( $ table == null ) { $ this -> _table = null ; $ this -> _connected = false ; return false ; } $ tableClass = get_class ( $ table ) ; if ( ! $ table instanceof $ this -> _tableClass ) { throw new Zend_Db_Table_Row_Exception ( "The specified Table ... | Set the table object to re - establish a live connection to the database for a Row that has been de - serialized . |
24,916 | public function setFromArray ( array $ data ) { $ data = array_intersect_key ( $ data , $ this -> _data ) ; foreach ( $ data as $ columnName => $ value ) { $ this -> __set ( $ columnName , $ value ) ; } return $ this ; } | Sets all data in the row from an array . |
24,917 | protected function _refresh ( ) { $ where = $ this -> _getWhereQuery ( ) ; $ row = $ this -> _getTable ( ) -> fetchRow ( $ where ) ; if ( null === $ row ) { throw new Zend_Db_Table_Row_Exception ( 'Cannot refresh row as parent is missing' ) ; } $ this -> _data = $ row -> toArray ( ) ; $ this -> _cleanData = $ this -> _... | Refreshes properties from the database . |
24,918 | protected function _prepareReference ( Zend_Db_Table_Abstract $ dependentTable , Zend_Db_Table_Abstract $ parentTable , $ ruleKey ) { $ parentTableName = ( get_class ( $ parentTable ) === 'Zend_Db_Table' ) ? $ parentTable -> getDefinitionConfigName ( ) : get_class ( $ parentTable ) ; $ map = $ dependentTable -> getRefe... | Prepares a table reference for lookup . |
24,919 | public function findDependentRowset ( $ dependentTable , $ ruleKey = null , Zend_Db_Table_Select $ select = null ) { $ db = $ this -> _getTable ( ) -> getAdapter ( ) ; if ( is_string ( $ dependentTable ) ) { $ dependentTable = $ this -> _getTableFromString ( $ dependentTable ) ; } if ( ! $ dependentTable instanceof Zen... | Query a dependent table to retrieve rows matching the current row . |
24,920 | public function getPrettyString ( ) { $ out = $ this -> translator -> translate ( 'General_DateRangeFromTo' , array ( $ this -> getDateStart ( ) -> toString ( ) , $ this -> getDateEnd ( ) -> toString ( ) ) ) ; return $ out ; } | Returns the current period as a string . |
24,921 | protected function generate ( ) { if ( $ this -> subperiodsProcessed ) { return ; } $ this -> loadAllFromCache ( ) ; if ( $ this -> subperiodsProcessed ) { return ; } parent :: generate ( ) ; if ( preg_match ( '/(last|previous)([0-9]*)/' , $ this -> strDate , $ regs ) ) { $ lastN = $ regs [ 2 ] ; $ lastOrPrevious = $ r... | Generates the subperiods |
24,922 | public static function parseDateRange ( $ dateString ) { $ matched = preg_match ( '/^([0-9]{4}-[0-9]{1,2}-[0-9]{1,2}),(([0-9]{4}-[0-9]{1,2}-[0-9]{1,2})|today|now|yesterday)$/D' , trim ( $ dateString ) , $ regs ) ; if ( empty ( $ matched ) ) { return false ; } return $ regs ; } | Given a date string returns false if not a date range or returns the array containing start and end dates . |
24,923 | protected function fillArraySubPeriods ( $ startDate , $ endDate , $ period ) { $ arrayPeriods = array ( ) ; $ endSubperiod = Period \ Factory :: build ( $ period , $ endDate ) ; $ arrayPeriods [ ] = $ endSubperiod ; $ endDate = $ endSubperiod -> getDateStart ( ) ; while ( $ endDate -> isLater ( $ startDate ) ) { $ end... | Adds new subperiods |
24,924 | public static function getDateXPeriodsAgo ( $ subXPeriods , $ date = false , $ period = false ) { if ( $ date === false ) { $ date = Common :: getRequestVar ( 'date' ) ; } if ( $ period === false ) { $ period = Common :: getRequestVar ( 'period' ) ; } if ( 365 == $ subXPeriods && 'day' == $ period && Date :: today ( ) ... | Returns the date that is X periods before the supplied date . |
24,925 | public static function getRelativeToEndDate ( $ period , $ lastN , $ endDate , $ site ) { $ timezone = $ site -> getTimezone ( ) ; $ last30Relative = new Range ( $ period , $ lastN , $ timezone ) ; if ( strpos ( $ endDate , '-' ) === false ) { $ endDate = Date :: factoryInTimezone ( $ endDate , $ timezone ) ; } else { ... | Returns a date range string given a period type end date and number of periods the range spans over . |
24,926 | public function getRangeString ( ) { $ dateStart = $ this -> getDateStart ( ) ; $ dateEnd = $ this -> getDateEnd ( ) ; return $ dateStart -> toString ( "Y-m-d" ) . "," . $ dateEnd -> toString ( "Y-m-d" ) ; } | Returns the date range string comprising two dates |
24,927 | public function setMessages ( array $ messages ) { foreach ( $ messages as $ key => $ message ) { $ this -> setMessage ( $ message , $ key ) ; } return $ this ; } | Sets validation failure message templates given as an array where the array keys are the message keys and the array values are the message template strings . |
24,928 | public function getTranslator ( ) { if ( $ this -> translatorIsDisabled ( ) ) { return null ; } if ( null === $ this -> _translator ) { return self :: getDefaultTranslator ( ) ; } return $ this -> _translator ; } | Return translation object |
24,929 | protected static function parseAttributes ( $ attrString ) { $ attributes = array ( ) ; if ( preg_match_all ( "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/" , $ attrString , $ regs ) ) { for ( $ i = 0 ; $ i < count ( $ regs ... | Parses the HTML attributes given as string |
24,930 | protected static function prepareAttributes ( $ attributes ) { $ prepared = array ( ) ; if ( is_string ( $ attributes ) ) { return self :: parseAttributes ( $ attributes ) ; } elseif ( is_array ( $ attributes ) ) { foreach ( $ attributes as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key = strtolower ( $ value ) ;... | Creates a valid attribute array from either a string or an array |
24,931 | protected static function getAttributesString ( $ attributes ) { $ str = '' ; if ( is_array ( $ attributes ) ) { $ charset = self :: getOption ( 'charset' ) ; foreach ( $ attributes as $ key => $ value ) { $ str .= ' ' . $ key . '="' . htmlspecialchars ( $ value , ENT_QUOTES , $ charset ) . '"' ; } } return $ str ; } | Creates HTML attribute string from array |
24,932 | public function setAttribute ( $ name , $ value = null ) { $ name = strtolower ( $ name ) ; if ( is_null ( $ value ) ) { $ value = $ name ; } if ( in_array ( $ name , $ this -> watchedAttributes ) ) { $ this -> onAttributeChange ( $ name , $ value ) ; } else { $ this -> attributes [ $ name ] = ( string ) $ value ; } re... | Sets the value of the attribute |
24,933 | public function setAttributes ( $ attributes ) { $ attributes = self :: prepareAttributes ( $ attributes ) ; $ watched = array ( ) ; foreach ( $ this -> watchedAttributes as $ watchedKey ) { if ( isset ( $ attributes [ $ watchedKey ] ) ) { $ this -> setAttribute ( $ watchedKey , $ attributes [ $ watchedKey ] ) ; unset ... | Sets the attributes |
24,934 | public function getAttributes ( $ asString = false ) { if ( $ asString ) { return self :: getAttributesString ( $ this -> attributes ) ; } else { return $ this -> attributes ; } } | Returns the attribute array or string |
24,935 | public function mergeAttributes ( $ attributes ) { $ attributes = self :: prepareAttributes ( $ attributes ) ; foreach ( $ this -> watchedAttributes as $ watchedKey ) { if ( isset ( $ attributes [ $ watchedKey ] ) ) { $ this -> onAttributeChange ( $ watchedKey , $ attributes [ $ watchedKey ] ) ; unset ( $ attributes [ ... | Merges the existing attributes with the new ones |
24,936 | public function setIndentLevel ( $ level ) { $ level = intval ( $ level ) ; if ( 0 <= $ level ) { $ this -> _indentLevel = $ level ; } return $ this ; } | Sets the indentation level |
24,937 | protected function makeSetting ( $ name , $ defaultValue , $ type , $ fieldConfigCallback ) { $ setting = new SystemSetting ( $ name , $ defaultValue , $ type , $ this -> pluginName ) ; $ setting -> setConfigureCallback ( $ fieldConfigCallback ) ; $ this -> addSetting ( $ setting ) ; return $ setting ; } | Creates a new system setting . |
24,938 | protected function makeSettingManagedInConfigOnly ( $ configSectionName , $ name , $ defaultValue , $ type , $ fieldConfigCallback ) { $ setting = new SystemConfigSetting ( $ name , $ defaultValue , $ type , $ this -> pluginName , $ configSectionName ) ; $ setting -> setConfigureCallback ( $ fieldConfigCallback ) ; $ t... | This is only meant for some core features used by some core plugins that are shipped with Piwik |
24,939 | public function handle ( ) { $ this -> checkSiteExists ( $ this -> request ) ; foreach ( $ this -> requestProcessors as $ processor ) { Common :: printDebug ( "Executing " . get_class ( $ processor ) . "::manipulateRequest()..." ) ; $ processor -> manipulateRequest ( $ this -> request ) ; } $ this -> visitProperties = ... | Main algorithm to handle the visit . |
24,940 | protected function getVisitorIdcookie ( ) { $ isKnown = $ this -> request -> getMetadata ( 'CoreHome' , 'isVisitorKnown' ) ; if ( $ isKnown ) { return $ this -> visitProperties -> getProperty ( 'idvisitor' ) ; } $ idVisitor = $ this -> visitProperties -> getProperty ( 'idvisitor' ) ; if ( ! empty ( $ idVisitor ) && Tra... | Returns visitor cookie |
24,941 | public static function isHostKnownAliasHost ( $ urlHost , $ idSite ) { $ websiteData = Cache :: getCacheWebsiteAttributes ( $ idSite ) ; if ( isset ( $ websiteData [ 'hosts' ] ) ) { $ canonicalHosts = array ( ) ; foreach ( $ websiteData [ 'hosts' ] as $ host ) { $ canonicalHosts [ ] = self :: toCanonicalHost ( $ host )... | is the host any of the registered URLs for this website? |
24,942 | private function getExistingVisitFieldsToUpdate ( $ visitIsConverted ) { $ valuesToUpdate = array ( ) ; $ valuesToUpdate = $ this -> setIdVisitorForExistingVisit ( $ valuesToUpdate ) ; $ dimensions = $ this -> getAllVisitDimensions ( ) ; $ valuesToUpdate = $ this -> triggerHookOnDimensions ( $ dimensions , 'onExistingV... | Gather fields = > values that needs to be updated for the existing visit in log_visit |
24,943 | public function sendToBrowserDownload ( $ filename ) { ReportRenderer :: sendToBrowser ( $ filename , ReportRenderer :: CSV_FORMAT , "text/" . ReportRenderer :: CSV_FORMAT , $ this -> getRenderedReport ( ) ) ; } | Send rendering to browser with a download file prompt |
24,944 | public function sendToBrowserInline ( $ filename ) { ReportRenderer :: sendToBrowser ( $ filename , ReportRenderer :: CSV_FORMAT , "application/" . ReportRenderer :: CSV_FORMAT , $ this -> getRenderedReport ( ) ) ; } | Output rendering to browser |
24,945 | public function renderReport ( $ processedReport ) { $ csvRenderer = $ this -> getRenderer ( $ processedReport [ 'reportData' ] , $ processedReport [ 'metadata' ] [ 'uniqueId' ] ) ; $ reportData = $ csvRenderer -> render ( $ processedReport ) ; if ( empty ( $ reportData ) ) { $ reportData = Piwik :: translate ( 'CoreHo... | Render the provided report . Multiple calls to this method before calling outputRendering appends each report content . |
24,946 | public static function getCountriesForContinent ( $ continent ) { $ regionDataProvider = StaticContainer :: get ( 'Piwik\Intl\Data\Provider\RegionDataProvider' ) ; $ result = array ( ) ; $ continent = strtolower ( $ continent ) ; foreach ( $ regionDataProvider -> getCountryList ( ) as $ countryCode => $ continentCode )... | Returns a list of country codes for a given continent code . |
24,947 | public function isGeoIPWorking ( ) { $ provider = LocationProvider :: getCurrentProvider ( ) ; return $ provider instanceof GeoIp && $ provider -> isAvailable ( ) === true && $ provider -> isWorking ( ) === true ; } | Returns true if a GeoIP provider is installed & working false if otherwise . |
24,948 | public function getMenu ( ) { if ( ! $ this -> menu ) { foreach ( $ this -> getAllMenus ( ) as $ menu ) { $ menu -> configureAdminMenu ( $ this ) ; } } return parent :: getMenu ( ) ; } | Triggers the Menu . MenuAdmin . addItems hook and returns the admin menu . |
24,949 | public function filterUsers ( $ users ) { if ( $ this -> access -> hasSuperUserAccess ( ) ) { return $ users ; } if ( ! $ this -> access -> isUserHasSomeAdminAccess ( ) ) { foreach ( $ users as $ user ) { if ( $ this -> isOwnLogin ( $ user [ 'login' ] ) ) { return array ( $ user ) ; } } return array ( ) ; } foreach ( $... | Removes all users from the list of the given users where the current user has no permission to see the existence of that other user . |
24,950 | public function filterLogins ( $ logins ) { if ( $ this -> access -> hasSuperUserAccess ( ) ) { return $ logins ; } if ( ! $ this -> access -> isUserHasSomeAdminAccess ( ) ) { foreach ( $ logins as $ login ) { if ( $ this -> isOwnLogin ( $ login ) ) { return array ( $ login ) ; } } return array ( ) ; } foreach ( $ logi... | Removes all logins from the list of logins where the current user has no permission to see them . |
24,951 | public function getCounters ( $ idSite , $ lastMinutes , $ segment = false , $ showColumns = array ( ) , $ hideColumns = array ( ) ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ model = new Model ( ) ; if ( is_string ( $ showColumns ) ) { $ showColumns = explode ( ',' , $ showColumns ) ; } if ( is_string ( $ hide... | This will return simple counters for a given website ID for visits over the last N minutes |
24,952 | public function getMostRecentVisitorId ( $ idSite , $ segment = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ minTimestamp = Date :: now ( ) -> subDay ( 7 ) -> getTimestamp ( ) ; $ dataTable = $ this -> loadLastVisitsDetailsFromDatabase ( $ idSite , $ period = false , $ date = false , $ segment , $ offset ... | Returns the visitor ID of the most recent visit . |
24,953 | public function getFirstVisitForVisitorId ( $ idSite , $ visitorId ) { Piwik :: checkUserHasSomeViewAccess ( ) ; if ( empty ( $ visitorId ) ) { return new DataTable ( ) ; } $ model = new Model ( ) ; $ data = $ model -> queryLogVisits ( $ idSite , false , false , false , 0 , 1 , $ visitorId , false , 'ASC' ) ; $ dataTab... | Returns the very first visit for the given visitorId |
24,954 | private function addFilterToCleanVisitors ( DataTable $ dataTable , $ idSite , $ flat = false , $ doNotFetchActions = false , $ filterNow = false ) { $ filter = 'queueFilter' ; if ( $ filterNow ) { $ filter = 'filter' ; } $ dataTable -> $ filter ( function ( $ table ) use ( $ idSite , $ flat , $ doNotFetchActions ) { $... | For an array of visits query the list of pages for this visit as well as make the data human readable |
24,955 | public function getMenu ( ) { $ this -> buildMenu ( ) ; $ this -> applyEdits ( ) ; $ this -> applyRemoves ( ) ; $ this -> applyRenames ( ) ; $ this -> applyOrdering ( ) ; return $ this -> menu ; } | Builds the menu applies edits renames and orders the entries . |
24,956 | protected function getAllMenus ( ) { if ( ! empty ( self :: $ menus ) ) { return self :: $ menus ; } $ components = PluginManager :: getInstance ( ) -> findComponents ( 'Menu' , 'Piwik\\Plugin\\Menu' ) ; self :: $ menus = array ( ) ; foreach ( $ components as $ component ) { self :: $ menus [ ] = StaticContainer :: get... | Returns a list of available plugin menu instances . |
24,957 | public function addItem ( $ menuName , $ subMenuName , $ url , $ order = 50 , $ tooltip = false , $ icon = false , $ onclick = false ) { if ( isset ( $ url [ 'idSite' ] ) && ! is_numeric ( $ url [ 'idSite' ] ) ) { $ idSites = API :: getInstance ( ) -> getSitesIdWithAtLeastViewAccess ( ) ; $ url [ 'idSite' ] = reset ( $... | Adds a new entry to the menu . |
24,958 | private function buildMenuItem ( $ menuName , $ subMenuName , $ url , $ order = 50 , $ tooltip = false , $ icon = false , $ onclick = false ) { if ( ! isset ( $ this -> menu [ $ menuName ] ) ) { $ this -> menu [ $ menuName ] = array ( '_hasSubmenu' => false , '_order' => $ order ) ; } if ( empty ( $ subMenuName ) ) { $... | Builds a single menu item |
24,959 | public function rename ( $ mainMenuOriginal , $ subMenuOriginal , $ mainMenuRenamed , $ subMenuRenamed ) { $ this -> renames [ ] = array ( $ mainMenuOriginal , $ subMenuOriginal , $ mainMenuRenamed , $ subMenuRenamed ) ; } | Renames a single menu entry . |
24,960 | private function applyEdits ( ) { foreach ( $ this -> edits as $ edit ) { $ mainMenuToEdit = $ edit [ 0 ] ; $ subMenuToEdit = $ edit [ 1 ] ; $ newUrl = $ edit [ 2 ] ; if ( $ subMenuToEdit === null ) { if ( isset ( $ this -> menu [ $ mainMenuToEdit ] ) ) { $ menuDataToEdit = & $ this -> menu [ $ mainMenuToEdit ] ; } els... | Applies all edits to the menu . |
24,961 | private function applyRenames ( ) { foreach ( $ this -> renames as $ rename ) { $ mainMenuOriginal = $ rename [ 0 ] ; $ subMenuOriginal = $ rename [ 1 ] ; $ mainMenuRenamed = $ rename [ 2 ] ; $ subMenuRenamed = $ rename [ 3 ] ; if ( ! empty ( $ subMenuOriginal ) ) { if ( isset ( $ this -> menu [ $ mainMenuOriginal ] [ ... | Applies renames to the menu . |
24,962 | private function applyOrdering ( ) { if ( empty ( $ this -> menu ) || $ this -> orderingApplied ) { return ; } uasort ( $ this -> menu , array ( $ this , 'menuCompare' ) ) ; foreach ( $ this -> menu as $ key => & $ element ) { if ( is_null ( $ element ) ) { unset ( $ this -> menu [ $ key ] ) ; } elseif ( $ element [ '_... | Orders the menu according to their order . |
24,963 | protected function menuCompare ( $ itemOne , $ itemTwo ) { if ( ! is_array ( $ itemOne ) && ! is_array ( $ itemTwo ) ) { return 0 ; } if ( ! is_array ( $ itemOne ) && is_array ( $ itemTwo ) ) { return - 1 ; } if ( is_array ( $ itemOne ) && ! is_array ( $ itemTwo ) ) { return 1 ; } if ( ! isset ( $ itemOne [ '_order' ] ... | Compares two menu entries . Used for ordering . |
24,964 | private function convertOldDistributedList ( & $ yearMonths ) { foreach ( $ yearMonths as $ key => $ value ) { if ( preg_match ( "/^[0-9]{4}_[0-9]{2}$/" , $ key ) ) { unset ( $ yearMonths [ $ key ] ) ; $ yearMonths [ ] = $ key ; } } } | Before 2 . 12 . 0 Piwik stored this list as an array mapping year months to arrays of site IDs . If this is found in the DB we convert the array to an array of year months to avoid errors and to make sure the correct tables are still purged . |
24,965 | public function auth ( ) { parent :: auth ( ) ; $ this -> _send ( 'AUTH PLAIN' ) ; $ this -> _expect ( 334 ) ; $ this -> _send ( base64_encode ( "\0" . $ this -> _username . "\0" . $ this -> _password ) ) ; $ this -> _expect ( 235 ) ; $ this -> _auth = true ; } | Perform PLAIN authentication with supplied credentials |
24,966 | public function getAvailableMeasurableTypes ( ) { Piwik :: checkUserHasSomeViewAccess ( ) ; $ typeManager = new TypeManager ( ) ; $ types = $ typeManager -> getAllTypes ( ) ; $ available = array ( ) ; foreach ( $ types as $ type ) { $ measurableSettings = $ this -> settingsProvider -> getAllMeasurableSettings ( $ idSit... | Returns all available measurable types . Marked as deprecated so it won t appear in API page . It won t be a public API for now . |
24,967 | public function getReportPagesMetadata ( $ idSite ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ widgetsList = WidgetsList :: get ( ) ; $ categoryList = CategoryList :: get ( ) ; $ metadata = new WidgetMetadata ( ) ; return $ metadata -> getPagesMetadata ( $ categoryList , $ widgetsList ) ; } | Get a list of all pages that shall be shown in a Matomo UI including a list of all widgets that shall be shown within each page . |
24,968 | public function getWidgetMetadata ( $ idSite ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ widgetsList = WidgetsList :: get ( ) ; $ categoryList = CategoryList :: get ( ) ; $ metadata = new WidgetMetadata ( ) ; return $ metadata -> getWidgetMetadata ( $ categoryList , $ widgetsList ) ; } | Get a list of all widgetizable widgets . |
24,969 | public function getBulkRequest ( $ urls ) { if ( empty ( $ urls ) ) { return array ( ) ; } $ urls = array_map ( 'urldecode' , $ urls ) ; $ urls = array_map ( array ( 'Piwik\Common' , 'unsanitizeInputValue' ) , $ urls ) ; $ result = array ( ) ; foreach ( $ urls as $ url ) { $ params = Request :: getRequestArrayFromStrin... | Performs multiple API requests at once and returns every result . |
24,970 | public function isPluginActivated ( $ pluginName ) { Piwik :: checkUserHasSomeViewAccess ( ) ; return \ Piwik \ Plugin \ Manager :: getInstance ( ) -> isPluginActivated ( $ pluginName ) ; } | Return true if plugin is activated false otherwise |
24,971 | public function getSuggestedValuesForSegment ( $ segmentName , $ idSite ) { if ( empty ( Config :: getInstance ( ) -> General [ 'enable_segment_suggested_values' ] ) ) { return array ( ) ; } Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ maxSuggestionsToReturn = 30 ; $ segment = $ this -> findSegment ( $ segmentName ... | Given a segment will return a list of the most used values for this particular segment . |
24,972 | public function flatRender ( $ dataTable = null ) { if ( is_null ( $ dataTable ) ) { $ dataTable = $ this -> table ; } if ( is_array ( $ dataTable ) ) { $ flatArray = $ dataTable ; if ( self :: shouldWrapArrayBeforeRendering ( $ flatArray ) ) { $ flatArray = array ( $ flatArray ) ; } } elseif ( $ dataTable instanceof D... | Produces a flat php array from the DataTable putting columns and metadata on the same level . |
24,973 | public function originalRender ( ) { Piwik :: checkObjectTypeIs ( $ this -> table , array ( 'Simple' , 'DataTable' ) ) ; if ( $ this -> table instanceof Simple ) { $ array = $ this -> renderSimpleTable ( $ this -> table ) ; } elseif ( $ this -> table instanceof DataTable ) { $ array = $ this -> renderTable ( $ this -> ... | Converts the current data table to an array |
24,974 | protected function renderTable ( $ table ) { $ array = array ( ) ; foreach ( $ table -> getRows ( ) as $ id => $ row ) { $ newRow = array ( 'columns' => $ row -> getColumns ( ) , 'metadata' => $ row -> getMetadata ( ) , 'idsubdatatable' => $ row -> getIdSubDataTable ( ) , ) ; if ( $ id == DataTable :: ID_SUMMARY_ROW ) ... | Converts the given data table to an array |
24,975 | protected function renderSimpleTable ( $ table ) { $ array = array ( ) ; $ row = $ table -> getFirstRow ( ) ; if ( $ row === false ) { return $ array ; } foreach ( $ row -> getColumns ( ) as $ columnName => $ columnValue ) { $ array [ $ columnName ] = $ columnValue ; } return $ array ; } | Converts the simple data table to an array |
24,976 | public function setGlobalSettings ( ) { $ response = new ResponseBuilder ( Common :: getRequestVar ( 'format' ) ) ; try { $ this -> checkTokenInUrl ( ) ; $ timezone = Common :: getRequestVar ( 'timezone' , false ) ; $ excludedIps = Common :: getRequestVar ( 'excludedIps' , false ) ; $ excludedQueryParameters = Common :... | Records Global settings when user submit changes |
24,977 | function downloadPiwikTracker ( ) { $ path = PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/' ; $ filename = 'PiwikTracker.php' ; Common :: sendHeader ( 'Content-type: text/php' ) ; Common :: sendHeader ( 'Content-Disposition: attachment; filename="' . $ filename . '"' ) ; return file_get_contents ( $ path . $ filename ) ; } | User will download a file called PiwikTracker . php that is the content of the actual script |
24,978 | public function getCurrentComponentVersion ( $ name ) { try { $ currentVersion = Option :: get ( self :: getNameInOptionTable ( $ name ) ) ; } catch ( \ Exception $ e ) { if ( Db :: get ( ) -> isErrNo ( $ e , '1146' ) ) { $ currentVersion = false ; } else { throw $ e ; } } return $ currentVersion ; } | Returns the currently installed version of a Piwik component . |
24,979 | public function getSqlQueriesToExecute ( ) { $ queries = array ( ) ; $ classNames = array ( ) ; foreach ( $ this -> componentsWithUpdateFile as $ componentName => $ componentUpdateInfo ) { foreach ( $ componentUpdateInfo as $ file => $ fileVersion ) { require_once $ file ; $ className = $ this -> getUpdateClassName ( $... | Returns the list of SQL queries that would be executed during the update |
24,980 | public function update ( $ componentName ) { $ warningMessages = array ( ) ; $ this -> executeListenerHook ( 'onComponentUpdateStarting' , array ( $ componentName ) ) ; foreach ( $ this -> componentsWithUpdateFile [ $ componentName ] as $ file => $ fileVersion ) { try { require_once $ file ; $ className = $ this -> get... | Update the named component |
24,981 | private function loadComponentsWithUpdateFile ( ) { $ componentsWithUpdateFile = array ( ) ; foreach ( $ this -> componentsWithNewVersion as $ name => $ versions ) { $ currentVersion = $ versions [ self :: INDEX_CURRENT_VERSION ] ; $ newVersion = $ versions [ self :: INDEX_NEW_VERSION ] ; if ( $ name == 'core' ) { $ pa... | Construct list of update files for the outdated components |
24,982 | public function getComponentsWithNewVersion ( $ componentsToCheck ) { $ componentsToUpdate = array ( ) ; if ( isset ( $ componentsToCheck [ 'core' ] ) ) { $ coreVersions = $ componentsToCheck [ 'core' ] ; unset ( $ componentsToCheck [ 'core' ] ) ; $ componentsToCheck = array_merge ( array ( 'core' => $ coreVersions ) ,... | Construct list of outdated components |
24,983 | public function updateComponents ( $ componentsWithUpdateFile ) { $ warnings = array ( ) ; $ errors = array ( ) ; $ deactivatedPlugins = array ( ) ; $ coreError = false ; if ( ! empty ( $ componentsWithUpdateFile ) ) { $ currentAccess = Access :: getInstance ( ) ; $ hasSuperUserAccess = $ currentAccess -> hasSuperUserA... | Updates multiple components while capturing & returning errors and warnings . |
24,984 | public function getComponentUpdates ( ) { $ componentsToCheck = array ( 'core' => Version :: VERSION ) ; $ manager = \ Piwik \ Plugin \ Manager :: getInstance ( ) ; $ plugins = $ manager -> getLoadedPlugins ( ) ; foreach ( $ plugins as $ pluginName => $ plugin ) { if ( $ manager -> isPluginInstalled ( $ pluginName ) ) ... | Returns any updates that should occur for core and all plugins that are both loaded and installed . Also includes updates required for dimensions . |
24,985 | public function executeMigrations ( $ file , $ migrations ) { foreach ( $ migrations as $ index => $ migration ) { $ migration = $ this -> keepBcForOldMigrationQueryFormat ( $ index , $ migration ) ; $ this -> executeMigration ( $ file , $ migration ) ; } } | Execute multiple migration queries from a single Update file . |
24,986 | public function addSetting ( Setting $ setting ) { $ name = $ setting -> getName ( ) ; if ( isset ( $ this -> settings [ $ name ] ) ) { throw new \ Exception ( sprintf ( 'A setting with name "%s" does already exist for plugin "%s"' , $ name , $ this -> pluginName ) ) ; } $ this -> settings [ $ name ] = $ setting ; } | Adds a new setting to the settings container . |
24,987 | protected function getDateParameterInTimezone ( $ date , $ timezone ) { $ timezoneToUse = null ; if ( in_array ( $ date , array ( 'today' , 'yesterday' ) ) ) { if ( $ date == 'today' ) { $ date = 'now' ; } elseif ( $ date == 'yesterday' ) { $ date = 'yesterdaySameTime' ; } $ timezoneToUse = $ timezone ; } return Date :... | Helper method that converts today or yesterday to the specified timezone . If the date is absolute ie . YYYY - MM - DD it will not be converted to the timezone . |
24,988 | protected function setDate ( Date $ date ) { $ this -> date = $ date ; $ this -> strDate = $ date -> toString ( ) ; } | Sets the date to be used by all other methods in the controller . If the date has to be modified this method should be called just after construction . |
24,989 | protected function renderReport ( $ apiAction , $ controllerAction = false ) { if ( empty ( $ controllerAction ) && is_string ( $ apiAction ) ) { $ report = ReportsProvider :: factory ( $ this -> pluginName , $ apiAction ) ; if ( ! empty ( $ report ) ) { $ apiAction = $ report ; } } if ( $ apiAction instanceof Report )... | Convenience method that creates and renders a ViewDataTable for a API method . |
24,990 | protected function setMinDateView ( Date $ minDate , $ view ) { $ view -> minDateYear = $ minDate -> toString ( 'Y' ) ; $ view -> minDateMonth = $ minDate -> toString ( 'm' ) ; $ view -> minDateDay = $ minDate -> toString ( 'd' ) ; } | Sets the first date available in the period selector s calendar . |
24,991 | protected function setBasicVariablesNoneAdminView ( $ view ) { $ view -> clientSideConfig = PiwikConfig :: getInstance ( ) -> getClientSideOptions ( ) ; $ view -> isSuperUser = Access :: getInstance ( ) -> hasSuperUserAccess ( ) ; $ view -> hasSomeAdminAccess = Piwik :: isUserHasSomeAdminAccess ( ) ; $ view -> hasSomeV... | Needed when a controller extends ControllerAdmin but you don t want to call the controller admin basic variables view . Solves a problem when a controller has regular controller and admin controller views . |
24,992 | protected function checkTokenInUrl ( ) { $ tokenRequest = Common :: getRequestVar ( 'token_auth' , false ) ; $ tokenUser = Piwik :: getCurrentUserTokenAuth ( ) ; if ( empty ( $ tokenRequest ) && empty ( $ tokenUser ) ) { return ; } if ( $ tokenRequest !== $ tokenUser ) { throw new NoAccessException ( Piwik :: translate... | Checks that the token_auth in the URL matches the currently logged - in user s token_auth . |
24,993 | public static function getPrettyDate ( $ date , $ period ) { return self :: getCalendarPrettyDate ( Period \ Factory :: build ( $ period , Date :: factory ( $ date ) ) ) ; } | Returns the pretty date representation |
24,994 | protected function getDividend ( $ row ) { $ currentValue = $ row -> getColumn ( $ this -> columnValueToRead ) ; if ( $ currentValue === false && $ this -> isRevenueEvolution && ! Site :: isEcommerceEnabledFor ( $ row -> getColumn ( 'label' ) ) ) { return false ; } $ pastRow = $ this -> getPastRowFromCurrent ( $ row ) ... | Returns the difference between the column in the specific row and its sister column in the past DataTable . |
24,995 | protected function formatValue ( $ value , $ divisor ) { $ value = self :: getPercentageValue ( $ value , $ divisor , $ this -> quotientPrecision ) ; $ value = self :: appendPercentSign ( $ value ) ; $ value = Common :: forceDotAsSeparatorForDecimalPoint ( $ value ) ; return $ value ; } | Calculates and formats a quotient based on a divisor and dividend . |
24,996 | public static function calculate ( $ currentValue , $ pastValue , $ quotientPrecision = 0 , $ appendPercentSign = true ) { $ number = self :: getPercentageValue ( $ currentValue - $ pastValue , $ pastValue , $ quotientPrecision ) ; if ( $ appendPercentSign ) { return NumberFormatter :: getInstance ( ) -> formatPercent ... | Calculates the evolution percentage for two arbitrary values . |
24,997 | private static function getPercentageValue ( $ value , $ divisor , $ quotientPrecision ) { if ( $ value == 0 ) { $ evolution = 0 ; } elseif ( $ divisor == 0 ) { $ evolution = 100 ; } else { $ evolution = ( $ value / $ divisor ) * 100 ; } $ evolution = round ( $ evolution , $ quotientPrecision ) ; return $ evolution ; } | Returns an evolution percent based on a value & divisor . |
24,998 | public function setConfig ( $ config ) { if ( ! is_array ( $ config ) || ! isset ( $ config [ 'callback' ] ) ) { $ config = array ( 'callback' => $ config ) ; } if ( ! is_callable ( $ config [ 'callback' ] , false , $ callbackName ) ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'Callback Rule requires a vali... | Sets the callback to use for validation and its additional arguments |
24,999 | public function isAvailable ( ) { if ( function_exists ( 'apache_get_modules' ) ) { foreach ( apache_get_modules ( ) as $ name ) { if ( strpos ( $ name , 'geoip' ) !== false ) { return true ; } } } $ available = ! empty ( $ _SERVER [ self :: TEST_SERVER_VAR ] ) || ! empty ( $ _SERVER [ self :: TEST_SERVER_VAR_ALT ] ) |... | Checks if an HTTP server module has been installed . It checks by looking for the GEOIP_ADDR server variable . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.