本文整理汇总了PHP中Piwik\Url类的典型用法代码示例。如果您正苦于以下问题:PHP Url类的具体用法?PHP Url怎么用?PHP Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
$this->requireFixtureFiles($input);
$this->setIncludePathAsInTestBootstrap();
$host = Url::getHost();
if (empty($host)) {
Url::setHost('localhost');
}
$fixture = $this->createFixture($input);
$this->setupDatabaseOverrides($input, $fixture);
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$fixture->getTestEnvironment()->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
if ($input->getOption('set-phantomjs-symlinks')) {
$this->createSymbolicLinksForUITests();
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
$sqlDumpPath = $input->getOption('sqldump');
if ($sqlDumpPath) {
$this->createSqlDump($sqlDumpPath, $output);
}
}
示例2: renderTable
/**
* Computes the output for the given data table
*
* @param DataTable $table
* @return string
* @throws Exception
*/
protected function renderTable($table)
{
if (!$table instanceof DataTable\Map || $table->getKeyName() != 'date') {
throw new Exception("RSS feeds can be generated for one specific website &idSite=X." . "\nPlease specify only one idSite or consider using &format=XML instead.");
}
$idSite = Common::getRequestVar('idSite', 1, 'int');
$period = Common::getRequestVar('period');
$piwikUrl = Url::getCurrentUrlWithoutFileName() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getDataTables(), true);
foreach ($moreRecentFirst as $date => $subtable) {
/** @var DataTable $subtable */
$timestamp = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->getTimestamp();
$site = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_SITE_INDEX);
$pudDate = date('r', $timestamp);
$dateInSiteTimezone = Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d');
$thisPiwikUrl = Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
$siteName = $site->getName();
$title = $siteName . " on " . $date;
$out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
$out .= Common::sanitizeInputValue($this->renderDataTable($subtable));
$out .= "</description>\n\t</item>\n";
}
$header = $this->getRssHeader();
$footer = $this->getRssFooter();
return $header . $out . $footer;
}
示例3: __construct
public function __construct($username)
{
$this->username = $username;
$this->title = 'Piwik - ' . Url::getCurrentHost();
$this->description = Piwik::getCurrentUserLogin();
$this->load();
}
示例4: setUp
public function setUp()
{
parent::setup();
File::reset();
Url::setHost(false);
$this->output = new Output('myid');
}
示例5: check
/**
* Check for a newer version
*
* @param bool $force Force check
* @param int $interval Interval used for update checks
*/
public static function check($force = false, $interval = null)
{
if (!self::isAutoUpdateEnabled()) {
return;
}
if ($interval === null) {
$interval = self::CHECK_INTERVAL;
}
$lastTimeChecked = Option::get(self::LAST_TIME_CHECKED);
if ($force || $lastTimeChecked === false || time() - $interval > $lastTimeChecked) {
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Option::set(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
$parameters = array('piwik_version' => Version::VERSION, 'php_version' => PHP_VERSION, 'url' => Url::getCurrentUrlWithoutQueryString(), 'trigger' => Common::getRequestVar('module', '', 'string'), 'timezone' => API::getInstance()->getDefaultTimezone());
$url = Config::getInstance()->General['api_service_url'] . '/1.0/getLatestVersion/' . '?' . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
if (@Config::getInstance()->Debug['allow_upgrades_to_beta']) {
$url = 'http://builds.piwik.org/LATEST_BETA';
}
try {
$latestVersion = Http::sendHttpRequest($url, $timeout);
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
$latestVersion = '';
}
} catch (Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
$latestVersion = '';
}
Option::set(self::LATEST_VERSION, $latestVersion);
}
}
示例6: getRank
/**
* Returns SEO statistics for a URL.
*
* @param string $url URL to request SEO stats for
* @return DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$metricProvider = new ProviderCache(new Aggregator());
$domain = Url::getHostFromUrl($url);
$metrics = $metricProvider->getMetrics($domain);
return $this->toDataTable($metrics);
}
示例7: test_getUrlToCheckForLatestAvailableVersion
public function test_getUrlToCheckForLatestAvailableVersion()
{
$version = Version::VERSION;
$phpVersion = urlencode(PHP_VERSION);
$url = urlencode(Url::getCurrentUrlWithoutQueryString());
$urlToCheck = $this->channel->getUrlToCheckForLatestAvailableVersion();
$this->assertStringStartsWith("http://api.piwik.org/1.0/getLatestVersion/?piwik_version={$version}&php_version={$phpVersion}&release_channel=my_channel&url={$url}&trigger=&timezone=", $urlToCheck);
}
示例8: addReport
/**
* Adds a report to the list of reports to display.
*
* @param string $category The report's category. Can be a i18n token.
* @param string $title The report's title. Can be a i18n token.
* @param string $action The controller action used to load the report, ie, Referrers.getAll
* @param array $params The list of query parameters to use when loading the report.
* This list overrides query parameters currently in use. For example,
* array('idSite' => 2, 'viewDataTable' => 'goalsTable')
* would mean the goals report for site w/ ID=2 will always be loaded.
*/
public function addReport($category, $title, $action, $params = array())
{
list($module, $action) = explode('.', $action);
$params = array('module' => $module, 'action' => $action) + $params;
$categories = $this->dimensionCategories;
$categories[$category][] = array('title' => $title, 'params' => $params, 'url' => Url::getCurrentQueryStringWithParametersModified($params));
$this->dimensionCategories = $categories;
}
示例9: saveLanguage
/**
* anonymous = in the session
* authenticated user = in the session
*/
public function saveLanguage()
{
$language = Common::getRequestVar('language');
// Prevent CSRF only when piwik is not installed yet (During install user can change language)
if (DbHelper::isInstalled()) {
$this->checkTokenInUrl();
}
LanguagesManager::setLanguageForSession($language);
Url::redirectToReferrer();
}
示例10: 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
* @internal param $
* @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)
{
Piwik::checkUserHasViewAccess($idSite);
if (empty($piwikUrl)) {
$piwikUrl = Url::getCurrentUrlWithoutFileName();
}
$piwikUrl = Common::sanitizeInputValues($piwikUrl);
$htmlEncoded = Piwik::getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains, $groupPageTitlesByDomain, $mergeAliasUrls, $visitorCustomVariables, $pageCustomVariables, $customCampaignNameQueryParam, $customCampaignKeywordParam, $doNotTrack);
$htmlEncoded = str_replace(array('<br>', '<br />', '<br/>'), '', $htmlEncoded);
return $htmlEncoded;
}
示例11:
function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false)
{
if (!isset($attributes['action'])) {
$attributes['action'] = Url::getCurrentQueryString();
}
if (!isset($attributes['name'])) {
$attributes['name'] = $id;
}
parent::__construct($id, $method, $attributes, $trackSubmit);
$this->init();
}
示例12: initHostAndQueryString
/**
* @param InputInterface $input
*/
protected function initHostAndQueryString(InputInterface $input)
{
$_GET = array();
$hostname = $input->getOption('piwik-domain');
Url::setHost($hostname);
$query = $input->getArgument('url-query');
$query = UrlHelper::getArrayFromQueryString($query);
foreach ($query as $name => $value) {
$_GET[$name] = $value;
}
}
示例13: setTrustedHosts
/**
* @internal
*/
public function setTrustedHosts($trustedHosts)
{
Piwik::checkUserHasSuperUserAccess();
if (!Controller::isGeneralSettingsAdminEnabled()) {
throw new Exception('General settings admin is ont enabled');
}
if (!empty($trustedHosts)) {
Url::saveTrustedHostnameInConfig($trustedHosts);
Config::getInstance()->forceSave();
}
return true;
}
示例14: sendMail
private function sendMail($subject, $body)
{
$feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
$subject = '[ Feedback Feature - Piwik ] ' . $subject;
$body = Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n";
$mail = new Mail();
$mail->setFrom(Piwik::getCurrentUserEmail());
$mail->addTo($feedbackEmailAddress, 'Piwik Team');
$mail->setSubject($subject);
$mail->setBodyText($body);
@$mail->send();
}
示例15: setFrom
/**
* Sets the sender.
*
* @param string $email Email address of the sender.
* @param null|string $name Name of the sender.
* @return Zend_Mail
*/
public function setFrom($email, $name = null)
{
$hostname = Config::getInstance()->mail['defaultHostnameIfEmpty'];
$piwikHost = Url::getCurrentHost($hostname);
// If known Piwik URL, use it instead of "localhost"
$piwikUrl = SettingsPiwik::getPiwikUrl();
$url = parse_url($piwikUrl);
if (isset($url['host']) && $url['host'] != 'localhost' && $url['host'] != '127.0.0.1') {
$piwikHost = $url['host'];
}
$email = str_replace('{DOMAIN}', $piwikHost, $email);
return parent::setFrom($email, $name);
}