本文整理汇总了PHP中Piwik_Url类的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Url类的具体用法?PHP Piwik_Url怎么用?PHP Piwik_Url使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Piwik_Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($action = '')
{
if (empty($action)) {
$action = Piwik_Url::getCurrentQueryString();
}
parent::HTML_QuickForm('form', 'POST', $action);
$this->registerRule('checkEmail', 'function', 'Piwik_Form_isValidEmailString');
$this->registerRule('fieldHaveSameValue', 'function', 'Piwik_Form_fieldHaveSameValue');
$this->init();
}
示例2: setGeneralVariablesView
protected function setGeneralVariablesView($view)
{
// date
$view->date = $this->strDate;
$oDate = new Piwik_Date($this->strDate);
$view->prettyDate = $oDate->getLocalized(Piwik_Translate('Home_LocalizedDateFormat'));
// period
$currentPeriod = Piwik_Common::getRequestVar('period');
$otherPeriodsAvailable = array('day', 'week', 'month', 'year');
$otherPeriodsNames = array('day' => Piwik_Translate('Home_PeriodDay'), 'week' => Piwik_Translate('Home_PeriodWeek'), 'month' => Piwik_Translate('Home_PeriodMonth'), 'year' => Piwik_Translate('Home_PeriodYear'));
$found = array_search($currentPeriod, $otherPeriodsAvailable);
if ($found !== false) {
unset($otherPeriodsAvailable[$found]);
}
$view->period = $currentPeriod;
$view->otherPeriods = $otherPeriodsAvailable;
$view->periodsNames = $otherPeriodsNames;
// other
$view->idSite = Piwik_Common::getRequestVar('idSite');
$view->userLogin = Piwik::getCurrentUserLogin();
$view->sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess();
$view->url = Piwik_Url::getCurrentUrl();
$view->menu = Piwik_GetMenu();
$view->menuJson = json_encode($view->menu);
//var_dump($view->menuJson);
}
示例3: renderTable
protected function renderTable($table)
{
if (!$table instanceof Piwik_DataTable_Array) {
throw new Exception("RSS Feed only used on DataTable_Array");
}
$idSite = Piwik_Common::getRequestVar('idSite', 1);
$period = Piwik_Common::getRequestVar('period');
$currentUrl = Piwik_Url::getCurrentUrlWithoutFileName();
$piwikUrl = $currentUrl . "?module=Home&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getArray(), true);
foreach ($moreRecentFirst as $date => $subtable) {
$timestamp = $table->metaData[$date]['timestamp'];
$site = $table->metaData[$date]['site'];
$pudDate = date('r', $timestamp);
$dateUrl = date('Y-m-d', $timestamp);
$thisPiwikUrl = htmlentities($piwikUrl . "&date={$dateUrl}");
$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 .= htmlspecialchars($this->renderDataTable($subtable));
$out .= "</description>\n\t</item>\n";
}
$header = $this->getRssHeader();
$footer = $this->getRssFooter();
return $this->output($header . $out . $footer);
}
示例4: renderTable
/**
* Computes the output for the given data table
*
* @param Piwik_DataTable $table
* @return string
* @throws Exception
*/
protected function renderTable($table)
{
if (!$table instanceof Piwik_DataTable_Array || $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 = Piwik_Common::getRequestVar('idSite', 1, 'int');
$period = Piwik_Common::getRequestVar('period');
$piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getArray(), true);
foreach ($moreRecentFirst as $date => $subtable) {
$timestamp = $table->metadata[$date]['timestamp'];
$site = $table->metadata[$date]['site'];
$pudDate = date('r', $timestamp);
$dateInSiteTimezone = Piwik_Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d');
$thisPiwikUrl = Piwik_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 .= Piwik_Common::sanitizeInputValue($this->renderDataTable($subtable));
$out .= "</description>\n\t</item>\n";
}
$header = $this->getRssHeader();
$footer = $this->getRssFooter();
return $header . $out . $footer;
}
示例5: setFrom
public function setFrom($email, $name = null)
{
$hostname = Zend_Registry::get('config')->mail->defaultHostnameIfEmpty;
$piwikHost = Piwik_Url::getCurrentHost($hostname);
$email = str_replace('{DOMAIN}', $piwikHost, $email);
parent::setFrom($email, $name);
}
示例6: check
/**
* Check for a newer version
*
* @param bool $force Force check
*/
public static function check($force = false)
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if($force || $lastTimeChecked === false
|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
{
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
$parameters = array(
'piwik_version' => Piwik_Version::VERSION,
'php_version' => PHP_VERSION,
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
'trigger' => Piwik_Common::getRequestVar('module','','string'),
'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
);
$url = Zend_Registry::get('config')->General->api_service_url;
$url .= '/1.0/getLatestVersion/';
$url .= '?' . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
Piwik_SetOption(self::LATEST_VERSION, '');
}
}
}
示例7: check
/**
* Check for a newer version
*/
public static function check()
{
$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
if($lastTimeChecked === false
|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
{
$parameters = array(
'piwik_version' => Piwik_Version::VERSION,
'php_version' => phpversion(),
'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
'trigger' => Piwik_Common::getRequestVar('module','','string'),
);
$url = self::PIWIK_HOST . "?" . http_build_query($parameters, '', '&');
$timeout = self::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik::sendHttpRequest($url, $timeout);
Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
} catch(Exception $e) {
// e.g., disable_functions = fsockopen; allow_url_open = Off
Piwik_SetOption(self::LATEST_VERSION, '');
}
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
}
}
示例8: sendFeedback
/**
* send email to Piwik team and display nice thanks
*/
function sendFeedback()
{
$email = Piwik_Common::getRequestVar('email', '', 'string');
$body = Piwik_Common::getRequestVar('body', '', 'string');
$category = Piwik_Common::getRequestVar('category', '', 'string');
$nonce = Piwik_Common::getRequestVar('nonce', '', 'string');
$view = Piwik_View::factory('sent');
$view->feedbackEmailAddress = Zend_Registry::get('config')->General->feedback_email_address;
try {
$minimumBodyLength = 35;
if (strlen($body) < $minimumBodyLength) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
}
if (!Piwik::isValidEmailString($email)) {
throw new Exception(Piwik_TranslateException('UsersManager_ExceptionInvalidEmail'));
}
if (preg_match('/https?:/i', $body)) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
}
if (!Piwik_Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
}
Piwik_Nonce::discardNonce('Piwik_Feedback.sendFeedback');
$mail = new Piwik_Mail();
$mail->setFrom(Piwik_Common::unsanitizeInputValue($email));
$mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
$mail->setSubject('[ Feedback form - Piwik ] ' . $category);
$mail->setBodyText(Piwik_Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Piwik_Version::VERSION . "\n" . 'IP: ' . Piwik_Common::getIpString() . "\n" . 'URL: ' . Piwik_Url::getReferer() . "\n");
@$mail->send();
} catch (Exception $e) {
$view->ErrorString = $e->getMessage();
$view->message = $body;
}
echo $view->render();
}
示例9: render
public function render()
{
try {
$this->currentModule = Piwik::getModule();
$this->currentPluginName = Piwik::getCurrentPlugin()->getName();
$this->userLogin = Piwik::getCurrentUserLogin();
$showWebsiteSelectorInUserInterface = Zend_Registry::get('config')->General->show_website_selector_in_user_interface;
if ($showWebsiteSelectorInUserInterface) {
$sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess();
usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
$this->sites = $sites;
}
$this->showWebsiteSelectorInUserInterface = $showWebsiteSelectorInUserInterface;
$this->url = Piwik_Url::getCurrentUrl();
$this->token_auth = Piwik::getCurrentUserTokenAuth();
$this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$this->userIsSuperUser = Piwik::isUserIsSuperUser();
$this->piwik_version = Piwik_Version::VERSION;
$this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable();
$this->loginModule = Zend_Registry::get('auth')->getName();
} catch (Exception $e) {
// can fail, for example at installation (no plugin loaded yet)
}
$this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
try {
$this->totalNumberOfQueries = Piwik::getQueryCount();
} catch (Exception $e) {
$this->totalNumberOfQueries = 0;
}
header('Content-Type: text/html; charset=utf-8');
header("Pragma: ");
header("Cache-Control: no-store, must-revalidate");
return $this->smarty->fetch($this->template);
}
示例10: getFlashInvocationCode
protected function getFlashInvocationCode($url = 'libs/open-flash-chart/data-files/nodata.txt', $use_swfobject = true)
{
$width = $this->width;
$height = $this->height;
$libPathInPiwik = 'libs/open-flash-chart/';
$currentPath = Piwik_Url::getCurrentUrlWithoutFileName();
$pathToLibraryOpenChart = $currentPath . $libPathInPiwik;
$url = Piwik_Url::getCurrentUrlWithoutQueryString() . $url;
// escape the & and stuff:
$url = urlencode($url);
$obj_id = $this->id . "Chart";
$div_name = $this->id . "FlashContent";
$return = '';
if ($use_swfobject) {
// Using library for auto-enabling Flash object on IE, disabled-Javascript proof
$return .= '
<div id="' . $div_name . '"></div>
<script type="text/javascript">
var so = new SWFObject("' . $pathToLibraryOpenChart . 'open-flash-chart.swf", "' . $obj_id . '_swf", "' . $width . '", "' . $height . '", "9", "#FFFFFF");
so.addVariable("data", "' . $url . '");
so.addParam("allowScriptAccess", "sameDomain");
so.write("' . $div_name . '");
</script>
<noscript>
';
}
$urlGraph = $pathToLibraryOpenChart . "open-flash-chart.swf?data=" . $url;
$this->codeEmbed .= "<div><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" . $width . "' height='" . $height . "' id='" . $obj_id . "' >" . "<param name='movie' value='" . $urlGraph . "' />" . "<param name='allowScriptAccess' value='sameDomain' /> " . "<embed src='{$urlGraph}' allowScriptAccess='sameDomain' quality='high' bgcolor='#FFFFFF' width='" . $width . "' height='" . $height . "' name='open-flash-chart' type='application/x-shockwave-flash' id='" . $obj_id . "' />" . "</object></div>";
$return .= $this->codeEmbed;
if ($use_swfobject) {
$return .= '</noscript>';
}
return $return;
}
示例11: buildView
protected function buildView()
{
$view = new Piwik_View($this->dataTableTemplate);
$this->uniqueIdViewDataTable = $this->getUniqueIdViewDataTable();
$view->graphType = $this->graphType;
$this->chartDivId = $this->uniqueIdViewDataTable . "Chart_swf";
$this->parametersToModify['action'] = $this->currentControllerAction;
$this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
$url = Piwik_Url::getCurrentQueryStringWithParametersModified($this->parametersToModify);
$this->includeData = !Zend_Registry::get('config')->Debug->disable_merged_requests;
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik_API_Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
if ($this->includeData) {
$this->chartData = $this->getFlashData();
} else {
$this->chartData = null;
}
$view->flashParameters = $this->getFlashParameters();
$view->urlGraphData = $url;
$view->chartDivId = $this->chartDivId;
$view->formEmbedId = "formEmbed" . $this->uniqueIdViewDataTable;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
$view->properties = $this->getViewProperties();
return $view;
}
示例12: getArrayFromCurrentQueryString
static function getArrayFromCurrentQueryString()
{
$queryString = Piwik_Url::getCurrentQueryString();
$queryString = htmlspecialchars($queryString);
$urlValues = Piwik_Common::getArrayFromQueryString($queryString);
return $urlValues;
}
示例13: activate
function activate()
{
Piwik::checkUserIsSuperUser();
$pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin');
}
示例14: init
function init()
{
$this->addElement('text', 'form_login')
->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('General_Username')));
$password = $this->addElement('password', 'form_password');
$password->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Login_Password')));
$passwordBis = $this->addElement('password', 'form_password_bis');
$passwordBis->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Login_PasswordRepeat')));
$passwordBis->addRule('eq', Piwik_Translate( 'Login_PasswordsDoNotMatch'), $password);
$this->addElement('text', 'form_token')
->addRule('required', Piwik_Translate('General_Required', Piwik_Translate('Login_PasswordResetToken')));
$this->addElement('hidden', 'form_nonce');
$this->addElement('submit', 'submit');
$resetToken = Piwik_Common::getRequestVar('token', '', 'string');
if(!empty($resetToken)) {
// default values
$this->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
'form_token' => $resetToken,
)));
$this->attributes['action'] = 'index.php' . Piwik_Url::getCurrentQueryStringWithParametersModified( array('token' => null) );
}
}
示例15: addMainPageMetricsToReport
/**
* Add the main metrics (pageviews, exits, bounces) to the full report.
* Data is loaded from Actions.getPageUrls using the label filter.
*/
private function addMainPageMetricsToReport(&$report, $pageUrl, $idSite, $period, $date, $segment)
{
$label = Piwik_Actions::getActionExplodedNames($pageUrl, Piwik_Tracker_Action::TYPE_ACTION_URL);
if (count($label) == 1) {
$label = $label[0];
} else {
$label = array_map('urlencode', $label);
$label = implode('>', $label);
}
$parameters = array('method' => 'Actions.getPageUrls', 'idSite' => $idSite, 'period' => $period, 'date' => $date, 'label' => $label, 'format' => 'original', 'serialize' => '0', 'expanded' => '0');
if (!empty($segment)) {
$parameters['segment'] = $segment;
}
$url = Piwik_Url::getQueryStringFromParameters($parameters);
$request = new Piwik_API_Request($url);
try {
/** @var $dataTable Piwik_DataTable */
$dataTable = $request->process();
} catch (Exception $e) {
throw new Exception("Actions.getPageUrls returned an error: " . $e->getMessage() . "\n");
}
if ($dataTable->getRowsCount() == 0) {
throw new Exception("The label '{$label}' could not be found in Actions.getPageUrls\n");
}
$row = $dataTable->getFirstRow();
if ($row !== false) {
$report['pageMetrics'] = array('pageviews' => intval($row->getColumn('nb_hits')), 'exits' => intval($row->getColumn('exit_nb_visits')), 'bounces' => intval($row->getColumn('entry_bounce_count')));
} else {
$report['pageMetrics'] = array('pageviews' => 0, 'exits' => 0, 'bounces' => 0);
}
}