Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
commit5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch)
tree5f30daf7bc14373fb1bbd0504ce11a771dafc02f /plugins/ExamplePlugin
parentae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff)
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'plugins/ExamplePlugin')
-rw-r--r--plugins/ExamplePlugin/Controller.php16
-rw-r--r--plugins/ExamplePlugin/ExamplePlugin.php6
2 files changed, 12 insertions, 10 deletions
diff --git a/plugins/ExamplePlugin/Controller.php b/plugins/ExamplePlugin/Controller.php
index 3e6c557130..0bebd89e57 100644
--- a/plugins/ExamplePlugin/Controller.php
+++ b/plugins/ExamplePlugin/Controller.php
@@ -10,12 +10,14 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Controller;
+use Piwik\View;
/**
*
* @package Piwik_ExamplePlugin
*/
-class Piwik_ExamplePlugin_Controller extends Piwik_Controller
+class Piwik_ExamplePlugin_Controller extends Controller
{
/**
* Go to /piwik/?module=ExamplePlugin&action=helloWorld to execute this method
@@ -54,7 +56,7 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller
*/
public function piwikDownloads()
{
- $view = new Piwik_View('@ExamplePlugin/piwikDownloads');
+ $view = new View('@ExamplePlugin/piwikDownloads');
$this->setGeneralVariablesView($view);
echo $view->render();
}
@@ -81,7 +83,7 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller
$out .= '<h3>Misc</h3>';
$out .= '<code>Piwik_AddMenu( $mainMenuName, $subMenuName, $url );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L76">UserCountry Plugin file</a>)<br />';
- $out .= '<code>Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />';
+ $out .= '<code>WidgetsList::add( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />';
$out .= '<code>Common::prefixTable("site")</code> = <b>' . Common::prefixTable("site") . '</b><br />';
@@ -94,15 +96,15 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller
$out .= '<h2>Execute SQL queries</h2>';
$txtQuery = "SELECT token_auth FROM " . Common::prefixTable('user') . " WHERE login = ?";
- $result = Piwik_FetchOne($txtQuery, array('anonymous'));
- $out .= '<code>Piwik_FetchOne("' . $txtQuery . '", array("anonymous"))</code> = <b>' . var_export($result, true) . '</b><br />';
+ $result = Db::fetchOne($txtQuery, array('anonymous'));
+ $out .= '<code>Db::fetchOne("' . $txtQuery . '", array("anonymous"))</code> = <b>' . var_export($result, true) . '</b><br />';
$out .= '<br />';
- $query = Piwik_Query($txtQuery, array('anonymous'));
+ $query = Db::query($txtQuery, array('anonymous'));
$fetched = $query->fetch();
$token_auth = $fetched['token_auth'];
- $out .= '<code>$query = Piwik_Query("' . $txtQuery . '", array("anonymous"))</code><br />';
+ $out .= '<code>$query = Db::query("' . $txtQuery . '", array("anonymous"))</code><br />';
$out .= '<code>$fetched = $query->fetch();</code><br />';
$out .= 'At this point, we have: <code>$fetched[\'token_auth\'] == <b>' . var_export($token_auth, true) . '</b></code><br />';
diff --git a/plugins/ExamplePlugin/ExamplePlugin.php b/plugins/ExamplePlugin/ExamplePlugin.php
index 7fc7a2cc09..bb7c968452 100644
--- a/plugins/ExamplePlugin/ExamplePlugin.php
+++ b/plugins/ExamplePlugin/ExamplePlugin.php
@@ -51,8 +51,8 @@ class Piwik_ExamplePlugin extends Plugin
{
// we register the widgets so they appear in the "Add a new widget" window in the dashboard
// Note that the first two parameters can be either a normal string, or an index to a translation string
- Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_exampleWidget', 'ExamplePlugin', 'exampleWidget');
- Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_photostreamMatt', 'ExamplePlugin', 'photostreamMatt');
- Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_piwikForumVisits', 'ExamplePlugin', 'piwikDownloads');
+ WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_exampleWidget', 'ExamplePlugin', 'exampleWidget');
+ WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_photostreamMatt', 'ExamplePlugin', 'photostreamMatt');
+ WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_piwikForumVisits', 'ExamplePlugin', 'piwikDownloads');
}
}