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:
authorLukas Winkler <github@lw1.at>2019-02-28 23:54:15 +0300
committerStefan Giehl <stefan@matomo.org>2019-02-28 23:54:15 +0300
commit8ac338d36bd3b3a7edaa5a5e4200e3a675235ffd (patch)
tree3e0c6cf5ab1d87a8ba57ba83b4e03bf06fa6debb /plugins/Referrers
parenta9e301f1afec4cafbd1a7f70e22b16a2963dcdce (diff)
remove getKeywordsForPageUrl widget (#14093)
* remove getKeywordsForPageUrl widget * fix tests * deprecate getKeywords... API * add to developer changelog * remove empty lines * improve deprecation message * fix test * fix test * fix tests * Update UI files
Diffstat (limited to 'plugins/Referrers')
-rw-r--r--plugins/Referrers/API.php7
-rw-r--r--plugins/Referrers/Controller.php121
-rw-r--r--plugins/Referrers/Widgets/GetKeywordsForPage.php23
3 files changed, 6 insertions, 145 deletions
diff --git a/plugins/Referrers/API.php b/plugins/Referrers/API.php
index ea12f4758c..3a7e19910e 100644
--- a/plugins/Referrers/API.php
+++ b/plugins/Referrers/API.php
@@ -24,7 +24,6 @@ use Piwik\Site;
* "getReferrerType" returns the Referrer overview report. "getCampaigns" returns the list of all campaigns (and all campaign keywords if the parameter &expanded=1 is set).
*
* The methods "getKeywordsForPageUrl" and "getKeywordsForPageTitle" are used to output the top keywords used to find a page.
- * Check out the widget <a href='http://demo.matomo.org/index.php?module=Widgetize&action=iframe&moduleToWidgetize=Referrers&actionToWidgetize=getKeywordsForPage&idSite=7&period=day&date=2011-02-15&disableLink=1' rel='noreferrer' target='_blank'>"Top keywords used to find this page"</a> that you can easily re-use on your website.
* @method static \Piwik\Plugins\Referrers\API getInstance()
*/
class API extends \Piwik\Plugin\API
@@ -195,6 +194,9 @@ class API extends \Piwik\Plugin\API
: $label;
}
+ /**
+ * @deprecated will be removed in Matomo 4.0.0
+ */
public function getKeywordsForPageUrl($idSite, $period, $date, $url)
{
// Fetch the Top keywords for this page
@@ -204,6 +206,9 @@ class API extends \Piwik\Plugin\API
return $this->getLabelsFromTable($table);
}
+ /**
+ * @deprecated will be removed in Matomo 4.0.0
+ */
public function getKeywordsForPageTitle($idSite, $period, $date, $title)
{
$segment = 'entryPageTitle==' . $title;
diff --git a/plugins/Referrers/Controller.php b/plugins/Referrers/Controller.php
index 367be3c9c9..99eed03f2c 100644
--- a/plugins/Referrers/Controller.php
+++ b/plugins/Referrers/Controller.php
@@ -356,127 +356,6 @@ class Controller extends \Piwik\Plugin\Controller
return $this->renderView($view);
}
- function getKeywordsForPage()
- {
- Piwik::checkUserHasViewAccess($this->idSite);
-
- $requestUrl = '&date=previous1'
- . '&period=week'
- . '&idSite=' . $this->idSite;
-
- $topPageUrlRequest = $requestUrl
- . '&method=Actions.getPageUrls'
- . '&filter_limit=50'
- . '&format=original';
- $request = new Request($topPageUrlRequest);
- $request = $request->process();
- /** @var $request Map */
- $tables = $request->getDataTables();;
-
- $topPageUrl = false;
- $first = key($tables);
- if (!empty($first)) {
- $topPageUrls = $tables[$first];
- $topPageUrls = $topPageUrls->getRowsMetadata('url');
- $tmpTopPageUrls = array_values($topPageUrls);
- $topPageUrl = current($tmpTopPageUrls);
- }
- if (empty($topPageUrl)) {
- $topPageUrl = $this->site->getMainUrl();
- }
- $url = $topPageUrl;
-
- // HTML
- $api = SettingsPiwik::getPiwikUrl()
- . '?module=API&method=Referrers.getKeywordsForPageUrl'
- . '&format=json'
- . '&filter_limit=10'
- . '&token_auth=' . Piwik::getCurrentUserTokenAuth();
-
- $api .= $requestUrl;
- $code = '
-// This function will call the API to get best keyword for current URL.
-// Then it writes the list of best keywords in a HTML list
-function DisplayTopKeywords($url = "")
-{
- // Do not spend more than 1 second fetching the data
- @ini_set("default_socket_timeout", $timeout = 1);
- // Get the Keywords data
- $url = empty($url) ? "http://". $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url;
- $api = "' . $api . '&url=" . urlencode($url);
- $keywords = @json_decode(file_get_contents($api), $assoc = true);
- Common::sendHeader(\'Content-Type: text/html; charset=utf-8\', true);
- if ($keywords === false || isset($keywords["result"])) {
- // DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
- // echo "Error while fetching the <a href=\'$api\'>Top Keywords from Piwik</a>";
- return;
- }
-
- // Display the list in HTML
- $url = htmlspecialchars($url, ENT_QUOTES, \'UTF-8\');
- $output = "<h2>Top Keywords for <a href=\'$url\'>$url</a></h2><ul>";
- foreach($keywords as $keyword) {
- $output .= "<li>". $keyword . "</li>";
- }
- if (empty($keywords)) { $output .= "Nothing yet..."; }
- $output .= "</ul>";
- echo $output;
-}
-';
-
- $jsonRequest = str_replace('format=php', 'format=json', $api);
- echo "<p style='padding: 0 12px;'>This widget is designed to work in your website directly.
- This widget makes it easy to use Piwik to <i>automatically display the list of Top Keywords</i>, for each of your website Page URLs.</p>
- <p style='padding: 0 12px;'>
- <b>Example API URL</b> - For example if you would like to get the top 10 keywords, used last week, to land on the page <a rel='noreferrer noopener' target='_blank' href='$topPageUrl'>$topPageUrl</a>,
- in format JSON: you would dynamically fetch the data using <a rel='noreferrer noopener' target='_blank' href='$jsonRequest&url=" . urlencode($topPageUrl) . "'>this API request URL</a>. Make sure you encode the 'url' parameter in the URL.</p>
-
- <p style='padding: 0 12px;'><b>PHP Function ready to use!</b> - If you use PHP on your website, we have prepared a small code snippet that you can copy paste in your Website PHP files. You can then simply call the function <code>DisplayTopKeywords();</code> anywhere in your template, at the bottom of the content or in your blog sidebar.
- If you run this code in your page $topPageUrl, it would output the following:";
-
- echo "<div style='width:400px;margin:10px 10px 0 10px;padding:10px;border:1px solid #333;'>";
- function DisplayTopKeywords($url = "", $api)
- {
- // Do not spend more than 1 second fetching the data
- @ini_set("default_socket_timeout", $timeout = 1);
- // Get the Keywords data
- $url = empty($url) ? "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url;
- $api = $api . "&url=" . urlencode($url);
- $keywords = @json_decode(file_get_contents($api), $assoc = true);
- Common::sendHeader('Content-Type: text/html; charset=utf-8', true);
- if ($keywords === false || isset($keywords["result"]) || !is_array($keywords)) {
- // DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
- //echo "Error while fetching the <a href=\'".$api."\'>Top Keywords from Piwik</a>";
- return;
- }
-
- // Display the list in HTML
- $url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
- $output = "<h2>Top Keywords for <a href=\'$url\'>$url</a></h2><ul>";
- foreach ($keywords as $keyword) {
- $output .= "<li>" . $keyword . "</li>";
- }
- if (empty($keywords)) {
- $output .= "Nothing yet...";
- }
- $output .= "</ul>";
- echo $output;
- }
-
- DisplayTopKeywords($topPageUrl, $api);
-
- echo "</div><br/>
- <p style='padding: 0 12px;'>Here is the PHP function that you can paste in your pages:</P>
- <textarea style='padding: 0 12px;height:auto;width:auto;margin-left:12px;' cols=60 rows=8>&lt;?php\n" . htmlspecialchars($code, ENT_COMPAT | ENT_HTML401, 'UTF-8') . "\n DisplayTopKeywords();</textarea>
- ";
-
- echo "
- <p style='padding: 12px;'><strong>Notes</strong>: You can for example edit the code to to make the Top search keywords link to your Website search result pages.
- <br/>On medium to large traffic websites, we recommend to cache this data, as to minimize the performance impact of calling the Piwik API on each page view.
- </p>
- ";
- }
-
/**
* Returns the i18n-ized label for a referrer type.
*
diff --git a/plugins/Referrers/Widgets/GetKeywordsForPage.php b/plugins/Referrers/Widgets/GetKeywordsForPage.php
deleted file mode 100644
index 165bb18f68..0000000000
--- a/plugins/Referrers/Widgets/GetKeywordsForPage.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * Piwik - free/libre analytics platform
- *
- * @link http://piwik.org
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
- *
- */
-namespace Piwik\Plugins\Referrers\Widgets;
-
-use Piwik\Widget\WidgetConfig;
-use Piwik\SettingsPiwik;
-
-class GetKeywordsForPage extends \Piwik\Widget\Widget
-{
- public static function configure(WidgetConfig $config)
- {
- $config->setCategoryId('SEO');
- $config->setName('Referrers_WidgetTopKeywordsForPages');
- $config->setIsEnabled(SettingsPiwik::isSegmentationEnabled());
- }
-
-}