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


PHP Filesystem::getPathToPiwikRoot方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $piwikLanguages = \Piwik\Plugins\LanguagesManager\API::getInstance()->getAvailableLanguages();
     $aliasesUrl = 'https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/aliases.json';
     $aliasesData = Http::fetchRemoteFile($aliasesUrl);
     $aliasesData = json_decode($aliasesData, true);
     $aliasesData = $aliasesData['supplemental']['metadata']['alias']['languageAlias'];
     $writePath = Filesystem::getPathToPiwikRoot() . '/plugins/Intl/lang/%s.json';
     foreach ($piwikLanguages as $langCode) {
         if ($langCode == 'dev') {
             continue;
         }
         $requestLangCode = $transformedLangCode = $this->transformLangCode($langCode);
         if (array_key_exists($requestLangCode, $aliasesData)) {
             $requestLangCode = $aliasesData[$requestLangCode]['_replacement'];
         }
         // fix some locales
         $localFixes = array('pt' => 'pt-PT', 'pt-br' => 'pt', 'zh-cn' => 'zh-Hans', 'zh-tw' => 'zh-Hant');
         if (array_key_exists($langCode, $localFixes)) {
             $requestLangCode = $localFixes[$langCode];
         }
         setlocale(LC_ALL, $langCode);
         $translations = array();
         $this->fetchLanguageData($output, $transformedLangCode, $requestLangCode, $translations);
         $this->fetchTerritoryData($output, $transformedLangCode, $requestLangCode, $translations);
         $this->fetchCalendarData($output, $transformedLangCode, $requestLangCode, $translations);
         $this->fetchLayoutDirection($output, $transformedLangCode, $requestLangCode, $translations);
         $this->fetchUnitData($output, $transformedLangCode, $requestLangCode, $translations);
         $this->fetchNumberFormattingData($output, $transformedLangCode, $requestLangCode, $translations);
         ksort($translations['Intl']);
         file_put_contents(sprintf($writePath, $langCode), json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:33,代码来源:GenerateIntl.php

示例2: getPathToLogo

 protected function getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo)
 {
     $pathToPiwikRoot = Filesystem::getPathToPiwikRoot();
     $logo = $defaultLogo;
     $themeName = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled()->getPluginName();
     $themeLogo = sprintf($themeLogo, $themeName);
     if (file_exists($pathToPiwikRoot . '/' . $themeLogo)) {
         $logo = $themeLogo;
     }
     if ($this->isEnabled() && file_exists($pathToPiwikRoot . '/' . $customLogo)) {
         $logo = $customLogo;
     }
     if (!$pathOnly) {
         return SettingsPiwik::getPiwikUrl() . $logo;
     }
     return $pathToPiwikRoot . '/' . $logo;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:17,代码来源:CustomLogo.php

示例3: uninstall

 public function uninstall($redirectAfter = true)
 {
     $pluginName = $this->initPluginModification(static::UNINSTALL_NONCE);
     $this->dieIfPluginsAdminIsDisabled();
     $uninstalled = \Piwik\Plugin\Manager::getInstance()->uninstallPlugin($pluginName);
     if (!$uninstalled) {
         $path = Filesystem::getPathToPiwikRoot() . '/plugins/' . $pluginName . '/';
         $messagePermissions = Filechecks::getErrorMessageMissingPermissions($path);
         $messageIntro = $this->translator->translate("Warning: \"%s\" could not be uninstalled. Piwik did not have enough permission to delete the files in {$path}. ", $pluginName);
         $exitMessage = $messageIntro . "<br/><br/>" . $messagePermissions;
         $exitMessage .= "<br> Or manually delete this directory (using FTP or SSH access)";
         $ex = new MissingFilePermissionException($exitMessage);
         $ex->setIsHtmlMessage();
         throw $ex;
     }
     $this->redirectAfterModification($redirectAfter);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:17,代码来源:Controller.php

示例4: doWelcomeUpdates

 private function doWelcomeUpdates($view, $componentsWithUpdateFile)
 {
     $view->new_piwik_version = Version::VERSION;
     $view->commandUpgradePiwik = "<br /><code>php " . Filesystem::getPathToPiwikRoot() . "/console core:update </code>";
     $pluginNamesToUpdate = array();
     $dimensionsToUpdate = array();
     $coreToUpdate = false;
     // handle case of existing database with no tables
     if (!DbHelper::isInstalled()) {
         $this->errorMessages[] = Piwik::translate('CoreUpdater_EmptyDatabaseError', Config::getInstance()->database['dbname']);
         $this->coreError = true;
         $currentVersion = 'N/A';
     } else {
         $this->errorMessages = array();
         try {
             $currentVersion = Option::get('version_core');
         } catch (Exception $e) {
             $currentVersion = '<= 0.2.9';
         }
         foreach ($componentsWithUpdateFile as $name => $filenames) {
             if ($name == 'core') {
                 $coreToUpdate = true;
             } elseif (0 === strpos($name, 'log_')) {
                 $dimensionsToUpdate[] = $name;
             } else {
                 $pluginNamesToUpdate[] = $name;
             }
         }
     }
     // check file integrity
     $integrityInfo = Filechecks::getFileIntegrityInformation();
     if (isset($integrityInfo[1])) {
         if ($integrityInfo[0] == false) {
             $this->warningMessages[] = Piwik::translate('General_FileIntegrityWarningExplanation');
         }
         $this->warningMessages = array_merge($this->warningMessages, array_slice($integrityInfo, 1));
     }
     Filesystem::deleteAllCacheOnUpdate();
     $view->coreError = $this->coreError;
     $view->warningMessages = $this->warningMessages;
     $view->errorMessages = $this->errorMessages;
     $view->current_piwik_version = $currentVersion;
     $view->pluginNamesToUpdate = $pluginNamesToUpdate;
     $view->dimensionsToUpdate = $dimensionsToUpdate;
     $view->coreToUpdate = $coreToUpdate;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:46,代码来源:Controller.php

示例5: paintReportTable

 private function paintReportTable()
 {
     //Color and font restoration
     $this->TCPDF->SetFillColor($this->tableBackgroundColor[0], $this->tableBackgroundColor[1], $this->tableBackgroundColor[2]);
     $this->TCPDF->SetTextColor($this->reportTextColor[0], $this->reportTextColor[1], $this->reportTextColor[2]);
     $this->TCPDF->SetFont('');
     $fill = true;
     $url = false;
     $leftSpacesBeforeLogo = str_repeat(' ', $this->leftSpacesBeforeLogo);
     $logoWidth = $this->logoWidth;
     $logoHeight = $this->logoHeight;
     $rowsMetadata = $this->reportRowsMetadata->getRows();
     // Draw a body of report table
     foreach ($this->report->getRows() as $rowId => $row) {
         $rowMetrics = $row->getColumns();
         $rowMetadata = isset($rowsMetadata[$rowId]) ? $rowsMetadata[$rowId]->getColumns() : array();
         if (isset($rowMetadata['url'])) {
             $url = $rowMetadata['url'];
         }
         foreach ($this->reportColumns as $columnId => $columnName) {
             // Label column
             if ($columnId == 'label') {
                 $isLogoDisplayable = isset($rowMetadata['logo']);
                 $text = '';
                 $posX = $this->TCPDF->GetX();
                 $posY = $this->TCPDF->GetY();
                 if (isset($rowMetrics[$columnId])) {
                     $text = substr($rowMetrics[$columnId], 0, $this->truncateAfter);
                     if ($isLogoDisplayable) {
                         $text = $leftSpacesBeforeLogo . $text;
                     }
                 }
                 $text = $this->formatText($text);
                 $this->TCPDF->Cell($this->labelCellWidth, $this->cellHeight, $text, 'LR', 0, 'L', $fill, $url);
                 if ($isLogoDisplayable) {
                     if (isset($rowMetadata['logoWidth'])) {
                         $logoWidth = $rowMetadata['logoWidth'];
                     }
                     if (isset($rowMetadata['logoHeight'])) {
                         $logoHeight = $rowMetadata['logoHeight'];
                     }
                     $restoreY = $this->TCPDF->getY();
                     $restoreX = $this->TCPDF->getX();
                     $this->TCPDF->SetY($posY);
                     $this->TCPDF->SetX($posX);
                     $topMargin = 1.3;
                     // Country flags are not very high, force a bigger top margin
                     if ($logoHeight < 16) {
                         $topMargin = 2;
                     }
                     $path = Filesystem::getPathToPiwikRoot() . "/" . $rowMetadata['logo'];
                     if (file_exists($path)) {
                         $this->TCPDF->Image($path, $posX + ($leftMargin = 2), $posY + $topMargin, $logoWidth / 4);
                     }
                     $this->TCPDF->SetXY($restoreX, $restoreY);
                 }
             } else {
                 // No value means 0
                 if (empty($rowMetrics[$columnId])) {
                     $rowMetrics[$columnId] = 0;
                 }
                 $this->TCPDF->Cell($this->cellWidth, $this->cellHeight, $rowMetrics[$columnId], 'LR', 0, 'L', $fill);
             }
         }
         $this->TCPDF->Ln();
         // Top/Bottom grey border for all cells
         $this->TCPDF->SetDrawColor($this->rowTopBottomBorder[0], $this->rowTopBottomBorder[1], $this->rowTopBottomBorder[2]);
         $this->TCPDF->Cell($this->totalWidth, 0, '', 'T');
         $this->setBorderColor();
         $this->TCPDF->Ln(0.2);
         $fill = !$fill;
     }
 }
开发者ID:GovanifY,项目名称:piwik,代码行数:73,代码来源:Pdf.php

示例6: start

 /**
  * Start the session
  *
  * @param array|bool $options An array of configuration options; the auto-start (bool) setting is ignored
  * @return void
  */
 public static function start($options = false)
 {
     if (headers_sent() || self::$sessionStarted || defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START) {
         return;
     }
     self::$sessionStarted = true;
     // use cookies to store session id on the client side
     @ini_set('session.use_cookies', '1');
     // prevent attacks involving session ids passed in URLs
     @ini_set('session.use_only_cookies', '1');
     // advise browser that session cookie should only be sent over secure connection
     if (ProxyHttp::isHttps()) {
         @ini_set('session.cookie_secure', '1');
     }
     // advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
     @ini_set('session.cookie_httponly', '1');
     // don't use the default: PHPSESSID
     @ini_set('session.name', self::SESSION_NAME);
     // proxies may cause the referer check to fail and
     // incorrectly invalidate the session
     @ini_set('session.referer_check', '');
     $currentSaveHandler = ini_get('session.save_handler');
     $config = Config::getInstance();
     if (self::isFileBasedSessions()) {
         // Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
         // for "files", use our own folder to prevent local session file hijacking
         $sessionPath = self::getSessionsDirectory();
         // We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
         Filesystem::mkdir($sessionPath);
         @ini_set('session.save_handler', 'files');
         @ini_set('session.save_path', $sessionPath);
     } else {
         if ($config->General['session_save_handler'] === 'dbtable' || in_array($currentSaveHandler, array('user', 'mm'))) {
             // We consider these to be misconfigurations, in that:
             // - user  - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
             // - mm    - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
             $config = array('name' => Common::prefixTable('session'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
             $saveHandler = new DbTable($config);
             if ($saveHandler) {
                 self::setSaveHandler($saveHandler);
             }
         }
     }
     // garbage collection may disabled by default (e.g., Debian)
     if (ini_get('session.gc_probability') == 0) {
         @ini_set('session.gc_probability', 1);
     }
     try {
         parent::start();
         register_shutdown_function(array('Zend_Session', 'writeClose'), true);
     } catch (Exception $e) {
         Log::warning('Unable to start session: ' . $e->getMessage());
         $enableDbSessions = '';
         if (DbHelper::isInstalled()) {
             $enableDbSessions = "<br/>If you still experience issues after trying these changes,\n\t\t\t            \t\t\twe recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' target='_blank'>enable database session storage</a>.";
         }
         $pathToSessions = Filechecks::getErrorMessageMissingPermissions(Filesystem::getPathToPiwikRoot() . '/tmp/sessions/');
         $pathToSessions = SettingsPiwik::rewriteTmpPathWithInstanceId($pathToSessions);
         $message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>", Piwik::translate('General_ExceptionUnableToStartSession'), $pathToSessions, $enableDbSessions, $e->getMessage());
         Piwik_ExitWithMessage($message, $e->getTraceAsString());
     }
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:68,代码来源:Session.php


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