getMainUrl() 공개 메소드

Returns the main url of the site.
public getMainUrl ( ) : string
리턴 string
예제 #1
0
파일: GetRank.php 프로젝트: piwik/piwik
 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
 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();
 }
예제 #3
0
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  * 
  * The following variables assigned:
  * 
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * 
  * As well as the variables set by {@link setPeriodVariablesView()}.
  * 
  * Will exit on error.
  * 
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->date = $this->strDate;
     try {
         $view->idSite = $this->idSite;
         if (empty($this->site) || empty($this->idSite)) {
             throw new Exception("The requested website idSite is not found in the request, or is invalid.\n\t\t\t\tPlease check that you are logged in Piwik and have permission to access the specified website.");
         }
         $this->setPeriodVariablesView($view);
         $rawDate = Common::getRequestVar('date');
         $periodStr = Common::getRequestVar('period');
         if ($periodStr != 'range') {
             $date = Date::factory($this->strDate);
             $period = Period\Factory::build($periodStr, $date);
         } else {
             $period = new Range($periodStr, $rawDate, $this->site->getTimezone());
         }
         $view->rawDate = $rawDate;
         $view->prettyDate = self::getCalendarPrettyDate($period);
         $view->siteName = $this->site->getName();
         $view->siteMainUrl = $this->site->getMainUrl();
         $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
         $minDate = Date::factory($datetimeMinDate, $this->site->getTimezone());
         $this->setMinDateView($minDate, $view);
         $maxDate = Date::factory('now', $this->site->getTimezone());
         $this->setMaxDateView($maxDate, $view);
         // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
         $dateStart = $period->getDateStart();
         if ($dateStart->isEarlier($minDate)) {
             $dateStart = $minDate;
         }
         $dateEnd = $period->getDateEnd();
         if ($dateEnd->isLater($maxDate)) {
             $dateEnd = $maxDate;
         }
         $view->startDate = $dateStart;
         $view->endDate = $dateEnd;
         $language = LanguagesManager::getLanguageForSession();
         $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
         $this->setBasicVariablesView($view);
         $view->topMenu = MenuTop::getInstance()->getMenu();
         $view->userMenu = MenuUser::getInstance()->getMenu();
         $notifications = $view->notifications;
         if (empty($notifications)) {
             $view->notifications = NotificationManager::getAllNotificationsToDisplay();
             NotificationManager::cancelAllNonPersistent();
         }
     } catch (Exception $e) {
         Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString());
     }
 }
예제 #4
0
파일: API.php 프로젝트: carriercomm/piwik
 /**
  * Returns the list of all URLs registered for the given idSite (main_url + alias URLs).
  *
  * @throws Exception if the website ID doesn't exist or the user doesn't have access to it
  * @param int $idSite
  * @return array list of URLs
  */
 public function getSiteUrlsFromId($idSite)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $site = new Site($idSite);
     $urls = $this->getAliasSiteUrlsFromId($idSite);
     return array_merge(array($site->getMainUrl()), $urls);
 }
예제 #5
0
파일: Controller.php 프로젝트: piwik/piwik
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  *
  * The following variables assigned:
  *
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  *
  * As well as the variables set by {@link setPeriodVariablesView()}.
  *
  * Will exit on error.
  *
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->idSite = $this->idSite;
     $this->checkSitePermission();
     $this->setPeriodVariablesView($view);
     $view->siteName = $this->site->getName();
     $view->siteMainUrl = $this->site->getMainUrl();
     $siteTimezone = $this->site->getTimezone();
     $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
     $minDate = Date::factory($datetimeMinDate, $siteTimezone);
     $this->setMinDateView($minDate, $view);
     $maxDate = Date::factory('now', $siteTimezone);
     $this->setMaxDateView($maxDate, $view);
     $rawDate = Common::getRequestVar('date');
     Period::checkDateFormat($rawDate);
     $periodStr = Common::getRequestVar('period');
     if ($periodStr != 'range') {
         $date = Date::factory($this->strDate);
         $validDate = $this->getValidDate($date, $minDate, $maxDate);
         $period = Period\Factory::build($periodStr, $validDate);
         if ($date->toString() !== $validDate->toString()) {
             // we to not always change date since it could convert a strDate "today" to "YYYY-MM-DD"
             // only change $this->strDate if it was not valid before
             $this->setDate($validDate);
         }
     } else {
         $period = new Range($periodStr, $rawDate, $siteTimezone);
     }
     // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
     $dateStart = $period->getDateStart();
     $dateStart = $this->getValidDate($dateStart, $minDate, $maxDate);
     $dateEnd = $period->getDateEnd();
     $dateEnd = $this->getValidDate($dateEnd, $minDate, $maxDate);
     if ($periodStr == 'range') {
         // make sure we actually display the correct calendar pretty date
         $newRawDate = $dateStart->toString() . ',' . $dateEnd->toString();
         $period = new Range($periodStr, $newRawDate, $siteTimezone);
     }
     $view->date = $this->strDate;
     $view->prettyDate = self::getCalendarPrettyDate($period);
     $view->prettyDateLong = $period->getLocalizedLongString();
     $view->rawDate = $rawDate;
     $view->startDate = $dateStart;
     $view->endDate = $dateEnd;
     $language = LanguagesManager::getLanguageForSession();
     $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->adminMenu = MenuAdmin::getInstance()->getMenu();
     $notifications = $view->notifications;
     if (empty($notifications)) {
         $view->notifications = NotificationManager::getAllNotificationsToDisplay();
         NotificationManager::cancelAllNonPersistent();
     }
 }