/** * @return Piwik_SEO_API */ public static function getInstance() { if (self::$instance == null) { self::$instance = new self(); } return self::$instance; }
function test_API() { $dataTable = Piwik_SEO_API::getInstance()->getRank('http://forum.piwik.org/'); $renderer = Piwik_DataTable_Renderer::factory('php'); $renderer->setSerialize(false); $ranks = $renderer->render($dataTable); foreach ($ranks as $rank) { $this->assertTrue(!empty($rank['rank']), $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']'); } }
/** * tell us when the API is broken * * @group Plugins * @group SEO */ public function test_API() { $dataTable = Piwik_SEO_API::getInstance()->getRank('http://www.microsoft.com/'); $renderer = Piwik_DataTable_Renderer::factory('php'); $renderer->setSerialize(false); $ranks = $renderer->render($dataTable); foreach ($ranks as $rank) { $this->assertNotEmpty($rank['rank'], $rank['id'] . ' expected non-zero rank, got [' . $rank['rank'] . ']'); } }
function getRank() { $idSite = Piwik_Common::getRequestVar('idSite'); $site = new Piwik_Site($idSite); $url = urldecode(Piwik_Common::getRequestVar('url', '', 'string')); if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) { $url = 'http://' . $url; } if (empty($url) || !Piwik_Common::isLookLikeUrl($url)) { $url = $site->getMainUrl(); } $dataTable = Piwik_SEO_API::getInstance()->getRank($url); $view = Piwik_View::factory('index'); $view->urlToRank = Piwik_SEO_RankChecker::extractDomainFromUrl($url); $renderer = Piwik_DataTable_Renderer::factory('php'); $renderer->setSerialize(false); $view->ranks = $renderer->render($dataTable); echo $view->render(); }
function getRank() { $idSite = Piwik_Common::getRequestVar('idSite'); $site = new Piwik_Site($idSite); $url = urldecode(Piwik_Common::getRequestVar('url', '', 'string')); if(empty($url) || @parse_url($url) === false) { $url = $site->getMainUrl(); } $dataTable = Piwik_SEO_API::getInstance()->getRank($url); $view = Piwik_View::factory('index'); $view->urlToRank = $url; $renderer = Piwik_DataTable_Renderer::factory('php'); $renderer->setSerialize(false); $view->ranks = $renderer->render($dataTable); echo $view->render(); }