当前位置: 首页>>代码示例>>PHP>>正文


PHP View::assign方法代码示例

本文整理汇总了PHP中Piwik\View::assign方法的典型用法代码示例。如果您正苦于以下问题:PHP View::assign方法的具体用法?PHP View::assign怎么用?PHP View::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\View的用法示例。


在下文中一共展示了View::assign方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderReport

 public function renderReport($processedReport)
 {
     $isGoalPluginEnabled = Common::isGoalPluginEnabled();
     $prettyDate = $processedReport['prettyDate'];
     $reportData = $processedReport['reportData'];
     $evolutionMetrics = array();
     $multiSitesAPIMetrics = API::getApiMetrics($enhanced = true);
     foreach ($multiSitesAPIMetrics as $metricSettings) {
         $evolutionMetrics[] = $metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY];
     }
     $floatRegex = self::FLOAT_REGEXP;
     // no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics)
     $reportData->filter('ColumnCallbackReplace', array(array_merge(array_keys($multiSitesAPIMetrics), $evolutionMetrics), function ($value) use($floatRegex) {
         return preg_replace_callback($floatRegex, function ($matches) {
             return round($matches[0]);
         }, $value);
     }));
     // evolution metrics formatting :
     //  - remove monetary, percentage and white spaces to shorten SMS content
     //    (this is also needed to be able to test $value != 0 and see if there is an evolution at all in SMSReport.twig)
     //  - adds a plus sign
     $reportData->filter('ColumnCallbackReplace', array($evolutionMetrics, function ($value) use($floatRegex) {
         $matched = preg_match($floatRegex, $value, $matches);
         $formatted = $matched ? sprintf("%+d", $matches[0]) : $value;
         return \Piwik\NumberFormatter::getInstance()->formatPercentEvolution($formatted);
     }));
     $dataRows = $reportData->getRows();
     $reportMetadata = $processedReport['reportMetadata'];
     $reportRowsMetadata = $reportMetadata->getRows();
     $siteHasECommerce = array();
     foreach ($reportRowsMetadata as $rowMetadata) {
         $idSite = $rowMetadata->getColumn('idsite');
         $siteHasECommerce[$idSite] = Site::isEcommerceEnabledFor($idSite);
     }
     $view = new View('@MobileMessaging/SMSReport');
     $view->assign("isGoalPluginEnabled", $isGoalPluginEnabled);
     $view->assign("reportRows", $dataRows);
     $view->assign("reportRowsMetadata", $reportRowsMetadata);
     $view->assign("prettyDate", $prettyDate);
     $view->assign("siteHasECommerce", $siteHasECommerce);
     $view->assign("displaySiteName", $processedReport['metadata']['action'] == 'getAll');
     // segment
     $segment = $processedReport['segment'];
     $displaySegment = $segment != null;
     $view->assign("displaySegment", $displaySegment);
     if ($displaySegment) {
         $view->assign("segmentName", $segment['name']);
     }
     $this->rendering .= $view->render();
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:50,代码来源:Sms.php

