本文整理汇总了PHP中SiteConfig::config方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteConfig::config方法的具体用法?PHP SiteConfig::config怎么用?PHP SiteConfig::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteConfig
的用法示例。
在下文中一共展示了SiteConfig::config方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanEditPages
public function testCanEditPages()
{
$config = $this->objFromFixture('SiteConfig', 'default');
// Log in without pages admin access
$this->logInWithPermission('CMS_ACCESS_AssetAdmin');
$this->assertFalse($config->canEditPages());
// Login with necessary edit permission
$perms = SiteConfig::config()->required_permission;
$this->logInWithPermission(reset($perms));
$this->assertTrue($config->canEditPages());
}
示例2: testAvailableThemes
public function testAvailableThemes()
{
$config = SiteConfig::current_site_config();
$ds = DIRECTORY_SEPARATOR;
$testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes';
if (file_exists($testThemeBaseDir)) {
Filesystem::removeFolder($testThemeBaseDir);
}
mkdir($testThemeBaseDir);
mkdir($testThemeBaseDir . $ds . 'blackcandy');
mkdir($testThemeBaseDir . $ds . 'blackcandy_blog');
mkdir($testThemeBaseDir . $ds . 'darkshades');
mkdir($testThemeBaseDir . $ds . 'darkshades_blog');
$themes = $config->getAvailableThemes($testThemeBaseDir);
$this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme');
$this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme');
SiteConfig::config()->disabled_themes = array('darkshades');
$themes = $config->getAvailableThemes($testThemeBaseDir);
$this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available');
Filesystem::removeFolder($testThemeBaseDir);
}
示例3: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$services = SiteConfig::config()->available_services;
if (!$services) {
$services = array_keys(self::listAvailableMediaServices());
}
if (in_array('twitter', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('TwitterUsername', _t('Socialstream.TwitterUsername', 'Twitter Username')));
}
if (in_array('twitter_hashtag', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('TwitterHashtag', _t('Socialstream.TwitterHashtag', 'Twitter Hashtag')));
}
if (in_array('facebook_page', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('FacebookPage', _t('Socialstream.FacebookPage', 'Facebook Page')));
}
if (in_array('vimeo', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('VimeoUsername', _t('Socialstream.VimeoUsername', 'Vimeo Username')));
}
if (in_array('youtube', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('YoutubeUsername', _t('Socialstream.YoutubeUsername', 'Youtube Username')));
}
if (in_array('dailymotion', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('DailymotionUsername', _t('Socialstream.DailymotionUsername', 'Dailymotion Username')));
}
if (in_array('rss', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('RssFeed', _t('Socialstream.RssFeed', 'Rss Feed')));
}
if (in_array('flickr', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('FlickrUsername', _t('Socialstream.FlickrUsername', 'Flickr Username')));
}
if (in_array('github', $services)) {
$fields->addFieldToTab('Root.Social', new TextField('GithubUsername', _t('Socialstream.GithubUsername', 'Github Username')));
}
$fields->addFieldToTab('Root.Social', $wl = new ListboxField('LifestreamWhitelist', _t('Socialstream.LifestreamWhitelist', 'Lifestream Whitelist'), array_combine($services, $services)));
$wl->setMultiple(true);
$wl->setDescription('A list of services to display on the Lifestream. If left blank, all configured streams will be used.');
$fields->addFieldToTab('Root.Social', new NumericField('LifestreamItems', _t('Socialstream.LifestreamItems', 'Lifestream Items')));
return $fields;
}
示例4: testCreatePermissions
public function testCreatePermissions()
{
// Test logged out users cannot create
$this->logOut();
$this->assertFalse(singleton('SiteTree')->canCreate());
// Login with another permission
$this->logInWithPermission('DUMMY');
$this->assertFalse(singleton('SiteTree')->canCreate());
// Login with basic CMS permission
$perms = SiteConfig::config()->required_permission;
$this->logInWithPermission(reset($perms));
$this->assertTrue(singleton('SiteTree')->canCreate());
// Test creation underneath a parent which this user doesn't have access to
$parent = $this->objFromFixture('Page', 'about');
$this->assertFalse(singleton('SiteTree')->canCreate(null, array('Parent' => $parent)));
// Test creation underneath a parent which doesn't allow a certain child
$parentB = new SiteTreeTest_ClassB();
$parentB->Title = 'Only Allows SiteTreeTest_ClassC';
$parentB->write();
$this->assertTrue(singleton('SiteTreeTest_ClassA')->canCreate(null));
$this->assertFalse(singleton('SiteTreeTest_ClassA')->canCreate(null, array('Parent' => $parentB)));
$this->assertTrue(singleton('SiteTreeTest_ClassC')->canCreate(null, array('Parent' => $parentB)));
}