Skip to content
Snippets Groups Projects
Commit ac875918 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #62616 : do not specify protocol in piwik dashboard url

parent af13f8db
Branches
Tags
4 merge requests!2334Master,!2269Master,!2268Hotline master,!2262Hotline#62616 piwik accessible sur portail en http pas en https
Pipeline #2140 failed with stage
in 11 minutes and 58 seconds
- ticket #62616 : Administration : Correction de l'affichage du tableau de bord Piwik dans un Bokeh accédé en https
\ No newline at end of file
......@@ -50,28 +50,27 @@ class Class_AdminVar_JsStat {
public function getPiwikUrl() {
$script = Class_AdminVar::get('JS_STAT');
preg_match_all("/var u=.*(\/\/[^\"]+)\"/i", $script, $matches);
return isset($matches[1][0])
? ('http:' . trim($matches[1][0]))
: '';
return $this->_extractFromJsStat("/var u=.*(\/\/[^\"]+)\"/i", 1);
}
protected function _getGoogleAnalyticsId() {
$script = Class_AdminVar::get('JS_STAT');
preg_match_all("/(UA|MO)-[0-9]+-[0-9]/", $script, $matches);
return (isset($matches[0][0]))
? $matches[0][0]
: '';
return $this->_extractFromJsStat("/(UA|MO)-[0-9]+-[0-9]/", 0);
}
protected function _getPiwikSiteId() {
$script = Class_AdminVar::get('JS_STAT');
preg_match_all("/setSiteId\',([^\]]+)\]\)/i", $script, $matches);
return isset($matches[1][0]) ? trim($matches[1][0]) : '';
return $this->_extractFromJsStat("/setSiteId\',([^\]]+)\]\)/i", 1);
}
}
?>
\ No newline at end of file
protected function _extractFromJsStat($pattern, $match_index) {
preg_match($pattern,
Class_AdminVar::get('JS_STAT'),
$matches);
return isset($matches[$match_index])
? trim($matches[$match_index])
: '';
}
}
\ No newline at end of file
......@@ -18,9 +18,10 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AdminAbstractControllerTestCase.php';
class Admin_StatControllerRecherchesInfructueusesTest extends Admin_AbstractControllerTestCase {
class Admin_StatControllerRecherchesInfructueusesTest
extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
......@@ -64,4 +65,101 @@ class Admin_StatControllerRecherchesInfructueusesTest extends Admin_AbstractCont
$this->assertXPathContentContains('//h4', 'Nombre de recherches infructueuse : 2');
}
}
?>
\ No newline at end of file
class Admin_StatControllerPiwikActionTest
extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('PIWIK_AUTH_TOKEN', 'anierstauie-ua/ive');
Class_AdminVar::set('JS_STAT', '<!-- Piwik -->
<script type="text/javascript">
try {
var url = window.location.href ;
var _paq = _paq || [];
if ( (url.match ( new RegExp ( "/recherche/" ) )) && ($(\'.resultats_page\').length)) {
var customvartitle_total = "nombre de résultats" ;
var customvartitle_type = "type de recherche" ;
var customvartitle_motif = "motif de recherche" ;
var customvartitle_facette = "facettes de recherche" ;
var customvartitle_page = "page" ;
var customvarvalue_total;
var customvarvalue_type;
var customvarvalue_motif;
var customvarvalue_facette;
var customvarvalue_page;
if ($(\'.resultats_page .nombre-recherche\').length) {
var customvarvalue_total = $(\'.resultats_page .nombre-recherche\').html();
var regexcustomvarvalue_total = /\D/g ;
customvarvalue_total = customvarvalue_total.replace ( regexcustomvarvalue_total , \'\' ) ;
} else {
var customvarvalue_total = "zéro";
}
if (url.match ( new RegExp ( "expressionRecherche" ) )) {
var customvarvalue_type = "simple" ;
} else {
var customvarvalue_type = "avancée" ;
}
if (customvarvalue_type == "simple") {
if ($(\'.resultats_page .expression-recherche\').length) {
var customvarvalue_motif = $(\'.resultats_page .expression-recherche\').text();
}
if ($(\'.resultats_page .criteres_recherche\').length) {
//var customvarvalue_facette = $(\'.resultats_page .criteres_recherche\').text();
customvarvalue_facette = $(\'.resultats_page .criteres_recherche\').html();
var regexaddsep = /<img/g ;
customvarvalue_facette = customvarvalue_facette.replace ( regexaddsep , \'&nbsp;,&nbsp;<img\' ) ;
customvarvalue_facette = $(customvarvalue_facette).text();
customvarvalue_facette = customvarvalue_facette.replace(/\s,\s$/,\'\');
}
}
else if (customvarvalue_type == "avancée") {
if ($(\'.resultats_page .criteres_recherche\').length) {
//var customvarvalue_motif = $(\'.resultats_page .criteres_recherche\').text();
customvarvalue_motif = $(\'.resultats_page .criteres_recherche\').html();
var regexaddsep = /<img/g ;
customvarvalue_motif = customvarvalue_motif.replace ( regexaddsep , \'&nbsp;,&nbsp;<img\' ) ;
customvarvalue_motif = $(customvarvalue_motif).text();
customvarvalue_motif = customvarvalue_motif.replace(/\s,\s$/,\'\');
}
}
var regexcustomvarvalue_page = /\/page\/(\d+)/;
if (url.match ( new RegExp ( regexcustomvarvalue_page ) )) {
regexcustomvarvalue_page.exec(url);
customvarvalue_page=RegExp.$1;
}
if ( customvarvalue_total ) {_paq.push([\'setCustomVariable\', 1, customvartitle_total, customvarvalue_total, \'page\']);}
if ( customvarvalue_type ) {_paq.push([\'setCustomVariable\', 2, customvartitle_type, customvarvalue_type, \'page\']);}
if ( customvarvalue_motif ) {_paq.push([\'setCustomVariable\', 3, customvartitle_motif, customvarvalue_motif, \'page\']);}
if ( customvarvalue_facette ) {_paq.push([\'setCustomVariable\', 4, customvartitle_facette, customvarvalue_facette, \'page\']);}
if ( customvarvalue_page ) {_paq.push([\'setCustomVariable\', 5, customvartitle_page, customvarvalue_page, \'page\']);}
}
_paq.push([\'trackPageView\']);
_paq.push([\'enableLinkTracking\']);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.server.st/";
_paq.push([\'setTrackerUrl\', u+\'piwik.php\']);
_paq.push([\'setSiteId\', 9999]);
var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0]; g.type=\'text/javascript\';
g.defer=true; g.async=true; g.src=u+\'piwik.js\'; s.parentNode.insertBefore(g,s);
})();
} catch ( err ) {}
</script>
<noscript><p><img src="http://piwik.server.st/piwik.php?idsite=9999" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->');
$this->dispatch('/admin/stat/piwik', true);
}
/** @test */
public function iframeSrcShouldNotContainsProtocol() {
$this->assertXPath('//iframe[starts-with(@src, "//piwik.server.st")]',
$this->_response->getBody());
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment