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


PHP Option::set方法代码示例

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


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

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $dbName = false;
     if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) {
         $dbName = $GLOBALS['PIWIK_BENCHMARK_DATABASE'];
     }
     // connect to database
     self::createTestConfig();
     self::connectWithoutDatabase();
     // create specified fixture (global var not set, use default no-data fixture (see end of this file))
     if (empty($GLOBALS['PIWIK_BENCHMARK_FIXTURE'])) {
         $fixtureName = 'Piwik_Test_Fixture_EmptyOneSite';
     } else {
         $fixtureName = 'Piwik_Test_Fixture_' . $GLOBALS['PIWIK_BENCHMARK_FIXTURE'];
     }
     self::$fixture = new $fixtureName();
     // figure out if the desired fixture has already been setup, and if not empty the database
     $installedFixture = false;
     try {
         if (isset(self::$fixture->tablesPrefix)) {
             Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix;
         }
         Db::query("USE " . $dbName);
         $installedFixture = \Piwik\Option::get('benchmark_fixture_name');
     } catch (Exception $ex) {
         // ignore
     }
     $createEmptyDatabase = $fixtureName != $installedFixture;
     parent::_setUpBeforeClass($dbName, $createEmptyDatabase);
     // if we created an empty database, setup the fixture
     if ($createEmptyDatabase) {
         self::$fixture->setUp();
         \Piwik\Option::set('benchmark_fixture_name', $fixtureName);
     }
 }
开发者ID:Abine,项目名称:piwik,代码行数:35,代码来源:BenchmarkTestCase.php

示例2: 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);
     }
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:36,代码来源:UpdateCheck.php

示例3: runScheduledTasks

 /**
  * Tracker requests will automatically trigger the Scheduled tasks.
  * This is useful for users who don't setup the cron,
  * but still want daily/weekly/monthly PDF reports emailed automatically.
  *
  * This is similar to calling the API CoreAdminHome.runScheduledTasks
  */
 public function runScheduledTasks()
 {
     $now = time();
     // Currently, there are no hourly tasks. When there are some,
     // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic)
     $minimumInterval = TrackerConfig::getConfigValue('scheduled_tasks_min_interval');
     // If the user disabled browser archiving, he has already setup a cron
     // To avoid parallel requests triggering the Scheduled Tasks,
     // Get last time tasks started executing
     $cache = Cache::getCacheGeneral();
     if ($minimumInterval <= 0 || empty($cache['isBrowserTriggerEnabled'])) {
         Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
         return;
     }
     $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;
     if (defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS || $cache['lastTrackerCronRun'] === false || $nextRunTime < $now) {
         $cache['lastTrackerCronRun'] = $now;
         Cache::setCacheGeneral($cache);
         Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
         Common::printDebug('-> Scheduled Tasks: Starting...');
         $invokeScheduledTasksUrl = "?module=API&format=csv&convertToUnicode=0&method=CoreAdminHome.runScheduledTasks&trigger=archivephp";
         $cliMulti = new CliMulti();
         $cliMulti->runAsSuperUser();
         $responses = $cliMulti->request(array($invokeScheduledTasksUrl));
         $resultTasks = reset($responses);
         Common::printDebug($resultTasks);
         Common::printDebug('Finished Scheduled Tasks.');
     } else {
         Common::printDebug("-> Scheduled tasks not triggered.");
     }
     Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
 }
开发者ID:cemo,项目名称:piwik,代码行数:39,代码来源:ScheduledTasksRunner.php

示例4: testWebArchiving

 public function testWebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
         $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
         $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
         $this->markTestSkipped($message);
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertContains('Starting Piwik reports archiving...', $output);
     $this->assertContains('Archived website id = 1', $output);
     $this->assertContains('Done archiving!', $output);
     $this->compareArchivePhpOutputAgainstExpected($output);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:28,代码来源:ArchiveWebTest.php

