本文整理汇总了PHP中Piwik::createConfigObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::createConfigObject方法的具体用法?PHP Piwik::createConfigObject怎么用?PHP Piwik::createConfigObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::createConfigObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCacheWebsiteAttributes
/**
* Returns array containing data about the website: goals, URLs, etc.
*
* @param int $idSite
* @return array
*/
static function getCacheWebsiteAttributes($idSite)
{
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
static $cache = null;
if (is_null($cache)) {
$cache = new Piwik_CacheFile('tracker');
}
$filename = $idSite;
$cacheContent = $cache->get($filename);
if ($cacheContent !== false) {
return $cacheContent;
}
if (defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) {
require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php';
require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
Zend_Registry::set('db', Piwik_Tracker::getDatabase());
Piwik::createAccessObject();
Piwik::createConfigObject();
Piwik::setUserIsSuperUser();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
}
$content = array();
Piwik_PostEvent('Common.fetchWebsiteAttributes', $content, $idSite);
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
$cache->set($filename, $content);
}
return $content;
}
示例2: update
static function update()
{
$config = Zend_Registry::get('config');
$salt = Piwik_Common::generateUniqId();
try {
if(isset($config->superuser->salt))
{
return;
}
if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
{
$superuser_info = $config->superuser->toArray();
$superuser_info['salt'] = $salt;
$config->superuser = $superuser_info;
$config->__destruct();
Piwik::createConfigObject();
return;
}
} catch(Exception $e) { }
throw new Piwik_Updater_UpdateErrorException("Edit config.ini.php and add below <code>[superuser]</code> the following line <br/><code>salt = $salt</code>");
}
示例3: update
static function update()
{
$config = Zend_Registry::get('config');
$dbInfos = $config->database->toArray();
if(!isset($dbInfos['schema']))
{
try {
if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
{
$dbInfos['schema'] = 'Myisam';
$config->database = $dbInfos;
$config->__destruct();
Piwik::createConfigObject();
}
else
{
throw new Exception('mandatory update failed');
}
} catch(Exception $e) {
throw new Piwik_Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[database]</code> the following line: <br /><code>schema = Myisam</code>");
}
}
Piwik_Updater::updateDatabase(__FILE__, self::getSql());
}
示例4: setUp
public function setUp()
{
parent::setUp();
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_DataTable_Manager::getInstance()->deleteAll();
}
示例5: initCorePiwikInTrackerMode
protected static function initCorePiwikInTrackerMode()
{
static $init = false;
if (!empty($GLOBALS['PIWIK_TRACKER_MODE']) && $init === false) {
$init = true;
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
try {
$access = Zend_Registry::get('access');
} catch (Exception $e) {
Piwik::createAccessObject();
}
try {
$config = Zend_Registry::get('config');
} catch (Exception $e) {
Piwik::createConfigObject();
}
try {
$db = Zend_Registry::get('db');
} catch (Exception $e) {
Piwik::createDatabaseObject();
}
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsToLoad = Zend_Registry::get('config')->Plugins->Plugins->toArray();
$pluginsForcedNotToLoad = Piwik_Tracker::getPluginsNotToLoad();
$pluginsToLoad = array_diff($pluginsToLoad, $pluginsForcedNotToLoad);
$pluginsManager->loadPlugins($pluginsToLoad);
}
}
示例6: test_fetchRemoteFile
public function test_fetchRemoteFile()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$methods = array('curl', 'fopen', 'socket');
$this->assertTrue(in_array(Piwik_Http::getTransportMethod(), $methods));
foreach ($methods as $method) {
$version = '';
try {
$version = Piwik_Http::sendHttpRequestBy($method, 'http://api.piwik.org/1.0/getLatestVersion/', 5);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$this->assertTrue(preg_match('/^([0-9.]+)$/', $version), $method);
}
$destinationPath = PIWIK_USER_PATH . '/tmp/latest/LATEST';
try {
Piwik_Http::fetchRemoteFile('http://api.piwik.org/1.0/getLatestVersion/', $destinationPath, 3);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$this->assertTrue(filesize($destinationPath) > 0);
$destinationPath = PIWIK_USER_PATH . '/tmp/latest/latest.zip';
try {
Piwik_Http::fetchRemoteFile('http://piwik.org/latest.zip', $destinationPath, 3);
} catch (Exception $e) {
var_dump($e->getMessage());
}
$this->assertTrue(filesize($destinationPath) > 0);
}
示例7: test_callableApiMethods_doNotFail
function test_callableApiMethods_doNotFail()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik::createLogObject();
Piwik::createAccessObject();
Piwik::createDatabaseObject();
Piwik::setUserIsSuperUser();
Piwik_Translate::getInstance()->loadEnglishTranslation();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->loadPlugins(Piwik_Config::getInstance()->Plugins['Plugins']);
Piwik_SitesManager_API::getInstance()->addSite("name", "http://example.org");
$apiGenerator = new Piwik_API_DocumentationGenerator_CallAllMethods();
$requestUrls = $apiGenerator->getAllRequestsWithParameters();
$this->assertTrue(count($requestUrls) > 20);
foreach ($requestUrls as $url) {
$call = new Piwik_API_Request($url);
$output = $call->process();
// var_dump($url);
// var_dump($output);
$this->assertTrue(!empty($output));
}
Piwik_Translate::getInstance()->unloadEnglishTranslation();
$this->pass();
}
示例8: setUp
/**
* Setup the database and create the base tables for all tests
*/
public function setUp()
{
parent::setUp();
try {
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$dbConfig = Piwik_Config::getInstance()->database;
$dbName = $dbConfig['dbname'];
$dbConfig['dbname'] = null;
Piwik::createDatabaseObject($dbConfig);
Piwik::dropDatabase();
Piwik::createDatabase($dbName);
Piwik::disconnectDatabase();
Piwik::createDatabaseObject();
Piwik::createTables();
Piwik::createLogObject();
Piwik_PluginsManager::getInstance()->loadPlugins(array());
} catch (Exception $e) {
$this->fail("TEST INITIALIZATION FAILED: " . $e->getMessage());
}
include "DataFiles/SearchEngines.php";
include "DataFiles/Languages.php";
include "DataFiles/Countries.php";
include "DataFiles/Currencies.php";
include "DataFiles/LanguageToCountry.php";
}
示例9: test_isAcceptableRemoteUrl
public function test_isAcceptableRemoteUrl()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$data = array('http://piwik.org/' => array(true), 'http://piwik.org' => array(true), 'http://qa.piwik.org/' => array(true), 'http://forum.piwik.org/' => array(true), 'http://dev.piwik.org/' => array(true), 'http://demo.piwik.org/' => array(true), 'http://www.piwik.org/' => array(false), 'https://piwik.org/' => array(false), 'http://example.org/' => array(false));
foreach ($data as $url => $expected) {
$this->assertEqual(Piwik_Proxy_Controller::isPiwikUrl($url), $expected[0], $url);
}
}
示例10: test_getAcceptableOrigins
public function test_getAcceptableOrigins()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$tests = array('example.com' => array('http://example.com', 'https://example.com'), 'example.com:80' => array('http://example.com', 'https://example.com'), 'example.com:443' => array('http://example.com', 'https://example.com'), 'example.com:8080' => array('http://example.com', 'https://example.com', 'http://example.com:8080', 'https://example.com:8080'));
foreach ($tests as $host => $expected) {
$_SERVER['HTTP_HOST'] = $host;
$this->assertEqual(Piwik_Nonce::getAcceptableOrigins(), $expected, $host);
}
}
示例11: setUp
function setUp()
{
parent::setUp();
$pseudoMockAccess = new MockPiwik_Access();
$pseudoMockAccess->setReturnValue('isSuperUser', true);
Zend_Registry::set('access', $pseudoMockAccess);
Piwik::createConfigObject();
$user_agents = array('Mozilla/6.0 (Macintosh; I; Intel Mac OS X 11_7_9; de-LI; rv:1.9b4) Gecko/2012010317 Firefox/10.0a4', 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1');
$_SERVER['HTTP_USER_AGENT'] = $user_agents[mt_rand(0, count($user_agents) - 1)];
}
示例12: update
static function update()
{
$config = Zend_Registry::get('config');
$salt = Piwik_Common::generateUniqId();
if(!isset($config->superuser->salt))
{
try {
if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
{
$superuser_info = $config->superuser->toArray();
$superuser_info['salt'] = $salt;
$config->superuser = $superuser_info;
$config->__destruct();
Piwik::createConfigObject();
}
else
{
throw new Exception('mandatory update failed');
}
} catch(Exception $e) {
throw new Piwik_Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br/><code>salt = $salt</code>");
}
}
$config = Zend_Registry::get('config');
$plugins = $config->Plugins->toArray();
if(!in_array('MultiSites', $plugins))
{
try {
if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
{
$plugins[] = 'MultiSites';
$config->Plugins = $plugins;
$config->__destruct();
Piwik::createConfigObject();
}
else
{
throw new Exception('optional update failed');
}
} catch(Exception $e) {
throw new Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!");
}
}
Piwik_Updater::updateDatabase(__FILE__, array(
'ALTER TABLE `'. Piwik::prefixTable('log_action') .'`
CHANGE `name` `name` TEXT' => false,
));
}
示例13: setUp
public function setUp()
{
parent::setUp();
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
// setup the access layer (required in Segment contrustor testing if anonymous is allowed to use segments)
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Zend_Registry::set('access', $pseudoMockAccess);
// Load and install plugins
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->loadPlugins(Piwik_Config::getInstance()->Plugins['Plugins']);
}
示例14: test_ajaxLibraryVersions
function test_ajaxLibraryVersions()
{
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
$jqueryJs = file_get_contents(PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery.js', false, NULL, 0, 512);
$this->assertTrue(preg_match('/jQuery (?:JavaScript Library )?v?([0-9.]+)/', $jqueryJs, $matches));
$this->assertEqual($matches[1], Piwik_Config::getInstance()->General['jquery_version']);
$jqueryuiJs = file_get_contents(PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery-ui.js', false, NULL, 0, 512);
$this->assertTrue(preg_match('/jQuery UI (?:- v)?([0-9.]+)/', $jqueryuiJs, $matches));
$this->assertEqual($matches[1], Piwik_Config::getInstance()->General['jqueryui_version']);
$swfobjectJs = file_get_contents(PIWIK_DOCUMENT_ROOT . '/libs/swfobject/swfobject.js', false, NULL, 0, 512);
$this->assertTrue(preg_match('/SWFObject v([0-9.]+)/', $swfobjectJs, $matches));
$this->assertEqual($matches[1], Piwik_Config::getInstance()->General['swfobject_version']);
}
示例15: update
static function update()
{
$config = Zend_Registry::get('config');
try {
if(is_writable( Piwik_Config::getDefaultUserConfigPath() )) {
$plugins = $config->Plugins->toArray();
$plugins[] = 'MultiSites';
$config->Plugins = $plugins;
$config->__destruct();
Piwik::createConfigObject();
return;
}
} catch(Exception $e) { }
throw new Piwik_Updater_UpdateErrorException("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!");
}