示例2: buildView

 protected function buildView()
 {
     $this->overrideSomeConfigPropertiesIfNeeded();
     try {
         $this->beforeLoadDataTable();
         $this->loadDataTableFromAPI();
         $this->postDataTableLoadedFromAPI();
         $requestPropertiesAfterLoadDataTable = $this->requestConfig->getProperties();
         $this->applyFilters();
         $this->addVisualizationInfoFromMetricMetadata();
         $this->afterAllFiltersAreApplied();
         $this->beforeRender();
         $this->logMessageIfRequestPropertiesHaveChanged($requestPropertiesAfterLoadDataTable);
     } catch (NoAccessException $e) {
         throw $e;
     } catch (\Exception $e) {
         Log::error("Failed to get data from API: " . $e->getMessage() . "\n" . $e->getTraceAsString());
         $message = $e->getMessage();
         if (\Piwik_ShouldPrintBackTraceWithMessage()) {
             $message .= "\n" . $e->getTraceAsString();
         }
         $loadingError = array('message' => $message);
     }
     $view = new View("@CoreHome/_dataTable");
     if (!empty($loadingError)) {
         $view->error = $loadingError;
     }
     $view->assign($this->templateVars);
     $view->visualization = $this;
     $view->visualizationTemplate = static::TEMPLATE_FILE;
     $view->visualizationCssClass = $this->getDefaultDataTableCssClass();
     $view->reportMetdadata = $this->getReportMetadata();
     if (null === $this->dataTable) {
         $view->dataTable = null;
     } else {
         $view->dataTableHasNoData = !$this->isThereDataToDisplay();
         $view->dataTable = $this->dataTable;
         // if it's likely that the report data for this data table has been purged,
         // set whether we should display a message to that effect.
         $view->showReportDataWasPurgedMessage = $this->hasReportBeenPurged();
         $view->deleteReportsOlderThan = Option::get('delete_reports_older_than');
     }
     $view->idSubtable = $this->requestConfig->idSubtable;
     $view->clientSideParameters = $this->getClientSideParametersToSet();
     $view->clientSideProperties = $this->getClientSidePropertiesToSet();
     $view->properties = array_merge($this->requestConfig->getProperties(), $this->config->getProperties());
     $view->reportLastUpdatedMessage = $this->reportLastUpdatedMessage;
     $view->footerIcons = $this->config->footer_icons;
     $view->isWidget = Common::getRequestVar('widget', 0, 'int');
     return $view;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:51,代码来源:Visualization.php

示例3: assignCommonParameters

 private function assignCommonParameters(View $view)
 {
     $view->assign("reportFontFamily", ReportRenderer::DEFAULT_REPORT_FONT_FAMILY);
     $view->assign("reportTitleTextColor", ReportRenderer::REPORT_TITLE_TEXT_COLOR);
     $view->assign("reportTitleTextSize", self::REPORT_TITLE_TEXT_SIZE);
     $view->assign("reportTextColor", ReportRenderer::REPORT_TEXT_COLOR);
     $view->assign("tableHeaderBgColor", ReportRenderer::TABLE_HEADER_BG_COLOR);
     $view->assign("tableHeaderTextColor", ReportRenderer::TABLE_HEADER_TEXT_COLOR);
     $view->assign("tableCellBorderColor", ReportRenderer::TABLE_CELL_BORDER_COLOR);
     $view->assign("tableBgColor", ReportRenderer::TABLE_BG_COLOR);
     $view->assign("reportTableHeaderTextWeight", self::TABLE_HEADER_TEXT_WEIGHT);
     $view->assign("reportTableHeaderTextSize", self::REPORT_TABLE_HEADER_TEXT_SIZE);
     $view->assign("reportTableHeaderTextTransform", ReportRenderer::TABLE_HEADER_TEXT_TRANSFORM);
     $view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE);
     $view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE);
     $view->assign("currentPath", SettingsPiwik::getPiwikUrl());
     $view->assign("logoHeader", API::getInstance()->getHeaderLogoUrl());
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:18,代码来源:Html.php

示例4: sendAlertsPerEmailToRecipient

 /**
  * @param array $alerts
  * @param Mail $mail
  * @param string[] $recipient Email addresses
  * @param $period
  * @param $idSite
  */
 protected function sendAlertsPerEmailToRecipient($alerts, Mail $mail, $recipient, $period, $idSite)
 {
     if (empty($recipient) || empty($alerts)) {
         return;
     }
     $prettyDate = $this->getPrettyDateForSite($period, $idSite);
     $websiteName = Site::getNameFor($idSite);
     $mail->setDefaultFromPiwik();
     $mail->addTo($recipient);
     $mail->setSubject(Piwik::translate('CustomAlerts_MailAlertSubject', array($websiteName, $prettyDate)));
     $controller = new Controller();
     $viewHtml = new View('@CustomAlerts/alertHtmlMail');
     $viewHtml->assign('triggeredAlerts', $controller->formatAlerts($alerts, 'html'));
     $mail->setBodyHtml($viewHtml->render());
     $viewText = new View('@CustomAlerts/alertTextMail');
     $viewText->assign('triggeredAlerts', $controller->formatAlerts($alerts, 'text'));
     $viewText->setContentType('text/plain');
     $mail->setBodyText($viewText->render());
     $mail->send();
 }
开发者ID:andrzejewsky,项目名称:plugin-CustomAlerts,代码行数:27,代码来源:Notifier.php

