PDF rausgenommen
This commit is contained in:
27
msd2/tracking/piwik/core/View/HtmlEmailFooterView.php
Normal file
27
msd2/tracking/piwik/core/View/HtmlEmailFooterView.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\View;
|
||||
|
||||
|
||||
use Piwik\View;
|
||||
|
||||
class HtmlEmailFooterView extends View
|
||||
{
|
||||
const TEMPLATE_FILE = '@CoreHome/ReportRenderer/_htmlReportFooter';
|
||||
|
||||
public function __construct($unsubscribeLink = null)
|
||||
{
|
||||
parent::__construct(self::TEMPLATE_FILE);
|
||||
|
||||
HtmlReportEmailHeaderView::assignCommonParameters($this);
|
||||
|
||||
$this->unsubscribeLink = $unsubscribeLink;
|
||||
}
|
||||
}
|
96
msd2/tracking/piwik/core/View/HtmlReportEmailHeaderView.php
Normal file
96
msd2/tracking/piwik/core/View/HtmlReportEmailHeaderView.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\View;
|
||||
|
||||
use Piwik\Common;
|
||||
use Piwik\Date;
|
||||
use Piwik\Mail\EmailStyles;
|
||||
use Piwik\Plugin\ThemeStyles;
|
||||
use Piwik\Plugins\API\API;
|
||||
use Piwik\Plugins\CoreAdminHome\CustomLogo;
|
||||
use Piwik\Scheduler\Schedule\Schedule;
|
||||
use Piwik\SettingsPiwik;
|
||||
use Piwik\Site;
|
||||
use Piwik\View;
|
||||
use Piwik\Plugin\Manager;
|
||||
|
||||
class HtmlReportEmailHeaderView extends View
|
||||
{
|
||||
const TEMPLATE_FILE = '@CoreHome/ReportRenderer/_htmlReportHeader';
|
||||
|
||||
private static $reportFrequencyTranslationByPeriod = [
|
||||
Schedule::PERIOD_NEVER => '',
|
||||
Schedule::PERIOD_DAY => 'General_DailyReport',
|
||||
Schedule::PERIOD_WEEK => 'General_WeeklyReport',
|
||||
Schedule::PERIOD_MONTH => 'General_MonthlyReport',
|
||||
Schedule::PERIOD_YEAR => 'General_YearlyReport',
|
||||
Schedule::PERIOD_RANGE => 'General_RangeReports',
|
||||
];
|
||||
|
||||
public function __construct($reportTitle, $prettyDate, $description, $reportMetadata, $segment, $idSite, $period)
|
||||
{
|
||||
parent::__construct(self::TEMPLATE_FILE);
|
||||
|
||||
self::assignCommonParameters($this);
|
||||
|
||||
$periods = self::getPeriodToFrequencyAsAdjective();
|
||||
$this->assign("frequency", $periods[$period]);
|
||||
$this->assign("reportTitle", $reportTitle);
|
||||
$this->assign("prettyDate", $prettyDate);
|
||||
$this->assign("description", $description);
|
||||
$this->assign("reportMetadata", $reportMetadata);
|
||||
$this->assign("websiteName", Site::getNameFor($idSite));
|
||||
$this->assign("idSite", $idSite);
|
||||
$this->assign("period", $period);
|
||||
|
||||
$date = Date::now()->setTimezone(Site::getTimezoneFor($idSite))->toString();
|
||||
$this->assign("date", $date);
|
||||
|
||||
// segment
|
||||
$displaySegment = ($segment != null);
|
||||
$this->assign("displaySegment", $displaySegment);
|
||||
if ($displaySegment) {
|
||||
$this->assign("segmentName", $segment['name']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function assignCommonParameters(View $view)
|
||||
{
|
||||
$themeStyles = ThemeStyles::get();
|
||||
$emailStyles = EmailStyles::get();
|
||||
|
||||
$view->currentPath = SettingsPiwik::getPiwikUrl();
|
||||
$view->logoHeader = API::getInstance()->getHeaderLogoUrl();
|
||||
|
||||
$view->themeStyles = $themeStyles;
|
||||
$view->emailStyles = $emailStyles;
|
||||
|
||||
$view->fontStyle = 'color:' . $themeStyles->colorText . ';font-family:' . $themeStyles->fontFamilyBase.';';
|
||||
$view->styleParagraphText = 'font-size:15px;line-height:24px;';
|
||||
$view->styleParagraph = $view->styleParagraphText . 'margin:0 0 16px;';
|
||||
|
||||
$customLogo = new CustomLogo();
|
||||
$view->isCustomLogo = $customLogo->isEnabled() && CustomLogo::hasUserLogo();
|
||||
$view->logoHeader = $customLogo->getHeaderLogoUrl($pathOnly = false);
|
||||
|
||||
$pluginManager = Manager::getInstance();
|
||||
|
||||
$view->hasWhiteLabel = $pluginManager->isPluginLoaded('WhiteLabel')
|
||||
&& $pluginManager->isPluginActivated('WhiteLabel')
|
||||
&& $pluginManager->isPluginInFilesystem('WhiteLabel');
|
||||
|
||||
$view->idSite = Common::getRequestVar('idSite', false);
|
||||
}
|
||||
|
||||
private static function getPeriodToFrequencyAsAdjective()
|
||||
{
|
||||
return array_map(['\Piwik\Piwik', 'translate'], self::$reportFrequencyTranslationByPeriod);
|
||||
}
|
||||
}
|
99
msd2/tracking/piwik/core/View/OneClickDone.php
Normal file
99
msd2/tracking/piwik/core/View/OneClickDone.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\View;
|
||||
|
||||
use Piwik\Common;
|
||||
|
||||
/**
|
||||
* Post-update view
|
||||
*
|
||||
* During a Piwik software update, there will be instances of old classes
|
||||
* loaded in memory. This is problematic as we will start to instantiate
|
||||
* new classes which may not be backward compatible. This class provides
|
||||
* a clean bridge/transition by forcing a new request.
|
||||
*
|
||||
* This class needs to be self-contained, with no external dependencies.
|
||||
*
|
||||
*/
|
||||
class OneClickDone
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $tokenAuth;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $feedbackMessages;
|
||||
|
||||
/**
|
||||
* Did the download over HTTPS fail?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $httpsFail = false;
|
||||
|
||||
public function __construct($tokenAuth)
|
||||
{
|
||||
$this->tokenAuth = $tokenAuth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the data.
|
||||
*
|
||||
* @return string html
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
// set response headers
|
||||
@Common::stripHeader('Pragma');
|
||||
@Common::stripHeader('Expires');
|
||||
@Common::sendHeader('Content-Type: text/html; charset=UTF-8');
|
||||
@Common::sendHeader('Cache-Control: must-revalidate');
|
||||
@Common::sendHeader('X-Frame-Options: deny');
|
||||
|
||||
$error = htmlspecialchars($this->error, ENT_QUOTES, 'UTF-8');
|
||||
$messages = htmlspecialchars(serialize($this->feedbackMessages), ENT_QUOTES, 'UTF-8');
|
||||
$tokenAuth = $this->tokenAuth;
|
||||
$httpsFail = (int) $this->httpsFail;
|
||||
|
||||
// use a heredoc instead of an external file
|
||||
echo <<<END_OF_TEMPLATE
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<form name="myform" method="post" action="?module=CoreUpdater&action=oneClickResults">
|
||||
<input type="hidden" name="token_auth" value="$tokenAuth" />
|
||||
<input type="hidden" name="error" value="$error" />
|
||||
<input type="hidden" name="messages" value="$messages" />
|
||||
<input type="hidden" name="httpsFail" value="$httpsFail" />
|
||||
<noscript>
|
||||
<button type="submit">Continue</button>
|
||||
</noscript>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
document.myform.submit();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
END_OF_TEMPLATE;
|
||||
}
|
||||
}
|
82
msd2/tracking/piwik/core/View/RenderTokenParser.php
Normal file
82
msd2/tracking/piwik/core/View/RenderTokenParser.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\View;
|
||||
|
||||
use Twig_Node_Expression_Array;
|
||||
use Twig_Node_Expression_MethodCall;
|
||||
use Twig_Node_Include;
|
||||
use Twig_Token;
|
||||
use Twig_TokenParser;
|
||||
|
||||
/**
|
||||
* Defines a new Twig tag that will render a Piwik View.
|
||||
*
|
||||
* Use the tag like this:
|
||||
*
|
||||
* {% render theView %}
|
||||
*
|
||||
* where `theView` is a variable referencing a View instance.
|
||||
*/
|
||||
class RenderTokenParser extends Twig_TokenParser
|
||||
{
|
||||
/**
|
||||
* Parses the Twig stream and creates a Twig_Node_Include instance that includes
|
||||
* the View's template.
|
||||
*
|
||||
* @return Twig_Node_Include
|
||||
*/
|
||||
public function parse(Twig_Token $token)
|
||||
{
|
||||
$parser = $this->parser;
|
||||
$stream = $parser->getStream();
|
||||
|
||||
$view = $parser->getExpressionParser()->parseExpression();
|
||||
|
||||
$variablesOverride = new Twig_Node_Expression_Array(array(), $token->getLine());
|
||||
if ($stream->test(Twig_Token::NAME_TYPE, 'with')) {
|
||||
$stream->next();
|
||||
|
||||
$variablesOverride->addElement($this->parser->getExpressionParser()->parseExpression());
|
||||
}
|
||||
|
||||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
$viewTemplateExpr = new Twig_Node_Expression_MethodCall(
|
||||
$view,
|
||||
'getTemplateFile',
|
||||
new Twig_Node_Expression_Array(array(), $token->getLine()),
|
||||
$token->getLine()
|
||||
);
|
||||
|
||||
$variablesExpr = new Twig_Node_Expression_MethodCall(
|
||||
$view,
|
||||
'getTemplateVars',
|
||||
$variablesOverride,
|
||||
$token->getLine()
|
||||
);
|
||||
|
||||
return new Twig_Node_Include(
|
||||
$viewTemplateExpr,
|
||||
$variablesExpr,
|
||||
$only = false,
|
||||
$ignoreMissing = false,
|
||||
$token->getLine()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tag identifier.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return 'render';
|
||||
}
|
||||
}
|
179
msd2/tracking/piwik/core/View/UIControl.php
Normal file
179
msd2/tracking/piwik/core/View/UIControl.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\View;
|
||||
|
||||
use Exception;
|
||||
use Piwik\View;
|
||||
|
||||
/**
|
||||
* Base type of UI controls.
|
||||
*
|
||||
* The JavaScript companion class can be found in plugins/CoreHome/javascripts/uiControl.js.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
class UIControl extends \Piwik\View
|
||||
{
|
||||
/**
|
||||
* The Twig template file that generates the control's HTML.
|
||||
*
|
||||
* Derived classes must set this constant.
|
||||
*/
|
||||
const TEMPLATE = '';
|
||||
|
||||
/**
|
||||
* The CSS class that is used to map the root element of this control with the JavaScript class.
|
||||
*
|
||||
* This field must be set prior to rendering.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cssIdentifier = null;
|
||||
|
||||
/**
|
||||
* The name of the JavaScript class that handles the behavior of this control.
|
||||
*
|
||||
* This field must be set prior to rendering.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $jsClass = null;
|
||||
|
||||
/**
|
||||
* The JavaScript module that contains the JavaScript class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $jsNamespace = 'piwik/UI';
|
||||
|
||||
/**
|
||||
* Extra CSS class(es) for the root element.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $cssClass = "";
|
||||
|
||||
/**
|
||||
* HTML Attributes for the root element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $htmlAttributes = array();
|
||||
|
||||
/**
|
||||
* The inner view that renders the actual control content.
|
||||
*
|
||||
* @var View
|
||||
*/
|
||||
private $innerView = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->innerView = new View(static::TEMPLATE);
|
||||
|
||||
parent::__construct("@CoreHome\_uiControl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a variable. See {@link View::__set()}.
|
||||
*/
|
||||
public function __set($key, $val)
|
||||
{
|
||||
$this->innerView->__set($key, $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a view variable. See {@link View::__get()}.
|
||||
*/
|
||||
public function &__get($key)
|
||||
{
|
||||
return $this->innerView->__get($key);
|
||||
}
|
||||
|
||||
public function __isset($key)
|
||||
{
|
||||
return isset($this->innerView->templateVars[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the control view within a containing <div> that is used by the UIControl JavaScript
|
||||
* class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->cssIdentifier === null) {
|
||||
throw new Exception("All UIControls must set a cssIdentifier property");
|
||||
}
|
||||
|
||||
if ($this->jsClass === null) {
|
||||
throw new Exception("All UIControls must set a jsClass property");
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link View::getTemplateVars()}.
|
||||
*/
|
||||
public function getTemplateVars($override = array())
|
||||
{
|
||||
$this->templateVars['implView'] = $this->innerView;
|
||||
$this->templateVars['cssIdentifier'] = $this->cssIdentifier;
|
||||
$this->templateVars['cssClass'] = $this->cssClass;
|
||||
$this->templateVars['jsClass'] = $this->jsClass;
|
||||
$this->templateVars['htmlAttributes'] = $this->htmlAttributes;
|
||||
$this->templateVars['jsNamespace'] = $this->jsNamespace;
|
||||
$this->templateVars['implOverride'] = $override;
|
||||
|
||||
$innerTemplateVars = $this->innerView->getTemplateVars($override);
|
||||
|
||||
$this->templateVars['clientSideProperties'] = array();
|
||||
foreach ($this->getClientSideProperties() as $name) {
|
||||
$this->templateVars['clientSideProperties'][$name] = $innerTemplateVars[$name];
|
||||
}
|
||||
|
||||
$this->templateVars['clientSideParameters'] = array();
|
||||
foreach ($this->getClientSideParameters() as $name) {
|
||||
$this->templateVars['clientSideParameters'][$name] = $innerTemplateVars[$name];
|
||||
}
|
||||
|
||||
return parent::getTemplateVars($override);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of property names whose values are passed to the UIControl JavaScript class.
|
||||
*
|
||||
* Should be overriden by descendants.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClientSideProperties()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of property names whose values are passed to the UIControl JavaScript class.
|
||||
* These values differ from those in {@link $clientSideProperties} in that they are meant to passed as
|
||||
* request parameters when the JavaScript code makes an AJAX request.
|
||||
*
|
||||
* Should be overriden by descendants.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClientSideParameters()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
25
msd2/tracking/piwik/core/View/ViewInterface.php
Normal file
25
msd2/tracking/piwik/core/View/ViewInterface.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Piwik\View;
|
||||
|
||||
/**
|
||||
* Rendering interface for all "view" types.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
interface ViewInterface
|
||||
{
|
||||
/**
|
||||
* Returns data.
|
||||
*
|
||||
* @return string Serialized data, eg, (image, array, html...).
|
||||
*/
|
||||
public function render();
|
||||
}
|
Reference in New Issue
Block a user