Пример #1
0
 public function render()
 {
     $idSite = Common::getRequestVar('idSite');
     $site = new Site($idSite);
     $url = urldecode(Common::getRequestVar('url', '', 'string'));
     if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
         $url = 'http://' . $url;
     }
     if (empty($url) || !UrlHelper::isLookLikeUrl($url)) {
         $url = $site->getMainUrl();
     }
     $dataTable = API::getInstance()->getRank($url);
     /** @var \Piwik\DataTable\Renderer\Php $renderer */
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     return $this->renderTemplate('getRank', array('urlToRank' => Url::getHostFromUrl($url), 'ranks' => $renderer->render($dataTable)));
 }
Пример #2
0
 /**
  * tell us when the API is broken
  *
  * @group Plugins
  */
 public function test_API()
 {
     try {
         $dataTable = API::getInstance()->getRank('http://www.microsoft.com/');
     } catch (Exception $e) {
         $this->markTestSkipped('A SEO http request failed, Skipping this test for now. Error was: ' . $e->getMessage());
     }
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     $ranks = $renderer->render($dataTable);
     foreach ($ranks as $rank) {
         $message = $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']';
         if (empty($rank['rank'])) {
             $this->markTestSkipped("Skipped to avoid random build failure: " . $message);
         }
         $this->assertNotEmpty($rank['rank'], $message);
     }
 }
Пример #3
0
 function getRank()
 {
     $idSite = Common::getRequestVar('idSite');
     $site = new Site($idSite);
     $url = urldecode(Common::getRequestVar('url', '', 'string'));
     if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
         $url = 'http://' . $url;
     }
     if (empty($url) || !UrlHelper::isLookLikeUrl($url)) {
         $url = $site->getMainUrl();
     }
     $dataTable = API::getInstance()->getRank($url);
     $view = new View('@SEO/getRank');
     $view->urlToRank = RankChecker::extractDomainFromUrl($url);
     /** @var \Piwik\DataTable\Renderer\Php $renderer */
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     $view->ranks = $renderer->render($dataTable);
     return $view->render();
 }