diff options
author | matthieu_ <matthieu_@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2007-09-17 22:35:25 +0400 |
---|---|---|
committer | matthieu_ <matthieu_@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2007-09-17 22:35:25 +0400 |
commit | 5f80dfd757c207c0963cf790fe61fa220dcc1382 (patch) | |
tree | 33db76736c1db12bebf95d00f1e7775ce440faaf | |
parent | d1877ab55079023ca9dac89587163bfdb43524cc (diff) |
Fixed small bugs when no visitors
Worked on the openads integration, full specification ready
-rw-r--r-- | MVC specification.txt (renamed from MVC specification.php) | 4 | ||||
-rw-r--r-- | TODO | 7 | ||||
-rw-r--r-- | misc/generateVisitsData/Referers.php | 1 | ||||
-rw-r--r-- | modules/API/Request.php | 4 | ||||
-rw-r--r-- | modules/Archive.php | 4 | ||||
-rw-r--r-- | modules/LogStats/Visit.php | 2 | ||||
-rw-r--r-- | modules/PluginsManager.php | 6 | ||||
-rw-r--r-- | modules/ViewDataTable/GenerateGraphData.php | 54 | ||||
-rw-r--r-- | modules/ViewDataTable/Graph.php | 2 | ||||
-rw-r--r-- | modules/Visualization/Chart.php | 11 | ||||
-rw-r--r-- | modules/Visualization/OpenFlashChart.php | 2 | ||||
-rw-r--r-- | openads_piwik_plugin.php | 235 | ||||
-rw-r--r-- | piwik openads integration.odt | bin | 16995 -> 21828 bytes | |||
-rw-r--r-- | plugins/UserSettings/templates/graph.tpl | 1 |
14 files changed, 298 insertions, 35 deletions
diff --git a/MVC specification.php b/MVC specification.txt index 7b4467c4a3..866444523a 100644 --- a/MVC specification.php +++ b/MVC specification.txt @@ -35,3 +35,7 @@ Use cases 7 - Plugin that add a selection for every user ------------------------------------------------------------------------------------ + +Links +===== +Netvibes box using jquery http://sonspring.com/journal/jquery-portlets @@ -13,6 +13,7 @@ FEATURES - Purge log_ when archiving is done - Provide Config file feature for plugins (works as the translation system) - CHANGE setColumnsToDisplay TO setColumnsIdsToDisplay +- Limit number of rows saved in the datatable during the archiving process BUGS ==== @@ -34,10 +35,16 @@ BUGS $element .= $slash; } - is_numeric is not valid. Replace by is_int OR is_float +- images.google.X is not counted as a search engine. needs to read the prev variable and then the q variable. User Interface ============== - searching on countries should search on the final label and not the iso code +- define the default output type on a per table basis +- design a generic system to add _blocks_ in _pages_ (different from the _views_ associated to the controllers) +- plugins can add & modify the menu +- add the columns containing the % values based on the nb_visits or nb_visitors +- when a given output is chosen (Tag cloud) hide the icon under the datatable TODO MISC ========= diff --git a/misc/generateVisitsData/Referers.php b/misc/generateVisitsData/Referers.php index ae3327a773..ad6f85dc1e 100644 --- a/misc/generateVisitsData/Referers.php +++ b/misc/generateVisitsData/Referers.php @@ -34,7 +34,6 @@ $referers = array( "http://www.google.fr/search?hl=fr&rls=GFRC%2CGFRC%3A2007-03%2CGFRC%3Afr&q=mesure audience sites&meta=", "http://www.phpmyvisites.net/", "http://www.google.fr/search?hl=fr&q=phpmyvisit&btnG=Recherche Google&meta=", -"http://www.web-analytique.com/les-interviews/interview--matthieu-aubry-createur-de-phpmyvisites.html", "http://www.scriptdungeon.com/script.php?ScriptID=888", "http://www.google.ca/search?hl=fr&q=free web creation&meta=", "http://www.phpmyvisites.net/phpmv2/index.php?lang=fa-utf-8.php&mod=view_visits&site=1&adminsite=1&date=2007-03-19&period=1&action=", diff --git a/modules/API/Request.php b/modules/API/Request.php index 6b9f2cdcd2..7f45ba91ff 100644 --- a/modules/API/Request.php +++ b/modules/API/Request.php @@ -136,9 +136,7 @@ class Piwik_API_Request $toReturn = $this->getRenderedDataTable($dataTable); } - - - if(!is_array($toReturn) // an empty array is not considered as "nothing has been returned" + elseif(!is_array($toReturn) // an empty array is not considered as "nothing has been returned" && empty($toReturn)) { $format = Piwik_Common::getRequestVar('format', 'xml', 'string', $this->requestToUse); diff --git a/modules/Archive.php b/modules/Archive.php index 71935e888b..98efe1591d 100644 --- a/modules/Archive.php +++ b/modules/Archive.php @@ -273,14 +273,14 @@ class Piwik_Archive $table = new Piwik_DataTable_Simple; $table->loadFromArray($values); - return $table; } public function getNumeric( $name ) { - return $this->get($name, 'numeric'); + // we caste the result as float because returns false when no visitors + return (float)$this->get($name, 'numeric'); } public function getBlob( $name ) diff --git a/modules/LogStats/Visit.php b/modules/LogStats/Visit.php index 6d84a22434..a2ea9c21c3 100644 --- a/modules/LogStats/Visit.php +++ b/modules/LogStats/Visit.php @@ -791,6 +791,6 @@ class Piwik_LogStats_Visit return Piwik_Common::generateUniqId(); } } - + } diff --git a/modules/PluginsManager.php b/modules/PluginsManager.php index 5a97bd6d63..df62a30ce1 100644 --- a/modules/PluginsManager.php +++ b/modules/PluginsManager.php @@ -116,7 +116,7 @@ class Piwik_PluginsManager // . $this->pluginsPath // . $this->pluginsCategory $pluginFileName; - + //TODO bug here should be NOT if(is_file($path)) { throw new Exception("The plugin file $path couldn't be found."); @@ -124,6 +124,7 @@ class Piwik_PluginsManager require_once $path; + //TODO bug here should be NOT if($pluginClassName instanceof Piwik_Plugin) { throw new Exception("The plugin $pluginClassName in the file $path must inherit from Piwik_Plugin."); @@ -141,8 +142,7 @@ class Piwik_PluginsManager } if($this->doLoadPlugins) - { - + { $newPlugin->registerTranslation( $this->languageToLoad ); $this->addPluginObservers( $newPlugin ); $this->addLoadedPlugin($pluginName); diff --git a/modules/ViewDataTable/GenerateGraphData.php b/modules/ViewDataTable/GenerateGraphData.php index efafc16d11..5da9d04ed0 100644 --- a/modules/ViewDataTable/GenerateGraphData.php +++ b/modules/ViewDataTable/GenerateGraphData.php @@ -41,35 +41,43 @@ class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable } - $this->setDefaultLimit( $view->getDefaultLimit() ); - + $this->setDefaultLimit( $view->getDefaultLimit() ); $this->loadDataTableFromAPI(); - // We apply a filter to the DataTable, decoding the label column (useful for keywords for example) - $filter = new Piwik_DataTable_Filter_ColumnCallbackReplace( - $this->dataTable, - 'label', - 'urldecode' - ); - - foreach($this->dataTable->getRows() as $row) + + $this->dataAvailable = $this->dataTable->getRowsCount() != 0; + + if(!$this->dataAvailable) { - $label = $row->getColumn('label'); - $value = $row->getColumn('nb_unique_visitors'); - // case no unique visitors - if($value === false) + $view->title("No data for this graph", '{font-size: 25px;}'); + } + else + { + // We apply a filter to the DataTable, decoding the label column (useful for keywords for example) + $filter = new Piwik_DataTable_Filter_ColumnCallbackReplace( + $this->dataTable, + 'label', + 'urldecode' + ); + $data = array(); + foreach($this->dataTable->getRows() as $row) { - $value = $row->getColumn('nb_visits'); + $label = $row->getColumn('label'); + $value = $row->getColumn('nb_unique_visitors'); + // case no unique visitors + if($value === false) + { + $value = $row->getColumn('nb_visits'); + } + $data[] = array( + 'label' => $label, + 'value' => $value, + 'url' => $row->getDetail('url'), + ); } - $data[] = array( - 'label' => $label, - 'value' => $value, - 'url' => $row->getDetail('url'), - ); + $view->setData($data); + $view->customizeGraph(); } - $view->setData($data); - $view->customizeGraph(); - $this->view = $view; } diff --git a/modules/ViewDataTable/Graph.php b/modules/ViewDataTable/Graph.php index bb6cf2f608..786d6a31d4 100644 --- a/modules/ViewDataTable/Graph.php +++ b/modules/ViewDataTable/Graph.php @@ -26,6 +26,8 @@ class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable } $this->mainAlreadyExecuted = true; + + $view = new Piwik_View($this->dataTableTemplate); $this->id = $this->getUniqIdTable(); $view->id = $this->id; diff --git a/modules/Visualization/Chart.php b/modules/Visualization/Chart.php index b1cdad994f..cd6670b84d 100644 --- a/modules/Visualization/Chart.php +++ b/modules/Visualization/Chart.php @@ -17,7 +17,16 @@ abstract class Piwik_Visualization_Chart extends Piwik_Visualization_OpenFlashCh $label[] = $row['label']; $data[] = $row['value']; } - $max = max($data); + + // case no data + if(count($data) == 0) + { + $max = 0; + } + else + { + $max = max($data); + } $this->arrayData = $data; $this->arrayLabel = $label; diff --git a/modules/Visualization/OpenFlashChart.php b/modules/Visualization/OpenFlashChart.php index fe85d348b7..1001f61d66 100644 --- a/modules/Visualization/OpenFlashChart.php +++ b/modules/Visualization/OpenFlashChart.php @@ -1,8 +1,8 @@ <?php
require_once "iView.php";
+// Original class provided by Open Flash Chart
abstract class Piwik_Visualization_OpenFlashChart implements iView
{
- // Original class provided by Open Flash Chart
function __construct()
{
$this->data = array();
diff --git a/openads_piwik_plugin.php b/openads_piwik_plugin.php new file mode 100644 index 0000000000..122ac20a7d --- /dev/null +++ b/openads_piwik_plugin.php @@ -0,0 +1,235 @@ +<?php + +class Piwik_Openads_Plugin +{ + /** + * Returns an array associating the hook name to the method to call + * + * @return array array("hookToListenTo" => "methodNameToTrigger") + */ + function getListHooksRegistered() + { + return array( + // publishers + "openAds.insertPublisher" => "insertWebsite", + "openAds.deletePublisher" => "deleteWebsite", + "openAds.updatePublisher" => "updateWebsite", + + // users + "openAds.insertPublisher" => "insertUser", + "openAds.insertPublisher" => "deleteUser", + "openAds.updatePublisher" => "updateUser", + + ); + } + + /** + * Methods triggered on the Openads DLL events + */ +// function insertWebsite( $parameters ) +// function deleteWebsite( $parameters ) +// function updateWebsite( $parameters ) +// function insertUser( $parameters ) +// function deleteUser( $parameters ) +// function updateUser( $parameters ) + + /** + * Function called statically by the Openads-Piwik delivery engine plugin + * Returns the javascript to print in the HEAD + * + * @param int The publisher ID in openads + * @return string A javascript code or the empty string + */ + function getJavascriptTag( $openadsPublisherId ) + { + // reads the $piwikUrl from the Piwik Config file + // if not available, returns empty string as it means piwik is not installed + + // The mapping is applied as follows + // Piwik_SiteId from the openads PublisherId + + } + + + /** + * Function called statically within Piwik at the end of the installation process + * + * Returns a value from the Openads config file. + * This function is called either from openads or it can be called from piwik directly, + * without the Openads initialization process. + * So this function must load the config file if it is not already loaded. + * + * @param string Name of the config variable to return + * @param string Optional category name containing the config variable to return + * + * @return string + * + * ------------------------- + * Example: + * + * #config file + * [adminPlugins] + * piwik = piwik/example.php + * + * Piwik_Openads_Plugin::getOpenadsConfigurationValue('piwik', 'adminPlugins') returns 'piwik/example.php' + * + */ + function getOpenadsConfigurationValue($valueName, $valueCategory = null) + { + + } + + + /** + * + * Function called statically within Piwik at the end of the installation process + * + * Set a value from the Openads config file. + * This function is called either from openads or it can be called from piwik directly, + * without the Openads initialization process. + * So this function must load the config file if it is not already loaded. + * + * @param string Name of the value to set + * @param string Optional category name containing the config var to return + * + * @return string + * + * ------------------------- + * Example: + * Piwik_Openads_Plugin::setOpenadsConfigurationValue('adminPlugins', 'piwik', 'piwik/example.php') + * add the following lines in the configuration file (or modify the existing value for this variable) + * + * [adminPlugins] + * piwik = piwik/example.php + * + * + */ + function setOpenadsConfigurationValue($variableCategory, $variableName, $value) + { + + } + + /** + * Function called statically within Piwik at the end of the installation process + * + * Returns the openads database information + * - host + * - login + * - password + * - Database name + * + * @return array The array of values array( + * 'host' => "localhost", + * 'login' => "mysqlUser", + * 'password' => "passwordUser", + * 'database_name' => "openads_db", + * ); + */ + function getOpenadsDatabaseInformation() + { + + } + + /** + * Function called statically within Piwik at the end of the installation process + * Returns the login of the OpenAds super user + * + * @return string + */ + function getOpenadsSuperUserInformation() + { + + } + + /** + * Function called statically within Piwik at the end of the installation process. + * + * Returns an array containing all the Openads users login & piwik access information + * + * This method does the mapping between the openads permission system and piwik permission system + * For a given user, we return an array containing, for the list of publishersId, the permission + * + * The permission is one of the following value + * - view + * - admin + * + * The mapping between openads and piwik is as follows + * - maps to "view" in piwik + * - maps to "admin" in piwik + * - maps to No Access in piwik (no access set) + * + * Example: + * The user 'radek' in Openads is a publisher for the publisherId = 4. + * He is also X for the publisherId = 12 + * + * "radek" => array( 4 => "view", 12 => "admin") + * + * @return array Returns array( + * "loginUser1" => array ( openadsPubliserId_1 => piwikAccessForThisPublisher + * ), + * "loginUser2" => array ( openadsPubliserId_34 => piwikAccessForThisPublisher, + * openadsPubliserId_27 => piwikAccessForThisPublisher ) + * ), + * ) + */ + function getAllOpenadsUsersInformation() + { + + } + + + /** + * Function called statically within Piwik at the end of the installation process + * + * Returns an array containing all the Openads websites ID & main Url + * + * @return array Returns array( + * array('id' => 1, 'url' => 'http://www.example.com') + * array('id' => 65, 'url' => 'http://www.example2.com') + * ) + */ + function getAllOpenadsWebsitesInformation() + { + + } + + + /** + * Function called statically within Piwik when trying to authenticate the user + * + * Returns the current logged OpenAds user + * + * @return string User login of the currently logged user. + * Returns empty string if no user is authenticated. + * + */ + function getCurrentlyAuthenticatedUserLogin() + { + + } + + /** + * Redirect the current page to the Piwik/index.php if we find the files + * - Piwik/index.php + * - Piwik/plugins/OpenadsIntegration.php + * + * If we don't find the files we display a nice message explaining what to do to the users + * - We tell them where to download the package with the openads plugin + * - Once they have uploaded the package on this server, + * they give us the path to the package. + * - We save this path in the openads configuration file + * - We redirect to this same page so it checks if now the files are available + */ + function redirectToPiwikIfAvailable() + { + print("redirecting..."); + } + +} + +// if we call this script directly then we call the conditional redirect method +if( basename($_SERVER['PHP_SELF']) == basename(__FILE__)) +{ + Piwik_Openads_Plugin::redirectToPiwikIfAvailable(); +} + diff --git a/piwik openads integration.odt b/piwik openads integration.odt Binary files differindex 4e06a0ff65..c9bd1c5723 100644 --- a/piwik openads integration.odt +++ b/piwik openads integration.odt diff --git a/plugins/UserSettings/templates/graph.tpl b/plugins/UserSettings/templates/graph.tpl index 4d6e52cddb..c49fe79b8d 100644 --- a/plugins/UserSettings/templates/graph.tpl +++ b/plugins/UserSettings/templates/graph.tpl @@ -14,5 +14,6 @@ type="text"> </form> </small> + {include file="UserSettings/templates/datatable_footer.tpl"} </div>
\ No newline at end of file |