当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik::getJavascriptCode方法代码示例

本文整理汇总了PHP中Piwik\Piwik::getJavascriptCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getJavascriptCode方法的具体用法?PHP Piwik::getJavascriptCode怎么用?PHP Piwik::getJavascriptCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Piwik的用法示例。


在下文中一共展示了Piwik::getJavascriptCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getJavascriptTag

 /**
  * Returns the javascript tag for the given idSite.
  * This tag must be included on every page to be tracked by Piwik
  *
  * @param int $idSite
  * @param string $piwikUrl
  * @param bool $mergeSubdomains
  * @param bool $groupPageTitlesByDomain
  * @param bool $mergeAliasUrls
  * @param bool $visitorCustomVariables
  * @param bool $pageCustomVariables
  * @param bool $customCampaignNameQueryParam
  * @param bool $customCampaignKeywordParam
  * @param bool $doNotTrack
  * @param bool $disableCookies
  * @return string The Javascript tag ready to be included on the HTML pages
  */
 public function getJavascriptTag($idSite, $piwikUrl = '', $mergeSubdomains = false, $groupPageTitlesByDomain = false, $mergeAliasUrls = false, $visitorCustomVariables = false, $pageCustomVariables = false, $customCampaignNameQueryParam = false, $customCampaignKeywordParam = false, $doNotTrack = false, $disableCookies = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     if (empty($piwikUrl)) {
         $piwikUrl = SettingsPiwik::getPiwikUrl();
     }
     $piwikUrl = Common::sanitizeInputValues($piwikUrl);
     $htmlEncoded = Piwik::getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain, $mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables, $customCampaignNameQueryParam, $customCampaignKeywordParam, $doNotTrack, $disableCookies);
     $htmlEncoded = str_replace(array('<br>', '<br />', '<br/>'), '', $htmlEncoded);
     return $htmlEncoded;
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:28,代码来源:API.php

示例2: trackingCode

 /**
  * Installation Step 7: Display JavaScript tracking code
  */
 public function trackingCode()
 {
     $this->checkPiwikIsNotInstalled();
     $this->markInstallationAsCompleted();
     $view = new View('@Installation/trackingCode', $this->getInstallationSteps(), __FUNCTION__);
     $siteName = Common::unsanitizeInputValue($this->getParam('site_name'));
     $idSite = $this->getParam('site_idSite');
     // Load the Tracking code and help text from the SitesManager
     $viewTrackingHelp = new \Piwik\View('@SitesManager/_displayJavascriptCode');
     $viewTrackingHelp->displaySiteName = $siteName;
     $viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName());
     $viewTrackingHelp->idSite = $idSite;
     $viewTrackingHelp->piwikUrl = Url::getCurrentUrlWithoutFileName();
     $view->trackingHelp = $viewTrackingHelp->render();
     $view->displaySiteName = $siteName;
     $view->displayfirstWebsiteSetupSuccess = true;
     $view->showNextStep = true;
     return $view->render();
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:22,代码来源:Controller.php

示例3: displayJavascriptCode

 /**
  * Displays the admin UI page showing all tracking tags
  * @return string
  */
 function displayJavascriptCode()
 {
     $idSite = Common::getRequestVar('idSite');
     Piwik::checkUserHasViewAccess($idSite);
     $jsTag = Piwik::getJavascriptCode($idSite, SettingsPiwik::getPiwikUrl());
     $view = new View('@SitesManager/displayJavascriptCode');
     $this->setBasicVariablesView($view);
     $view->idSite = $idSite;
     $site = new Site($idSite);
     $view->displaySiteName = $site->getName();
     $view->jsTag = $jsTag;
     return $view->render();
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:17,代码来源:Controller.php

示例4: displayJavascriptCode

 /**
  * Displays the admin UI page showing all tracking tags
  * @return string
  */
 function displayJavascriptCode()
 {
     $idSite = Common::getRequestVar('idSite');
     Piwik::checkUserHasViewAccess($idSite);
     $jsTag = Piwik::getJavascriptCode($idSite, SettingsPiwik::getPiwikUrl());
     $site = new Site($idSite);
     return $this->renderTemplate('displayJavascriptCode', array('idSite' => $idSite, 'displaySiteName' => $site->getName(), 'jsTag' => $jsTag));
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:12,代码来源:Controller.php

示例5: testJavascriptTrackingCode_withAllOptions

 /**
  * Tests the generated JS code
  * @group Core
  */
 public function testJavascriptTrackingCode_withAllOptions()
 {
     $jsTag = Piwik::getJavascriptCode($idSite = 1, $piwikUrl = 'http://localhost/piwik', $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", $doNotTrack = true);
     $expected = "&lt;!-- Piwik --&gt;\n&lt;script type=&quot;text/javascript&quot;&gt;\n  var _paq = _paq || [];\n  _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]);\n  // you can set up to 5 custom variables for each visitor\n  _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]);\n  _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]);\n  // you can set up to 5 custom variables for each action (page view, download, click, site search)\n  _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]);\n  _paq.push([\"setCampaignNameKey\", \"campaignKey\"]);\n  _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]);\n  _paq.push([\"setDoNotTrack\", true]);\n  _paq.push(['trackPageView']);\n  _paq.push(['enableLinkTracking']);\n  (function() {\n    var u=&quot;//localhost/piwik/&quot;;\n    _paq.push(['setTrackerUrl', u+'piwik.php']);\n    _paq.push(['setSiteId', 1]);\n    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];\n    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);\n  })();\n&lt;/script&gt;\n&lt;noscript&gt;&lt;p&gt;&lt;img src=&quot;//localhost/piwik/piwik.php?idsite=1&quot; style=&quot;border:0;&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;&lt;/noscript&gt;\n&lt;!-- End Piwik Code --&gt;\n";
     $this->assertEquals($expected, $jsTag);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:10,代码来源:PiwikTest.php

示例6: trackingCode

 /**
  * Installation Step 8: Display JavaScript tracking code
  */
 public function trackingCode()
 {
     $this->checkPreviousStepIsValid(__FUNCTION__);
     $view = new View('@Installation/trackingCode', $this->getInstallationSteps(), __FUNCTION__);
     $this->skipThisStep(__FUNCTION__);
     if (!isset($this->session->firstWebsiteSetupSuccessMessage)) {
         $view->displayfirstWebsiteSetupSuccess = true;
         $this->session->firstWebsiteSetupSuccessMessage = true;
     }
     $siteName = $this->session->site_name;
     $idSite = $this->session->site_idSite;
     // Load the Tracking code and help text from the SitesManager
     $viewTrackingHelp = new \Piwik\View('@SitesManager/_displayJavascriptCode');
     $viewTrackingHelp->displaySiteName = $siteName;
     $viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName());
     $viewTrackingHelp->idSite = $idSite;
     $viewTrackingHelp->piwikUrl = Url::getCurrentUrlWithoutFileName();
     $view->trackingHelp = $viewTrackingHelp->render();
     $view->displaySiteName = $siteName;
     $view->showNextStep = true;
     $this->session->currentStepDone = __FUNCTION__;
     return $view->render();
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:26,代码来源:Controller.php


注:本文中的Piwik\Piwik::getJavascriptCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。