示例5: view

 /**
  * Main method
  */
 public function view()
 {
     /** List of available groups */
     $groups = array();
     $conf = self::conf();
     $d = dir($conf['logPath']);
     /** Fix by Kowalikus: get the list of sites the current user has view access to */
     $idSite = (int) Common::getRequestVar('idSite');
     if (Piwik::isUserHasViewAccess($idSite) === false) {
         return false;
     }
     while (($dir = $d->read()) !== false) {
         if ($dir[0] === '.' || !is_dir($d->path . $dir)) {
             continue;
         }
         $pos = strpos($dir, ',');
         if ($pos === false) {
             continue;
         }
         $site = (int) substr($dir, 0, $pos);
         /** Fix by Kowalikus: check if current user has view access */
         if ($site !== $idSite) {
             continue;
         }
         $groups[] = '<option value="' . $dir . '">' . ($pos === false ? $dir : substr($dir, $pos + 1)) . '</option>';
     }
     $d->close();
     /** Sort groups in alphabetical order */
     sort($groups);
     $__selectGroups = implode("\n", $groups);
     /** Screen sizes */
     $__selectScreens = '';
     for ($i = 0; $i < count($conf['__screenSizes']); $i++) {
         $__selectScreens .= '<option value="' . $conf['__screenSizes'][$i] . '">' . ($conf['__screenSizes'][$i] === 0 ? Piwik::Translate('ClickHeat_LANG_ALL') : $conf['__screenSizes'][$i] . 'px') . '</option>';
     }
     /** Browsers */
     $__selectBrowsers = '';
     foreach ($conf['__browsersList'] as $label => $name) {
         $__selectBrowsers .= '<option value="' . $label . '">' . ($label === 'all' ? Piwik::Translate('ClickHeat_LANG_ALL') : ($label === 'unknown' ? Piwik::Translate('ClickHeat_LANG_UNKNOWN') : $name)) . '</option>';
     }
     /** Date */
     $date = strtotime(Common::getRequestVar('date'));
     if ($date === false) {
         if ($conf['yesterday'] === true) {
             $date = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
         } else {
             $date = time();
         }
     }
     $__day = (int) date('d', $date);
     $__month = (int) date('m', $date);
     $__year = (int) date('Y', $date);
     $range = Common::getRequestVar('period');
     $range = $range[0];
     if (!in_array($range, array('d', 'm', 'w'))) {
         $range = 'd';
     }
     if ($range === 'w') {
         $startDay = $conf['start'] === 'm' ? 1 : 0;
         while (date('w', $date) != $startDay) {
             $date = mktime(0, 0, 0, date('m', $date), date('d', $date) - 1, date('Y', $date));
         }
         $__day = (int) date('d', $date);
         $__month = (int) date('m', $date);
         $__year = (int) date('Y', $date);
     } elseif ($range === 'm') {
         $__day = 1;
     }
     $view = new View('@ClickHeat/view');
     $view->assign('clickheat_host', 'http://' . $_SERVER['SERVER_NAME']);
     $view->assign('clickheat_path', CLICKHEAT_PATH);
     $view->assign('clickheat_index', CLICKHEAT_INDEX_PATH);
     //$view->assign('clickheat_group', LANG_GROUP);
     $view->assign('clickheat_groups', $__selectGroups);
     //$view->assign('clickheat_browser', LANG_BROWSER);
     $view->assign('clickheat_browsers', $__selectBrowsers);
     //$view->assign('clickheat_screen', LANG_SCREENSIZE);
     $view->assign('clickheat_screens', $__selectScreens);
     //$view->assign('clickheat_heatmap', LANG_HEATMAP);
     $view->clickheat_loading = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_ERROR_LOADING'));
     $view->clickheat_cleaner = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_CLEANER_RUNNING'));
     $view->clickheat_admincookie = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_JAVASCRIPT_ADMIN_COOKIE'));
     $view->clickheat_alpha = $conf['alpha'];
     $view->clickheat_iframes = $conf['hideIframes'] === true ? 'true' : 'false';
     $view->clickheat_flashes = $conf['hideFlashes'] === true ? 'true' : 'false';
     $view->clickheat_force_heatmap = $conf['heatmap'] === true ? ' checked="checked"' : '';
     $view->clickheat_jsokay = str_replace('\'', '\\\'', Piwik::Translate('ClickHeat_LANG_ERROR_JAVASCRIPT'));
     $view->clickheat_day = $__day;
     $view->clickheat_month = $__month;
     $view->clickheat_year = $__year;
     $view->clickheat_range = $range;
     $view->clickheat_menu = '<a href="#" onclick="adminCookie(); return false;">' . Piwik::Translate('ClickHeat_LANG_LOG_MY_CLICKS') . '</a><br /><a href="#" onclick="showJsCode(); return false;">Javascript</a>';
     echo $view->render();
 }
开发者ID:NikitaEgorov,项目名称:plugin-clickheat,代码行数:97,代码来源:Controller.php


注:本文中的Piwik\View::assign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。