示例5: recordComponentSuccessfullyUpdated

 /**
  * Record version of successfully completed component update
  *
  * @param string $name
  * @param string $version
  */
 public static function recordComponentSuccessfullyUpdated($name, $version)
 {
     try {
         Option::set(self::getNameInOptionTable($name), $version, $autoLoad = 1);
     } catch (\Exception $e) {
         // case when the option table is not yet created (before 0.2.10)
     }
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:14,代码来源:Updater.php

示例6: update

 static function update()
 {
     // when updating from pre-3.0 versions, set use_ldap_for_authentication to 0 and make sure
     // a warning displays in the UI to not set it to 1
     \Piwik\Config::getInstance()->LoginLdap['use_ldap_for_authentication'] = 0;
     \Piwik\Config::getInstance()->forceSave();
     Option::set('LoginLdap_updatedFromPre3_0', 1);
 }
开发者ID:heiglandreas,项目名称:plugin-LoginLdap,代码行数:8,代码来源:3.0.0.php

示例7: setSiteIdsToArchive

 public function setSiteIdsToArchive($siteIds)
 {
     if (!empty($siteIds)) {
         Option::set('SharedSiteIdsToArchive', implode(',', $siteIds));
     } else {
         Option::delete('SharedSiteIdsToArchive');
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:8,代码来源:SharedSiteIds.php

示例8: cacheDataByArchiveNameReports

 /**
  * Caches the intermediate DataTables used in the getIndividualReportsSummary and
  * getIndividualMetricsSummary reports in the option table.
  */
 public function cacheDataByArchiveNameReports()
 {
     $api = API::getInstance();
     $api->getIndividualReportsSummary(true);
     $api->getIndividualMetricsSummary(true);
     $now = Date::now()->getLocalized(Date::DATE_FORMAT_SHORT);
     Option::set(DBStats::TIME_OF_LAST_TASK_RUN_OPTION, $now);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:12,代码来源:Tasks.php

示例9: setSiteIdsToArchive

 public function setSiteIdsToArchive($siteIds)
 {
     if (!empty($siteIds)) {
         Option::set($this->optionName, implode(',', $siteIds));
     } else {
         Option::delete($this->optionName);
     }
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:8,代码来源:SharedSiteIds.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     $this->manager = new PrivacyManager();
     \Piwik\Option::set('delete_logs_enable', 1);
     \Piwik\Option::set('delete_logs_older_than', 270);
     \Piwik\Option::set('delete_reports_keep_week_reports', 1);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:8,代码来源:PrivacyManagerTest.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     self::updateDatabase();
     self::createWebsite("2012-01-01 00:00:00");
     $fakeTasks = array('Piwik\\Plugins\\ExamplePlugin\\Tasks.myTask' => Date::factory("2012-01-02 02:33:45")->getTimestampUTC(), 'Piwik\\Plugins\\CoreUpdater\\Tasks.sendNotificationIfUpdateAvailable' => Date::factory("2012-03-04 13:45:56")->getTimestampUTC(), 'Piwik\\Plugins\\CorePluginsAdmin\\Tasks.sendNotificationIfUpdatesAvailable' => Date::factory("2012-02-12 15:12:10")->getTimestampUTC());
     Option::set('TaskScheduler.timetable', serialize($fakeTasks));
 }
开发者ID:diosmosis,项目名称:plugin-TasksTimetable,代码行数:8,代码来源:FakeTasksFixture.php

示例12: set

 /**
  * @param string|null|false $licenseKey `null` or `false` will delete an existing a license key
  */
 public function set($licenseKey)
 {
     if (!isset($licenseKey) || $licenseKey === false) {
         $this->delete();
     } else {
         Option::set('marketplace_license_key', (string) $licenseKey);
     }
 }
开发者ID:piwik,项目名称:piwik,代码行数:11,代码来源:LicenseKey.php

示例13: cacheDataByArchiveNameReports

 /**
  * Caches the intermediate DataTables used in the getIndividualReportsSummary and
  * getIndividualMetricsSummary reports in the option table.
  */
 public function cacheDataByArchiveNameReports()
 {
     $api = API::getInstance();
     $api->getIndividualReportsSummary(true);
     $api->getIndividualMetricsSummary(true);
     $now = Date::now()->getLocalized("%longYear%, %shortMonth% %day%");
     Option::set(DBStats::TIME_OF_LAST_TASK_RUN_OPTION, $now);
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:12,代码来源:Tasks.php

示例14: test_UpdateCommand_DoesNotExecuteUpdate_IfPiwikUpToDate

 public function test_UpdateCommand_DoesNotExecuteUpdate_IfPiwikUpToDate()
 {
     Option::set('version_core', Version::VERSION);
     $result = $this->applicationTester->run(array('command' => 'core:update', '--yes' => true));
     $this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
     // check no update occurred
     $this->assertContains("Everything is already up to date.", $this->applicationTester->getDisplay());
     $this->assertEquals(Version::VERSION, Option::get('version_core'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:UpdateTest.php

示例15: test_construct_CorrectlyConvertsOldListValues

 public function test_construct_CorrectlyConvertsOldListValues()
 {
     $oldItems = array('2015_01' => array(1, 2, 3), '2013_02' => array(3), 3 => '2015_03', '2014_01' => array(), 4 => '2015_06');
     Option::set(ArchivesToPurgeDistributedList::OPTION_INVALIDATED_DATES_SITES_TO_PURGE, serialize($oldItems));
     $list = new ArchivesToPurgeDistributedList();
     $items = $list->getAll();
     $expected = array('2015_03', '2015_06', '2015_01', '2013_02', '2014_01');
     $this->assertEquals($expected, array_values($items));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:ArchivesToPurgeDistributedListTest.php


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