diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-12-26 16:50:57 +0300 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-12-26 16:50:57 +0300 |
commit | 446fd843abd0640403c30a763493a8fb1d821160 (patch) | |
tree | 65ebec570ef05ae3f3d84e14a3e4cd7ab6b128ea /core | |
parent | 35d668736cc7596e9f48ac050ce685a45296cbb6 (diff) |
- cacheFile is now creating the directory if not already created
- adding log_conversion table, and goal table in 0.2.27
- adding case sensitive/case insensitive matching
- when goal plugin is disabled, conversions are not being recorded
- adding release notes in the Goal tab to let users know that this is alpha release
Diffstat (limited to 'core')
-rw-r--r-- | core/ArchiveProcessing/Day.php | 1 | ||||
-rw-r--r-- | core/CacheFile.php | 8 | ||||
-rw-r--r-- | core/Common.php | 34 | ||||
-rw-r--r-- | core/DataFiles/SearchEngines.php | 5 | ||||
-rw-r--r-- | core/Log.php | 2 | ||||
-rw-r--r-- | core/Piwik.php | 81 | ||||
-rw-r--r-- | core/PluginsManager.php | 4 | ||||
-rw-r--r-- | core/Tracker/GoalManager.php | 35 | ||||
-rw-r--r-- | core/Updates/0.2.27.php | 18 | ||||
-rw-r--r-- | core/Updates/0.2.28.php | 9 | ||||
-rw-r--r-- | core/Version.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable.php | 5 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable/AllColumns.php | 1 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable/Goals.php | 1 |
14 files changed, 139 insertions, 67 deletions
diff --git a/core/ArchiveProcessing/Day.php b/core/ArchiveProcessing/Day.php index 300234f3ce..9d0e3fd975 100644 --- a/core/ArchiveProcessing/Day.php +++ b/core/ArchiveProcessing/Day.php @@ -358,7 +358,6 @@ class Piwik_ArchiveProcessing_Day extends Piwik_ArchiveProcessing $oldRowToUpdate[Piwik_Archive::INDEX_NB_VISITS_CONVERTED] += $newRowToAdd['nb_visits_converted']; } - //TODO comment public function queryConversionsBySegment($segments = '') { if(!empty($segments)) diff --git a/core/CacheFile.php b/core/CacheFile.php index 156ef85703..a254788c52 100644 --- a/core/CacheFile.php +++ b/core/CacheFile.php @@ -58,12 +58,16 @@ class Piwik_CacheFile * @return bool True if the entry was succesfully stored */ function set($id, $content) - { + { + if( !is_dir($this->cachePath)) + { + Piwik_Common::mkdir($this->cachePath); + } if (!is_writable($this->cachePath)) { return false; } - $id = $this->cachePath . $id; + $id = $this->cachePath . $id . ".php"; $cache_literal = "<"."?php\n\n"; $cache_literal .= "$"."content = ".var_export($content, true).";\n\n"; diff --git a/core/Common.php b/core/Common.php index adfd7015b7..194e66a4c8 100644 --- a/core/Common.php +++ b/core/Common.php @@ -216,6 +216,40 @@ class Piwik_Common return $nameToValue; } + static public function mkdir( $path, $mode = 0755, $denyAccess = true ) + { + if(!is_dir($path)) + { + $directoryParent = Piwik_Common::realpath(dirname($path)); + if( is_writable($directoryParent) ) + { + mkdir($path, $mode, true); + } + } + + if($denyAccess) + { + self::createHtAccess($path); + } + } + + /** + * path without trailing slash + */ + static public function createHtAccess( $path ) + { + @file_put_contents($path . "/.htaccess", "Deny from all"); + } + + static public function realpath($path) + { + if (file_exists($path)) + { + return realpath($path); + } + return $path; + } + /** * Returns true if the string is a valid filename * File names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), and dot(.) will be accepted. diff --git a/core/DataFiles/SearchEngines.php b/core/DataFiles/SearchEngines.php index af8891dca3..1076b56ff7 100644 --- a/core/DataFiles/SearchEngines.php +++ b/core/DataFiles/SearchEngines.php @@ -66,8 +66,9 @@ if(!isset($GLOBALS['Piwik_SearchEngines'] )) //Alice Adsl "rechercher.aliceadsl.fr" => array("Alice Adsl", "qs"), - "search.alice.it" => array("Alice (Virgilio)", "qt"), - + "search.alice.it" => array("Alice (powered by Virgilio)", "qt"), + "ricerca.alice.it" => array("Alice (powered by Virgilio)", "qs"), + //Allesklar "www.allesklar.de" => array("Allesklar", "words"), diff --git a/core/Log.php b/core/Log.php index 3291065e26..59f91c025b 100644 --- a/core/Log.php +++ b/core/Log.php @@ -52,7 +52,7 @@ abstract class Piwik_Log extends Zend_Log function addWriteToFile() { $writerFile = new Zend_Log_Writer_Stream($this->logToFileFilename); - Piwik::mkdir(Zend_Registry::get('config')->path->log); + Piwik_Common::mkdir(Zend_Registry::get('config')->path->log); $writerFile->setFormatter( $this->fileFormatter ); $this->addWriter($writerFile); } diff --git a/core/Piwik.php b/core/Piwik.php index 597d335257..aafe16655a 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -34,31 +34,6 @@ class Piwik ); /** - * path without trailing slash - */ - static public function createHtAccess( $path ) - { - @file_put_contents($path . "/.htaccess", "Deny from all"); - } - - static public function mkdir( $path, $mode = 0755, $denyAccess = true ) - { - if(!is_dir($path)) - { - $directoryParent = Piwik::realpath(dirname($path)); - if( is_writable($directoryParent) ) - { - mkdir($path, $mode, true); - } - } - - if($denyAccess) - { - Piwik::createHtAccess($path); - } - } - - /** * Checks that the directories Piwik needs write access are actually writable * Displays a nice error page if permissions are missing on some directories * @@ -72,7 +47,7 @@ class Piwik $directoryList = ''; foreach($resultCheck as $dir => $bool) { - $realpath = Piwik::realpath($dir); + $realpath = Piwik_Common::realpath($dir); if(!empty($realpath) && $bool === false) { $directoryList .= "<code>chmod 777 $realpath</code><br>"; @@ -117,10 +92,10 @@ class Piwik if(!file_exists($directoryToCheck)) { - Piwik::mkdir($directoryToCheck, 0755, false); + Piwik_Common::mkdir($directoryToCheck, 0755, false); } - $directory = Piwik::realpath($directoryToCheck); + $directory = Piwik_Common::realpath($directoryToCheck); $resultCheck[$directory] = false; if($directory !== false // realpath() returns FALSE on failure && is_writable($directoryToCheck)) @@ -131,15 +106,6 @@ class Piwik return $resultCheck; } - static public function realpath($path) - { - if (file_exists($path)) - { - return realpath($path); - } - return $path; - } - /** * Returns the Javascript code to be inserted on every page to track * @@ -547,6 +513,19 @@ class Piwik ) ", + 'goal' => " CREATE TABLE `{$prefixTables}goal` ( + `idsite` int(11) NOT NULL, + `idgoal` int(11) NOT NULL, + `name` varchar(50) NOT NULL, + `match_attribute` varchar(20) NOT NULL, + `pattern` varchar(255) NOT NULL, + `pattern_type` varchar(10) NOT NULL, + `case_sensitive` tinyint(4) NOT NULL, + `revenue` float NOT NULL, + `deleted` tinyint(4) NOT NULL default '0', + PRIMARY KEY (`idsite`,`idgoal`) + ) + ", 'logger_message' => "CREATE TABLE {$prefixTables}logger_message ( idlogger_message INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, @@ -644,6 +623,30 @@ class Piwik ) ", + 'log_conversion' => "CREATE TABLE `{$prefixTables}log_conversion` ( + `idvisit` int(10) unsigned NOT NULL, + `idsite` int(10) unsigned NOT NULL, + `visitor_idcookie` char(32) NOT NULL, + `server_time` datetime NOT NULL, + `visit_server_date` date NOT NULL, + `idaction` int(11) NOT NULL, + `idlink_va` int(11) NOT NULL, + `referer_idvisit` int(10) unsigned default NULL, + `referer_visit_server_date` date default NULL, + `referer_type` int(10) unsigned default NULL, + `referer_name` varchar(70) default NULL, + `referer_keyword` varchar(255) default NULL, + `visitor_returning` tinyint(1) NOT NULL, + `location_country` char(3) NOT NULL, + `location_continent` char(3) NOT NULL, + `url` text NOT NULL, + `idgoal` int(10) unsigned NOT NULL, + `revenue` float default NULL, + PRIMARY KEY (`idvisit`,`idgoal`), + KEY `index_idsite_date` (`idsite`,`visit_server_date`) + ) + ", + 'log_link_visit_action' => "CREATE TABLE {$prefixTables}log_link_visit_action ( idlink_va INTEGER(11) NOT NULL AUTO_INCREMENT, idvisit INTEGER(10) UNSIGNED NOT NULL, @@ -1151,8 +1154,8 @@ class Piwik static public function install() { - Piwik::mkdir(Zend_Registry::get('config')->smarty->compile_dir); - Piwik::mkdir(Zend_Registry::get('config')->smarty->cache_dir); + Piwik_Common::mkdir(Zend_Registry::get('config')->smarty->compile_dir); + Piwik_Common::mkdir(Zend_Registry::get('config')->smarty->cache_dir); } static public function uninstall() diff --git a/core/PluginsManager.php b/core/PluginsManager.php index 60c4f42f7a..a27bd2c937 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -401,9 +401,7 @@ class Piwik_PluginsManager } /** - * TODO horrible dirty hack because the Config class is not clean enough. Needs to rewrite the Config - * __set and __get in a cleaner way, also see the __destruct which writes the configuration file. - * + * TODO horrible dirty hack. Fix config class by merging both config files before reading. * @return array */ public function getInstalledPluginsName() diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 85ef6ba808..d7f3b38726 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -25,8 +25,6 @@ class Piwik_Tracker_GoalManager $this->cookie = $cookie; } - //TODO goalid should be incrementing on a website basis - // load goal definitions from file static public function getGoalDefinitions( $idSite ) { $websiteAttributes = Piwik_Common::getCacheWebsiteAttributes( $idSite ); @@ -61,6 +59,10 @@ class Piwik_Tracker_GoalManager //TODO does this code work for manually triggered goals, with custom revenue? function detectGoals($idSite) { + if(!Piwik_PluginsManager::getInstance()->isPluginActivated('Goals')) + { + return false; + } $url = $this->action->getUrl(); $actionType = $this->action->getActionType(); $goals = $this->getGoalDefinitions($idSite); @@ -76,25 +78,44 @@ class Piwik_Tracker_GoalManager continue; } - //TODO: outlink trailing slash is automatically deleted, problem when trying to match? $pattern_type = $goal['pattern_type']; switch($pattern_type) { case 'regex': - $match = (preg_match('/' . $goal['pattern'] . '/', $url) == 1); + $pattern = '/' . $goal['pattern'] . '/'; + if(!$goal['case_sensitive']) + { + $pattern .= 'i'; + } + $match = (preg_match($pattern, $url) == 1); break; case 'contains': - $match = (strpos($url, $goal['pattern']) !== false); + if($goal['case_sensitive']) + { + $matched = strpos($url, $goal['pattern']); + } + else + { + $matched = stripos($url, $goal['pattern']); + } + $match = ($matched !== false); break; case 'exact': - $match = ($goal['pattern'] == $url); + if($goal['case_sensitive']) + { + $matched = strcmp($goal['pattern'], $url); + } + else + { + $matched = strcasecmp($goal['pattern'], $url); + } + $match = ($matched == 0); break; default: throw new Exception("Pattern type $pattern_type not valid."); break; } - if($match) { $this->matchedGoals[] = $goal; diff --git a/core/Updates/0.2.27.php b/core/Updates/0.2.27.php new file mode 100644 index 0000000000..4e04ee3eb0 --- /dev/null +++ b/core/Updates/0.2.27.php @@ -0,0 +1,18 @@ +<?php + +Piwik_Query( "ALTER TABLE `".Piwik::prefixTable('log_visit')."` + ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time` ;"); +$tables = Piwik::getTablesCreateSql(); +Piwik_Query( $tables['log_conversion'] ); +Piwik_Query( $tables['goal'] ); + +$allTablesInstalled = Piwik::getTablesInstalled(); +foreach($allTablesInstalled as $tableName) +{ + if(preg_match('/archive_/', $tableName) == 1) + { + Piwik_Query('CREATE INDEX index_all + ON '. $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'); + + } +} diff --git a/core/Updates/0.2.28.php b/core/Updates/0.2.28.php deleted file mode 100644 index a64b2b2a72..0000000000 --- a/core/Updates/0.2.28.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -Piwik_Query( "ALTER TABLE `".Piwik::prefixTable('log_visit')."` - ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time` ;"); - -//TODO -// alter all archive_* -// KEY `index_all` (`idsite`,`date1`,`date2`,`name`,`ts_archived`) - diff --git a/core/Version.php b/core/Version.php index 89ad548c01..ce5455afda 100644 --- a/core/Version.php +++ b/core/Version.php @@ -1,5 +1,5 @@ <?php final class Piwik_Version { - const VERSION = '0.2.26'; + const VERSION = '0.2.27'; } diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index cc767a1337..e13f6b3d71 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -662,7 +662,10 @@ abstract class Piwik_ViewDataTable */ public function enableShowGoals() { - $this->viewProperties['show_goals'] = true; + if(Piwik_PluginsManager::getInstance()->isPluginActivated('Goals')) + { + $this->viewProperties['show_goals'] = true; + } } /** diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php index bf84ff2ff0..2a83c9ae80 100644 --- a/core/ViewDataTable/HtmlTable/AllColumns.php +++ b/core/ViewDataTable/HtmlTable/AllColumns.php @@ -10,7 +10,6 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT public function main() { - //TODO should be cached at least statically? $this->viewProperties['show_exclude_low_population'] = true; parent::main(); } diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php index f1233fec6a..6711f7602c 100644 --- a/core/ViewDataTable/HtmlTable/Goals.php +++ b/core/ViewDataTable/HtmlTable/Goals.php @@ -47,6 +47,7 @@ class Piwik_ViewDataTable_HtmlTable_Goals extends Piwik_ViewDataTable_HtmlTable if($columnName == 'goal_%s_conversion_rate') { require_once "core/Tracker/GoalManager.php"; + require_once "plugins/Goals/API.php"; $goals = Piwik_Goals_API::getGoals( $this->getIdSite() ); foreach($goals as $goal) { |