idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
24,600
protected function detectReferrerSocialNetwork ( ) { $ cache = \ Piwik \ Cache :: getTransientCache ( ) ; $ cacheKey = 'cachedReferrerSocialNetworks' ; $ cachedReferrerSocialNetworks = [ ] ; if ( $ cache -> contains ( $ cacheKey ) ) { $ cachedReferrerSocialNetworks = $ cache -> fetch ( $ cacheKey ) ; } $ socialNetworkN...
Social network detection
24,601
protected function detectReferrerDirectEntry ( ) { if ( empty ( $ this -> referrerHost ) ) { return false ; } $ urlsByHost = $ this -> getCachedUrlsByHostAndIdSite ( ) ; $ directEntry = new SiteUrls ( ) ; $ matchingSites = $ directEntry -> getIdSitesMatchingUrl ( $ this -> referrerUrlParse , $ urlsByHost ) ; if ( isset...
We have previously tried to detect the campaign variables in the URL so at this stage if the referrer host is the current host or if the referrer host is any of the registered URL for this website it is considered a direct entry
24,602
public function distinct ( $ flag = true ) { $ this -> _parts [ self :: DISTINCT ] = ( bool ) $ flag ; return $ this ; }
Makes the query SELECT DISTINCT .
24,603
public function columns ( $ cols = '*' , $ correlationName = null ) { if ( $ correlationName === null && count ( $ this -> _parts [ self :: FROM ] ) ) { $ correlationNameKeys = array_keys ( $ this -> _parts [ self :: FROM ] ) ; $ correlationName = current ( $ correlationNameKeys ) ; } if ( ! array_key_exists ( $ correl...
Specifies the columns used in the FROM clause .
24,604
public function union ( $ select = array ( ) , $ type = self :: SQL_UNION ) { if ( ! is_array ( $ select ) ) { throw new Zend_Db_Select_Exception ( "union() only accepts an array of Zend_Db_Select instances of sql query strings." ) ; } if ( ! in_array ( $ type , self :: $ _unionTypes ) ) { throw new Zend_Db_Select_Exce...
Adds a UNION clause to the query .
24,605
public function join ( $ name , $ cond , $ cols = self :: SQL_WILDCARD , $ schema = null ) { return $ this -> joinInner ( $ name , $ cond , $ cols , $ schema ) ; }
Adds a JOIN table and columns to the query .
24,606
public function joinLeft ( $ name , $ cond , $ cols = self :: SQL_WILDCARD , $ schema = null ) { return $ this -> _join ( self :: LEFT_JOIN , $ name , $ cond , $ cols , $ schema ) ; }
Add a LEFT OUTER JOIN table and colums to the query All rows from the left operand table are included matching rows from the right operand table included and the columns from the right operand table are filled with NULLs if no row exists matching the left table .
24,607
public function joinRight ( $ name , $ cond , $ cols = self :: SQL_WILDCARD , $ schema = null ) { return $ this -> _join ( self :: RIGHT_JOIN , $ name , $ cond , $ cols , $ schema ) ; }
Add a RIGHT OUTER JOIN table and colums to the query . Right outer join is the complement of left outer join . All rows from the right operand table are included matching rows from the left operand table included and the columns from the left operand table are filled with NULLs if no row exists matching the right table...
24,608
public function joinFull ( $ name , $ cond , $ cols = self :: SQL_WILDCARD , $ schema = null ) { return $ this -> _join ( self :: FULL_JOIN , $ name , $ cond , $ cols , $ schema ) ; }
Add a FULL OUTER JOIN table and colums to the query . A full outer join is like combining a left outer join and a right outer join . All rows from both tables are included paired with each other on the same row of the result set if they satisfy the join condition and otherwise paired with NULLs in place of columns from...
24,609
public function joinCross ( $ name , $ cols = self :: SQL_WILDCARD , $ schema = null ) { return $ this -> _join ( self :: CROSS_JOIN , $ name , null , $ cols , $ schema ) ; }
Add a CROSS JOIN table and colums to the query . A cross join is a cartesian product ; there is no join condition .
24,610
public function where ( $ cond , $ value = null , $ type = null ) { $ this -> _parts [ self :: WHERE ] [ ] = $ this -> _where ( $ cond , $ value , $ type , true ) ; return $ this ; }
Adds a WHERE condition to the query by AND .
24,611
public function orWhere ( $ cond , $ value = null , $ type = null ) { $ this -> _parts [ self :: WHERE ] [ ] = $ this -> _where ( $ cond , $ value , $ type , false ) ; return $ this ; }
Adds a WHERE condition to the query by OR .
24,612
public function group ( $ spec ) { if ( ! is_array ( $ spec ) ) { $ spec = array ( $ spec ) ; } foreach ( $ spec as $ val ) { if ( preg_match ( '/\(.*\)/' , ( string ) $ val ) ) { $ val = new Zend_Db_Expr ( $ val ) ; } $ this -> _parts [ self :: GROUP ] [ ] = $ val ; } return $ this ; }
Adds grouping to the query .
24,613
public function having ( $ cond , $ value = null , $ type = null ) { if ( $ value !== null ) { $ cond = $ this -> _adapter -> quoteInto ( $ cond , $ value , $ type ) ; } if ( $ this -> _parts [ self :: HAVING ] ) { $ this -> _parts [ self :: HAVING ] [ ] = self :: SQL_AND . " ($cond)" ; } else { $ this -> _parts [ self...
Adds a HAVING condition to the query by AND .
24,614
public function orHaving ( $ cond , $ value = null , $ type = null ) { if ( $ value !== null ) { $ cond = $ this -> _adapter -> quoteInto ( $ cond , $ value , $ type ) ; } if ( $ this -> _parts [ self :: HAVING ] ) { $ this -> _parts [ self :: HAVING ] [ ] = self :: SQL_OR . " ($cond)" ; } else { $ this -> _parts [ sel...
Adds a HAVING condition to the query by OR .
24,615
public function order ( $ spec ) { if ( ! is_array ( $ spec ) ) { $ spec = array ( $ spec ) ; } foreach ( $ spec as $ val ) { if ( $ val instanceof Zend_Db_Expr ) { $ expr = $ val -> __toString ( ) ; if ( empty ( $ expr ) ) { continue ; } $ this -> _parts [ self :: ORDER ] [ ] = $ val ; } else { if ( empty ( $ val ) ) ...
Adds a row order to the query .
24,616
public function limit ( $ count = null , $ offset = null ) { $ this -> _parts [ self :: LIMIT_COUNT ] = ( int ) $ count ; $ this -> _parts [ self :: LIMIT_OFFSET ] = ( int ) $ offset ; return $ this ; }
Sets a limit count and offset to the query .
24,617
public function limitPage ( $ page , $ rowCount ) { $ page = ( $ page > 0 ) ? $ page : 1 ; $ rowCount = ( $ rowCount > 0 ) ? $ rowCount : 1 ; $ this -> _parts [ self :: LIMIT_COUNT ] = ( int ) $ rowCount ; $ this -> _parts [ self :: LIMIT_OFFSET ] = ( int ) $ rowCount * ( $ page - 1 ) ; return $ this ; }
Sets the limit and count by page number .
24,618
public function forUpdate ( $ flag = true ) { $ this -> _parts [ self :: FOR_UPDATE ] = ( bool ) $ flag ; return $ this ; }
Makes the query SELECT FOR UPDATE .
24,619
public function getPart ( $ part ) { $ part = strtolower ( $ part ) ; if ( ! array_key_exists ( $ part , $ this -> _parts ) ) { throw new Zend_Db_Select_Exception ( "Invalid Select part '$part'" ) ; } return $ this -> _parts [ $ part ] ; }
Get part of the structured information for the currect query .
24,620
public function query ( $ fetchMode = null , $ bind = array ( ) ) { if ( ! empty ( $ bind ) ) { $ this -> bind ( $ bind ) ; } $ stmt = $ this -> _adapter -> query ( $ this ) ; if ( $ fetchMode == null ) { $ fetchMode = $ this -> _adapter -> getFetchMode ( ) ; } $ stmt -> setFetchMode ( $ fetchMode ) ; return $ stmt ; }
Executes the current select object and returns the result
24,621
public function assemble ( ) { $ sql = self :: SQL_SELECT ; foreach ( array_keys ( self :: $ _partsInit ) as $ part ) { $ method = '_render' . ucfirst ( $ part ) ; if ( method_exists ( $ this , $ method ) ) { $ sql = $ this -> $ method ( $ sql ) ; } } return $ sql ; }
Converts this object to an SQL SELECT string .
24,622
public function reset ( $ part = null ) { if ( $ part == null ) { $ this -> _parts = self :: $ _partsInit ; } else if ( array_key_exists ( $ part , self :: $ _partsInit ) ) { $ this -> _parts [ $ part ] = self :: $ _partsInit [ $ part ] ; } return $ this ; }
Clear parts of the Select object or an individual part .
24,623
public function _joinUsing ( $ type , $ name , $ cond , $ cols = '*' , $ schema = null ) { if ( empty ( $ this -> _parts [ self :: FROM ] ) ) { throw new Zend_Db_Select_Exception ( "You can only perform a joinUsing after specifying a FROM table" ) ; } $ join = $ this -> _adapter -> quoteIdentifier ( key ( $ this -> _pa...
Handle JOIN ... USING ... syntax
24,624
private function _uniqueCorrelation ( $ name ) { if ( is_array ( $ name ) ) { $ c = end ( $ name ) ; } else { $ dot = strrpos ( $ name , '.' ) ; $ c = ( $ dot === false ) ? $ name : substr ( $ name , $ dot + 1 ) ; } for ( $ i = 2 ; array_key_exists ( $ c , $ this -> _parts [ self :: FROM ] ) ; ++ $ i ) { $ c = $ name ....
Generate a unique correlation name
24,625
protected function _tableCols ( $ correlationName , $ cols , $ afterCorrelationName = null ) { if ( ! is_array ( $ cols ) ) { $ cols = array ( $ cols ) ; } if ( $ correlationName == null ) { $ correlationName = '' ; } $ columnValues = array ( ) ; foreach ( array_filter ( $ cols ) as $ alias => $ col ) { $ currentCorrel...
Adds to the internal table - to - column mapping array .
24,626
protected function _where ( $ condition , $ value = null , $ type = null , $ bool = true ) { if ( count ( $ this -> _parts [ self :: UNION ] ) ) { throw new Zend_Db_Select_Exception ( "Invalid use of where clause with " . self :: SQL_UNION ) ; } if ( $ value !== null ) { $ condition = $ this -> _adapter -> quoteInto ( ...
Internal function for creating the where clause
24,627
protected function _getQuotedSchema ( $ schema = null ) { if ( $ schema === null ) { return null ; } return $ this -> _adapter -> quoteIdentifier ( $ schema , true ) . '.' ; }
Return a quoted schema name
24,628
protected function _getQuotedTable ( $ tableName , $ correlationName = null ) { return $ this -> _adapter -> quoteTableAs ( $ tableName , $ correlationName , true ) ; }
Return a quoted table name
24,629
protected function _renderFrom ( $ sql ) { if ( empty ( $ this -> _parts [ self :: FROM ] ) ) { $ this -> _parts [ self :: FROM ] = $ this -> _getDummyTable ( ) ; } $ from = array ( ) ; foreach ( $ this -> _parts [ self :: FROM ] as $ correlationName => $ table ) { $ tmp = '' ; $ joinType = ( $ table [ 'joinType' ] == ...
Render FROM clause
24,630
protected function _renderUnion ( $ sql ) { if ( $ this -> _parts [ self :: UNION ] ) { $ parts = count ( $ this -> _parts [ self :: UNION ] ) ; foreach ( $ this -> _parts [ self :: UNION ] as $ cnt => $ union ) { list ( $ target , $ type ) = $ union ; if ( $ target instanceof Zend_Db_Select ) { $ target = $ target -> ...
Render UNION query
24,631
protected function _renderWhere ( $ sql ) { if ( $ this -> _parts [ self :: FROM ] && $ this -> _parts [ self :: WHERE ] ) { $ sql .= ' ' . self :: SQL_WHERE . ' ' . implode ( ' ' , $ this -> _parts [ self :: WHERE ] ) ; } return $ sql ; }
Render WHERE clause
24,632
protected function _renderGroup ( $ sql ) { if ( $ this -> _parts [ self :: FROM ] && $ this -> _parts [ self :: GROUP ] ) { $ group = array ( ) ; foreach ( $ this -> _parts [ self :: GROUP ] as $ term ) { $ group [ ] = $ this -> _adapter -> quoteIdentifier ( $ term , true ) ; } $ sql .= ' ' . self :: SQL_GROUP_BY . ' ...
Render GROUP clause
24,633
protected function _renderHaving ( $ sql ) { if ( $ this -> _parts [ self :: FROM ] && $ this -> _parts [ self :: HAVING ] ) { $ sql .= ' ' . self :: SQL_HAVING . ' ' . implode ( ' ' , $ this -> _parts [ self :: HAVING ] ) ; } return $ sql ; }
Render HAVING clause
24,634
protected function _renderOrder ( $ sql ) { if ( $ this -> _parts [ self :: ORDER ] ) { $ order = array ( ) ; foreach ( $ this -> _parts [ self :: ORDER ] as $ term ) { if ( is_array ( $ term ) ) { if ( is_numeric ( $ term [ 0 ] ) && strval ( intval ( $ term [ 0 ] ) ) == $ term [ 0 ] ) { $ order [ ] = ( int ) trim ( $ ...
Render ORDER clause
24,635
protected function _renderLimitoffset ( $ sql ) { $ count = 0 ; $ offset = 0 ; if ( ! empty ( $ this -> _parts [ self :: LIMIT_OFFSET ] ) ) { $ offset = ( int ) $ this -> _parts [ self :: LIMIT_OFFSET ] ; $ count = PHP_INT_MAX ; } if ( ! empty ( $ this -> _parts [ self :: LIMIT_COUNT ] ) ) { $ count = ( int ) $ this ->...
Render LIMIT OFFSET clause
24,636
protected function _renderForupdate ( $ sql ) { if ( $ this -> _parts [ self :: FOR_UPDATE ] ) { $ sql .= ' ' . self :: SQL_FOR_UPDATE ; } return $ sql ; }
Render FOR UPDATE clause
24,637
public static function getFileIntegrityInformation ( ) { $ messages = array ( ) ; $ manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php' ; if ( file_exists ( $ manifest ) ) { require_once $ manifest ; } if ( ! class_exists ( 'Piwik\\Manifest' ) ) { $ messages [ ] = Piwik :: translate ( 'General_WarningFileIntegri...
Get file integrity information
24,638
protected static function getDirectoriesFoundButNotExpected ( ) { static $ cache = null ; if ( ! is_null ( $ cache ) ) { return $ cache ; } $ pluginsInManifest = self :: getPluginsFoundInManifest ( ) ; $ directoriesInManifest = self :: getDirectoriesFoundInManifest ( ) ; $ directoriesFoundButNotExpected = array ( ) ; f...
Look for whole directories which are in the filesystem but should not be
24,639
protected static function getFilesFoundButNotExpected ( ) { $ files = \ Piwik \ Manifest :: $ files ; $ pluginsInManifest = self :: getPluginsFoundInManifest ( ) ; $ filesFoundButNotExpected = array ( ) ; foreach ( self :: getPathsToInvestigate ( ) as $ file ) { if ( is_dir ( $ file ) ) { continue ; } $ file = substr (...
Look for files which are in the filesystem but should not be
24,640
protected static function isFileFromPluginNotInManifest ( $ file , $ pluginsInManifest ) { if ( strpos ( $ file , 'plugins/' ) !== 0 ) { return false ; } if ( substr_count ( $ file , '/' ) < 2 ) { return false ; } $ pluginName = self :: getPluginNameFromFilepath ( $ file ) ; if ( in_array ( $ pluginName , $ pluginsInMa...
If a plugin folder is not tracked in the manifest then we don t try to report any files in this folder Could be a third party plugin or any plugin from the Marketplace
24,641
public function onNewAction ( Request $ request , Visitor $ visitor , Action $ action ) { if ( ! ( $ action instanceof ActionPageview ) ) { return false ; } $ value = Common :: getRequestVar ( 'my_page_keywords' , false , 'string' , $ request -> getParams ( ) ) ; if ( false === $ value ) { return $ value ; } $ value = ...
This event is triggered before a new action is logged to the log_link_visit_action table . It overwrites any looked up action so it makes usually no sense to implement both methods but it sometimes does . You can assign any value to the column or return boolan false in case you do not want to save any value .
24,642
protected function _checkRequiredOptions ( array $ config ) { parent :: _checkRequiredOptions ( $ config ) ; if ( array_key_exists ( 'host' , $ this -> _config ) && ! array_key_exists ( 'port' , $ config ) ) { throw new Zend_Db_Adapter_Exception ( "Configuration must have a key for 'port' when 'host' is specified" ) ; ...
Checks required options
24,643
public function insert ( $ table , array $ bind ) { $ this -> _connect ( ) ; $ newbind = array ( ) ; if ( is_array ( $ bind ) ) { foreach ( $ bind as $ name => $ value ) { if ( $ value !== null ) { $ newbind [ $ name ] = $ value ; } } } return parent :: insert ( $ table , $ newbind ) ; }
Inserts a table row with specified data . Special handling for PDO_IBM remove empty slots
24,644
public function getUsersHavingSuperUserAccess ( ) { $ db = $ this -> getDb ( ) ; $ users = $ db -> fetchAll ( "SELECT login, email, token_auth, superuser_access FROM " . Common :: prefixTable ( "user" ) . " WHERE superuser_access = 1 ...
Note that this returns the token_auth which is as private as the password!
24,645
public function getAll ( ) { $ result = $ this -> getListOptionValue ( ) ; foreach ( $ result as $ key => $ item ) { if ( is_array ( $ item ) ) { $ this -> logger -> info ( "Found array item in DistributedList option value '{name}': {data}" , array ( 'name' => $ this -> optionName , 'data' => var_export ( $ result , tr...
Queries the option table and returns all items in this list .
24,646
public function setAll ( $ items ) { foreach ( $ items as $ key => & $ item ) { if ( is_array ( $ item ) ) { throw new \ InvalidArgumentException ( "Array item encountered in DistributedList::setAll() [ key = $key ]." ) ; } else { $ item = ( string ) $ item ; } } Option :: set ( $ this -> optionName , serialize ( $ ite...
Sets the contents of the list in the option table .
24,647
public function add ( $ item ) { $ allItems = $ this -> getAll ( ) ; if ( is_array ( $ item ) ) { $ allItems = array_merge ( $ allItems , $ item ) ; } else { $ allItems [ ] = $ item ; } $ this -> setAll ( $ allItems ) ; }
Adds one or more items to the list in the option table .
24,648
public function remove ( $ items ) { if ( ! is_array ( $ items ) ) { $ items = array ( $ items ) ; } $ allItems = $ this -> getAll ( ) ; foreach ( $ items as $ item ) { $ existingIndex = array_search ( $ item , $ allItems ) ; if ( $ existingIndex === false ) { return ; } unset ( $ allItems [ $ existingIndex ] ) ; } $ t...
Removes one or more items by value from the list in the option table .
24,649
public function removeByIndex ( $ indices ) { if ( ! is_array ( $ indices ) ) { $ indices = array ( $ indices ) ; } $ indices = array_unique ( $ indices ) ; $ allItems = $ this -> getAll ( ) ; foreach ( $ indices as $ index ) { unset ( $ allItems [ $ index ] ) ; } $ this -> setAll ( array_values ( $ allItems ) ) ; }
Removes one or more items by index from the list in the option table .
24,650
public function getNumProcessedWebsites ( ) { $ numProcessed = $ this -> index + 1 ; if ( $ numProcessed > $ this -> getNumSites ( ) ) { return $ this -> getNumSites ( ) ; } return $ numProcessed ; }
Get the number of already processed websites . All websites were processed by the current archiver .
24,651
public function render ( ) { $ data = $ this -> _config -> toArray ( ) ; $ sectionName = $ this -> _config -> getSectionName ( ) ; $ extends = $ this -> _config -> getExtends ( ) ; if ( is_string ( $ sectionName ) ) { $ data = array ( $ sectionName => $ data ) ; } foreach ( $ extends as $ section => $ parentSection ) {...
Render a Zend_Config into a YAML config string .
24,652
protected static function _encodeYaml ( $ indent , $ data ) { reset ( $ data ) ; $ result = "" ; $ numeric = is_numeric ( key ( $ data ) ) ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ encoded = "\n" . self :: _encodeYaml ( $ indent + 1 , $ value ) ; } else { $ encoded = ( string ) $ value ...
Service function for encoding YAML
24,653
public function setStyleForId ( $ idOrStyles , $ style = null ) { if ( is_array ( $ idOrStyles ) ) { $ this -> styles = array_merge ( $ this -> styles , $ idOrStyles ) ; } else { $ this -> styles [ $ idOrStyles ] = $ style ; } return $ this ; }
Sets a style for element rendering
24,654
public function addWidgetConfig ( WidgetConfig $ widget ) { if ( $ widget instanceof WidgetContainerConfig ) { $ this -> addContainer ( $ widget ) ; } elseif ( Development :: isEnabled ( ) ) { $ this -> checkIsValidWidget ( $ widget ) ; } $ this -> widgets [ ] = $ widget ; }
Adds a new widget to the widget config . Please make sure the widget is enabled before adding a widget as no such checks will be performed .
24,655
public function addToContainerWidget ( $ containerId , WidgetConfig $ widget ) { if ( isset ( $ this -> container [ $ containerId ] ) ) { $ this -> container [ $ containerId ] -> addWidgetConfig ( $ widget ) ; } else { if ( ! isset ( $ this -> containerWidgets [ $ containerId ] ) ) { $ this -> containerWidgets [ $ cont...
Add a widget to a widget container . It doesn t matter whether the container was added to this list already or whether the container is added later . As long as a container having the same containerId is added at some point the widget will be added to that container . If no container having this id is added the widget ...
24,656
public function remove ( $ widgetCategoryId , $ widgetName = false ) { foreach ( $ this -> widgets as $ index => $ widget ) { if ( $ widget -> getCategoryId ( ) === $ widgetCategoryId ) { if ( ! $ widgetName || $ widget -> getName ( ) === $ widgetName ) { unset ( $ this -> widgets [ $ index ] ) ; } } } }
Removes one or more widgets from the widget list .
24,657
public function isDefined ( $ module , $ action ) { foreach ( $ this -> widgets as $ widget ) { if ( $ widget -> getModule ( ) === $ module && $ widget -> getAction ( ) === $ action ) { return true ; } } return false ; }
Returns true if a widget exists in the widget list false if otherwise .
24,658
public static function get ( ) { $ list = new static ; $ widgets = StaticContainer :: get ( 'Piwik\Plugin\WidgetsProvider' ) ; $ widgetContainerConfigs = $ widgets -> getWidgetContainerConfigs ( ) ; foreach ( $ widgetContainerConfigs as $ config ) { if ( $ config -> isEnabled ( ) ) { $ list -> addWidgetConfig ( $ confi...
Get all widgets defined in the Piwik platform .
24,659
public static function getWidgetUniqueId ( $ controllerName , $ controllerAction , $ customParameters = array ( ) ) { $ widgetUniqueId = 'widget' . $ controllerName . $ controllerAction ; foreach ( $ customParameters as $ name => $ value ) { if ( is_array ( $ value ) ) { $ value = 'Array' ; } $ value = urlencode ( $ va...
CAUTION! If you ever change this method existing updates will fail as they currently use that method! If you change the output the uniqueId for existing widgets would not be found anymore
24,660
public function index ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ view = new View ( '@DBStats/index' ) ; $ this -> setBasicVariablesView ( $ view ) ; $ _GET [ 'showtitle' ] = '1' ; $ view -> databaseUsageSummary = $ this -> renderReport ( 'getDatabaseUsageSummary' ) ; $ view -> trackerDataSummary = $ this -> ren...
Returns the index for this plugin . Shows every other report defined by this plugin except the ... ByYear reports . These can be loaded as related reports .
24,661
public function setConfig ( $ config ) { if ( is_null ( $ config ) ) { $ config = 1 ; } elseif ( 1 > intval ( $ config ) ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'Nonempty Rule accepts a positive count of nonempty values, ' . preg_replace ( '/\s+/' , ' ' , var_export ( $ config , true ) ) . ' given' ) ;...
Sets minimum number of nonempty values
24,662
public function getRangeLabel ( $ oldLabel , $ lowerBound , $ upperBound ) { if ( $ lowerBound < 60 ) { return sprintf ( $ this -> labelSecondsPlural , $ lowerBound , $ upperBound ) ; } else { return sprintf ( $ this -> labelPlural , ceil ( $ lowerBound / 60 ) . "-" . ceil ( $ upperBound / 60 ) ) ; } }
Beautifies and returns a range label whose range is bounded and spans over more than one unit ie 1 - 5 5 - 10 but NOT 11 + .
24,663
public function getUnboundedLabel ( $ oldLabel , $ lowerBound ) { if ( $ lowerBound < 60 ) { return sprintf ( $ this -> labelSecondsPlural , $ lowerBound ) ; } else { return sprintf ( $ this -> labelPlural , "" . floor ( $ lowerBound / 60 ) . urlencode ( '+' ) ) ; } }
Beautifies and returns a range label whose range is unbounded ie 5 + 10 + etc .
24,664
public function sql ( $ sql , $ errorCodesToIgnore = array ( ) ) { if ( $ errorCodesToIgnore === false ) { $ errorCodesToIgnore = array ( ) ; } return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\Sql' , array ( 'sql' => $ sql , 'errorCodesToIgnore' => $ errorCodesToIgnore ) ) ; }
Performs a custom SQL query during the update .
24,665
public function boundSql ( $ sql , $ bind , $ errorCodesToIgnore = array ( ) ) { if ( $ errorCodesToIgnore === false ) { $ errorCodesToIgnore = array ( ) ; } return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\BoundSql' , array ( 'sql' => $ sql , 'errorCodesToIgnore' => $ errorCodesToIgnore , 'bind' => $ b...
Performs a custom SQL query that uses bound parameters during the update .
24,666
public function createTable ( $ table , $ columnNames , $ primaryKey = array ( ) ) { $ table = $ this -> prefixTable ( $ table ) ; if ( ! empty ( $ primaryKey ) && ! is_array ( $ primaryKey ) ) { $ primaryKey = array ( $ primaryKey ) ; } return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\CreateTable' , ar...
Creates a new database table .
24,667
public function dropTable ( $ table ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\DropTable' , array ( 'table' => $ table ) ) ; }
Drops an existing database table .
24,668
public function addColumn ( $ table , $ columnName , $ columnType , $ placeColumnAfter = null ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\AddColumn' , array ( 'table' => $ table , 'columnName' => $ columnName , 'columnType' => $ columnType , 'placeC...
Adds a new database table column to an existing table .
24,669
public function addColumns ( $ table , $ columns , $ placeColumnAfter = null ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\AddColumns' , array ( 'table' => $ table , 'columns' => $ columns , 'placeColumnAfter' => $ placeColumnAfter ) ) ; }
Adds multiple new database table columns to an existing table at once .
24,670
public function dropColumn ( $ table , $ columnName ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\DropColumn' , array ( 'table' => $ table , 'columnName' => $ columnName ) ) ; }
Drops an existing database table column .
24,671
public function changeColumn ( $ table , $ oldColumnName , $ newColumnName , $ columnType ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\ChangeColumn' , array ( 'table' => $ table , 'oldColumnName' => $ oldColumnName , 'newColumnName' => $ newColumnNam...
Changes the column name and column type of an existing database table column .
24,672
public function changeColumnType ( $ table , $ columnName , $ columnType ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\ChangeColumnType' , array ( 'table' => $ table , 'columnName' => $ columnName , 'columnType' => $ columnType ) ) ; }
Changes the type of an existing database table column .
24,673
public function changeColumnTypes ( $ table , $ columns ) { $ table = $ this -> prefixTable ( $ table ) ; return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\ChangeColumnTypes' , array ( 'table' => $ table , 'columns' => $ columns ) ) ; }
Changes the type of multiple existing database table columns at the same time .
24,674
public function addIndex ( $ table , $ columnNames , $ indexName = '' ) { $ table = $ this -> prefixTable ( $ table ) ; if ( ! is_array ( $ columnNames ) ) { $ columnNames = array ( $ columnNames ) ; } return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\AddIndex' , array ( 'table' => $ table , 'columnNames...
Adds an index to an existing database table .
24,675
public function addPrimaryKey ( $ table , $ columnNames ) { $ table = $ this -> prefixTable ( $ table ) ; if ( ! is_array ( $ columnNames ) ) { $ columnNames = array ( $ columnNames ) ; } return $ this -> container -> make ( 'Piwik\Updater\Migration\Db\AddPrimaryKey' , array ( 'table' => $ table , 'columnNames' => $ co...
Adds a primary key to an existing database table .
24,676
public function redirect ( ) { $ url = Common :: getRequestVar ( 'url' , '' , 'string' , $ _GET ) ; if ( ! UrlHelper :: isLookLikeUrl ( $ url ) ) { die ( 'Please check the &url= parameter: it should to be a valid URL' ) ; } $ referrer = Url :: getReferrer ( ) ; if ( empty ( $ referrer ) || ! Url :: isLocalUrl ( $ refer...
Output redirection page instead of linking directly to avoid exposing the referrer on the Piwik demo .
24,677
public function completeLocationResult ( & $ location ) { parent :: completeLocationResult ( $ location ) ; if ( empty ( $ location [ self :: REGION_NAME_KEY ] ) && ! empty ( $ location [ self :: REGION_CODE_KEY ] ) && ! empty ( $ location [ self :: COUNTRY_CODE_KEY ] ) ) { $ countryCode = $ location [ self :: COUNTRY_...
Attempts to fill in some missing information in a GeoIP location .
24,678
public static function getRegionNames ( ) { if ( is_null ( self :: $ regionNames ) ) { $ GEOIP_REGION_NAME = array ( ) ; require_once PIWIK_INCLUDE_PATH . '/libs/MaxMindGeoIP/geoipregionvars.php' ; self :: $ regionNames = $ GEOIP_REGION_NAME ; } return self :: $ regionNames ; }
Returns an array of region names mapped by country code & region code .
24,679
public static function getPathToGeoIpDatabase ( $ possibleFileNames ) { foreach ( $ possibleFileNames as $ filename ) { $ path = self :: getPathForGeoIpDatabase ( $ filename ) ; if ( file_exists ( $ path ) ) { return $ path ; } } return false ; }
Returns the path of an existing GeoIP database or false if none can be found .
24,680
public static function isDatabaseInstalled ( ) { return self :: getPathToGeoIpDatabase ( self :: $ dbNames [ 'loc' ] ) || self :: getPathToGeoIpDatabase ( self :: $ dbNames [ 'isp' ] ) || self :: getPathToGeoIpDatabase ( self :: $ dbNames [ 'org' ] ) ; }
Returns true if there is a GeoIP database in the misc directory .
24,681
public function trackingCodeGenerator ( ) { Piwik :: checkUserHasSomeViewAccess ( ) ; $ view = new View ( '@CoreAdminHome/trackingCodeGenerator' ) ; $ this -> setBasicVariablesView ( $ view ) ; $ view -> topMenu = MenuTop :: getInstance ( ) -> getMenu ( ) ; $ viewableIdSites = APISitesManager :: getInstance ( ) -> getS...
Renders and echo s an admin page that lets users generate custom JavaScript tracking code and custom image tracker links .
24,682
public static function getAllVisitorDetailsInstances ( ) { $ cacheId = CacheId :: pluginAware ( 'VisitorDetails' ) ; $ cache = Cache :: getTransientCache ( ) ; if ( ! $ cache -> contains ( $ cacheId ) ) { $ instances = [ new VisitorDetails ( ) ] ; Piwik :: postEvent ( 'Live.addVisitorDetails' , array ( & $ instances ) ...
Returns all available visitor details instances
24,683
public function setHash ( $ options ) { if ( ! is_array ( $ options ) ) { $ options = ( array ) $ options ; } $ options [ 'algorithm' ] = 'md5' ; parent :: setHash ( $ options ) ; return $ this ; }
Sets the md5 hash for one or multiple files
24,684
public function addHash ( $ options ) { if ( ! is_array ( $ options ) ) { $ options = ( array ) $ options ; } $ options [ 'algorithm' ] = 'md5' ; parent :: addHash ( $ options ) ; return $ this ; }
Adds the md5 hash for one or multiple files
24,685
public function downloadFreeGeoIPDB ( ) { $ this -> dieIfGeolocationAdminIsDisabled ( ) ; Piwik :: checkUserHasSuperUserAccess ( ) ; if ( $ this -> isGeoIp2Enabled ( ) ) { return $ this -> downloadFreeGeoIP2DB ( ) ; } if ( $ _SERVER [ "REQUEST_METHOD" ] == "POST" ) { $ this -> checkTokenInUrl ( ) ; Json :: sendHeaderJS...
Starts or continues download of GeoLiteCity . dat .
24,686
public function downloadFreeGeoIP2DB ( ) { $ this -> dieIfGeolocationAdminIsDisabled ( ) ; Piwik :: checkUserHasSuperUserAccess ( ) ; if ( $ _SERVER [ "REQUEST_METHOD" ] == "POST" ) { $ this -> checkTokenInUrl ( ) ; Json :: sendHeaderJSON ( ) ; $ outputPath = GeoIp2 :: getPathForGeoIpDatabase ( 'GeoLite2-City.tar' ) . ...
Starts or continues download of GeoLite2 - City . mmdb .
24,687
private function setUpdaterManageVars ( $ view ) { $ view -> isGeoIp2Available = $ this -> isGeoIp2Enabled ( ) ; if ( $ this -> isGeoIp2Enabled ( ) ) { $ urls = GeoIPAutoUpdater :: getConfiguredUrls ( ) ; $ view -> geoIPLegacyLocUrl = $ urls [ 'loc' ] ; $ view -> geoIPLegacyIspUrl = $ urls [ 'isp' ] ; $ view -> geoIPLe...
Sets some variables needed by the _updaterManage . twig template .
24,688
public function updateGeoIPLinks ( ) { $ this -> dieIfGeolocationAdminIsDisabled ( ) ; Piwik :: checkUserHasSuperUserAccess ( ) ; if ( $ _SERVER [ "REQUEST_METHOD" ] == "POST" ) { Json :: sendHeaderJSON ( ) ; try { $ this -> checkTokenInUrl ( ) ; if ( $ this -> isGeoIp2Enabled ( ) ) { GeoIP2AutoUpdater :: setUpdaterOpt...
Sets the URLs used to download new versions of the installed GeoIP databases .
24,689
public function downloadMissingGeoIpDb ( ) { $ this -> dieIfGeolocationAdminIsDisabled ( ) ; Piwik :: checkUserHasSuperUserAccess ( ) ; if ( $ _SERVER [ "REQUEST_METHOD" ] == "POST" ) { try { $ this -> checkTokenInUrl ( ) ; Json :: sendHeaderJSON ( ) ; $ key = Common :: getRequestVar ( 'key' , null , 'string' ) ; if ( ...
Starts or continues a download for a missing GeoIP database . A database is missing if it has an update URL configured but the actual database is not available in the misc directory .
24,690
public function getLocationUsingProvider ( ) { $ providerId = Common :: getRequestVar ( 'id' ) ; $ provider = LocationProvider :: getProviderById ( $ providerId ) ; if ( empty ( $ provider ) ) { throw new Exception ( "Invalid provider ID: '$providerId'." ) ; } $ location = $ provider -> getLocation ( array ( 'ip' => IP...
Echo s a pretty formatted location using a specific LocationProvider .
24,691
protected function _stripQuoted ( $ sql ) { $ d = $ this -> _adapter -> quoteIdentifier ( 'a' ) ; $ d = $ d [ 0 ] ; $ de = $ this -> _adapter -> quoteIdentifier ( $ d ) ; $ de = substr ( $ de , 1 , 2 ) ; $ de = str_replace ( '\\' , '\\\\' , $ de ) ; $ q = $ this -> _adapter -> quote ( 'a' ) ; $ q = $ q [ 0 ] ; $ qe = $...
Remove parts of a SQL string that contain quoted strings of values or identifiers .
24,692
public function _fetchBound ( $ row ) { foreach ( $ row as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key ++ ; } if ( isset ( $ this -> _bindColumn [ $ key ] ) ) { $ this -> _bindColumn [ $ key ] = $ value ; } } return true ; }
Helper function to map retrieved row to bound column variables
24,693
public function getAll ( $ period , $ date , $ segment = false , $ _restrictSitesToLogin = false , $ enhanced = false , $ pattern = false , $ showColumns = array ( ) ) { Piwik :: checkUserHasSomeViewAccess ( ) ; $ sites = $ this -> getSitesIdFromPattern ( $ pattern , $ _restrictSitesToLogin ) ; if ( ! empty ( $ showCol...
Returns a report displaying the total visits actions and revenue as well as the evolution of these values of all existing sites over a specified period of time .
24,694
private function getSitesIdFromPattern ( $ pattern , $ _restrictSitesToLogin ) { Site :: clearCache ( ) ; if ( empty ( $ pattern ) ) { $ scheduler = StaticContainer :: getContainer ( ) -> get ( 'Piwik\Scheduler\Scheduler' ) ; if ( Piwik :: hasUserSuperUserAccess ( ) && ! $ scheduler -> isRunningTask ( ) ) { APISitesMan...
Fetches the list of sites which names match the string pattern
24,695
private function calculateEvolutionPercentages ( $ currentData , $ pastData , $ apiMetrics ) { if ( get_class ( $ currentData ) != get_class ( $ pastData ) ) { throw new Exception ( "Expected \$pastData to be of type " . get_class ( $ currentData ) . " - got " . get_class ( $ pastData ) . "." ) ; } if ( $ currentData i...
Performs a binary filter of two DataTables in order to correctly calculate evolution metrics .
24,696
private function setPastTotalVisitsMetadata ( $ dataTable , $ pastTable ) { if ( $ pastTable instanceof DataTable ) { $ total = 0 ; $ metric = 'nb_visits' ; $ rows = $ pastTable -> getRows ( ) ; $ rows = $ this -> filterRowsForTotalsCalculation ( $ rows ) ; foreach ( $ rows as $ row ) { $ total += $ row -> getColumn ( ...
Sets the number of total visits in tha pastTable on the dataTable as metadata .
24,697
public function getDatabaseSize ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ view = new View ( '@PrivacyManager/getDatabaseSize' ) ; $ forceEstimate = Common :: getRequestVar ( 'forceEstimate' , 0 ) ; $ view -> dbStats = $ this -> getDeleteDBSizeEstimate ( $ getSettingsFromQuery = true , $ forceEstimate ) ; $ vie...
Echo s an HTML chunk describing the current database size and the estimated space savings after the scheduled data purge is run .
24,698
public function executeDataPurge ( ) { $ this -> checkDataPurgeAdminSettingsIsEnabled ( ) ; Piwik :: checkUserHasSuperUserAccess ( ) ; $ this -> checkTokenInUrl ( ) ; if ( $ _SERVER [ "REQUEST_METHOD" ] != "POST" && ! Common :: isPhpCliMode ( ) ) { $ this -> redirectToIndex ( 'PrivacyManager' , 'privacySettings' ) ; re...
Executes a data purge deleting raw data and report data using the current config options . Echo s the result of getDatabaseSize after purging .
24,699
public function index ( ) { Piwik :: checkUserHasViewAccess ( $ this -> idSite ) ; $ template = '@Overlay/index' ; if ( Config :: getInstance ( ) -> General [ 'overlay_disable_framed_mode' ] ) { $ template = '@Overlay/index_noframe' ; } $ view = new View ( $ template ) ; $ this -> setGeneralVariablesView ( $ view ) ; $...
The index of the plugin