本文整理汇总了PHP中Subsite类的典型用法代码示例。如果您正苦于以下问题:PHP Subsite类的具体用法?PHP Subsite怎么用?PHP Subsite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Subsite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testEachSubsiteHasAUniqueSiteConfig
function testEachSubsiteHasAUniqueSiteConfig()
{
$subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
$subsite2 = $this->objFromFixture('Subsite', 'domaintest2');
$this->assertTrue(is_array(singleton('SiteConfigSubsites')->extraStatics()));
Subsite::changeSubsite(0);
$sc = SiteConfig::current_site_config();
$sc->Title = 'RootSite';
$sc->write();
Subsite::changeSubsite($subsite1->ID);
$sc = SiteConfig::current_site_config();
$sc->Title = 'Subsite1';
$sc->write();
Subsite::changeSubsite($subsite2->ID);
$sc = SiteConfig::current_site_config();
$sc->Title = 'Subsite2';
$sc->write();
Subsite::changeSubsite(0);
$this->assertEquals(SiteConfig::current_site_config()->Title, 'RootSite');
Subsite::changeSubsite($subsite1->ID);
$this->assertEquals(SiteConfig::current_site_config()->Title, 'Subsite1');
Subsite::changeSubsite($subsite2->ID);
$this->assertEquals(SiteConfig::current_site_config()->Title, 'Subsite2');
$keys = SiteConfig::current_site_config()->extend('cacheKeyComponent');
$this->assertContains('subsite-' . $subsite2->ID, $keys);
}
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:26,代码来源:SiteConfigSubsitesTest.php
示例2: alternateFilepathForErrorcode
/**
* Alter file path to generated a static (static) error page file to handle error page template on different sub-sites
*
* @see Error::get_filepath_for_errorcode()
*
* FIXME since {@link Subsite::currentSubsite()} partly relies on Session, viewing other sub-site (including main site) between
* opening ErrorPage in the CMS and publish ErrorPage causes static error page to get generated incorrectly.
*/
function alternateFilepathForErrorcode($statusCode, $locale = null)
{
$static_filepath = Object::get_static($this->owner->ClassName, 'static_filepath');
$subdomainPart = "";
// Try to get current subsite from session
$subsite = Subsite::currentSubsite(false);
// since this function is called from Page class before the controller is created, we have to get subsite from domain instead
if (!$subsite) {
$subsiteID = Subsite::getSubsiteIDForDomain();
if ($subsiteID != 0) {
$subsite = DataObject::get_by_id("Subsite", $subsiteID);
} else {
$subsite = null;
}
}
if ($subsite) {
$subdomain = $subsite->domain();
$subdomainPart = "-{$subdomain}";
}
if (singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) {
$filepath = $static_filepath . "/error-{$statusCode}-{$locale}{$subdomainPart}.html";
} else {
$filepath = $static_filepath . "/error-{$statusCode}{$subdomainPart}.html";
}
return $filepath;
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:34,代码来源:ErrorPageSubsite.php
示例3: getURLPrefix
public function getURLPrefix()
{
$url = parent::getURLPrefix();
if (Director::isDev() || Director::isTest()) {
$urlarray = parse_url($url);
// define override
if (defined('DEV_SUBSITE_' . Subsite::currentSubsiteID())) {
$subsiteurl = 'DEV_SUBSITE_' . Subsite::currentSubsiteID();
return constant($subsiteurl) . $urlarray['path'];
}
if (!Subsite::currentSubsite() instanceof Subsite) {
return $url;
}
// if set in config settings
$currentDomain = Subsite::currentSubsite()->getPrimarySubsiteDomain();
if (Director::isTest()) {
$currentDomain = Subsite::currentSubsite()->TestDomainID ? Subsite::currentSubsite()->TestDomain() : $currentDomain;
}
if (Director::isDev()) {
$currentDomain = Subsite::currentSubsite()->DevDomainID ? Subsite::currentSubsite()->DevDomain() : $currentDomain;
}
if (!$currentDomain) {
return $url;
}
return $currentDomain->getFullProtocol() . $currentDomain->Domain . $urlarray['path'];
}
return $url;
}
开发者ID:otago,项目名称:subsites-domains,代码行数:28,代码来源:SubsiteSiteTreeURLSegmentField.php
示例4: updateCMSFields
function updateCMSFields(FieldList $fields)
{
if (class_exists('Subsite')) {
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}
return $fields;
}
开发者ID:helpfulrobot,项目名称:titledk-silverstripe-subsite-utilities,代码行数:7,代码来源:SubsiteDataObjectExtension.php
示例5: testWritingSubsiteID
function testWritingSubsiteID()
{
$this->objFromFixture('Member', 'admin')->logIn();
$subsite = $this->objFromFixture('Subsite', 'domaintest1');
FileSubsites::$default_root_folders_global = true;
Subsite::changeSubsite(0);
$file = new File();
$file->write();
$file->onAfterUpload();
$this->assertEquals((int) $file->SubsiteID, 0);
Subsite::changeSubsite($subsite->ID);
$this->assertTrue($file->canEdit());
$file = new File();
$file->write();
$this->assertEquals((int) $file->SubsiteID, 0);
$this->assertTrue($file->canEdit());
FileSubsites::$default_root_folders_global = false;
Subsite::changeSubsite($subsite->ID);
$file = new File();
$file->write();
$this->assertEquals($file->SubsiteID, $subsite->ID);
// Test inheriting from parent folder
$folder = new Folder();
$folder->write();
$this->assertEquals($folder->SubsiteID, $subsite->ID);
FileSubsites::$default_root_folders_global = true;
$file = new File();
$file->ParentID = $folder->ID;
$file->onAfterUpload();
$this->assertEquals($folder->SubsiteID, $file->SubsiteID);
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:31,代码来源:FileSubsitesTest.php
示例6: onBeforeWrite
function onBeforeWrite()
{
if (!$this->owner->ID && !$this->owner->SubsiteID) {
$this->owner->SubsiteID = Subsite::currentSubsiteID();
}
parent::onBeforeWrite();
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:7,代码来源:Ext_Subsites_Commerce.php
示例7: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
if ($this->modelClass == 'Order') {
$fields = $form->Fields();
$gridField = $fields->fieldByName('Order');
// Bulk manager
$manager = new GridFieldBulkManager();
$manager->removeBulkAction("bulkEdit");
$manager->removeBulkAction("unLink");
$manager->removeBulkAction("delete");
$manager->addBulkAction('paid', 'Mark Paid', 'CommerceGridFieldBulkAction_Paid');
$manager->addBulkAction('processing', 'Mark Processing', 'CommerceGridFieldBulkAction_Processing');
$manager->addBulkAction('dispatched', 'Mark Dispatched', 'CommerceGridFieldBulkAction_Dispatched');
// Add dispatch button
$field_config = $gridField->getConfig();
$field_config->addComponent($manager);
// Update list of items for subsite (if used)
if (class_exists('Subsite')) {
$list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID()));
$gridField->setList($list);
}
}
$this->extend("updateEditForm", $form);
return $form;
}
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:26,代码来源:OrderAdmin.php
示例8: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->removeByName('SubsiteID');
if (class_exists('Subsite')) {
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}
}
开发者ID:helpfulrobot,项目名称:adrexia-subsite-modeladmins,代码行数:7,代码来源:SubsiteModelExtension.php
示例9: subsiteCMSShowInMenu
public function subsiteCMSShowInMenu()
{
if (Subsite::currentSubsite()) {
return false;
}
return true;
}
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-subsites-extras,代码行数:7,代码来源:SubsiteActiveMenuExtension.php
示例10: onBeforeInit
/**
* @return void
*/
public function onBeforeInit()
{
// Check if we are runing a dev build, if so check if DB needs
// upgrading
$controller = $this->owner->request->param("Controller");
$action = $this->owner->request->param("Action");
global $project;
// Only check if the DB needs upgrading on a dev build
if ($controller == "DevelopmentAdmin" && $action == "build") {
// Now check if the files we need are installed
// Check if we have the files we need, if not, create them
if (!class_exists("Category")) {
copy(BASE_PATH . "/catalogue/scaffold/Category", BASE_PATH . "/{$project}/code/model/Category.php");
}
if (!class_exists("Category_Controller")) {
copy(BASE_PATH . "/catalogue/scaffold/Category_Controller", BASE_PATH . "/{$project}/code/control/Category_Controller.php");
}
if (!class_exists("Product")) {
copy(BASE_PATH . "/catalogue/scaffold/Product", BASE_PATH . "/{$project}/code/model/Product.php");
}
if (!class_exists("Product_Controller")) {
copy(BASE_PATH . "/catalogue/scaffold/Product_Controller", BASE_PATH . "/{$project}/code/control/Product_Controller.php");
}
}
if ($controller != "DevelopmentAdmin") {
if (class_exists('Subsite') && Subsite::currentSubsite()) {
// Set the location
i18n::set_locale(Subsite::currentSubsite()->Language);
}
}
}
开发者ID:alialamshahi,项目名称:silverstripe-catalogue-prowall,代码行数:34,代码来源:CatalogueControllerExtension.php
示例11: objFromFixture
/**
* Avoid subsites filtering on fixture fetching.
*/
function objFromFixture($class, $id)
{
Subsite::disable_subsite_filter(true);
$obj = parent::objFromFixture($class, $id);
Subsite::disable_subsite_filter(false);
return $obj;
}
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:10,代码来源:BaseSubsiteTest.php
示例12: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$subsites = class_exists('Subsite');
$onMainSite = TRUE;
$currentSubsiteID = 0;
$currentSiteConfig = SiteConfig::current_site_config();
if ($subsites) {
$currentSubsiteID = Subsite::currentSubsiteID();
if ($currentSubsiteID) {
$onMainSite = FALSE;
}
$mainSiteConfig = SiteConfig::get()->filter('SubsiteID', 0)->first();
} else {
$mainSiteConfig = $currentSiteConfig;
}
// Add mailblock CMS fields.
if (Permission::check('MANAGE_MAILBLOCK') && ($mainSiteConfig->getField('MailblockApplyPerSubsite') || $onMainSite)) {
$enabled = $currentSiteConfig->getField('MailblockEnabled');
$tabSet = new TabSet('Mailblock', $settingsTab = $this->basicSettingsFields(), $advancedSettingsTab = $this->advancedSettingsFields($onMainSite, $currentSubsiteID), $testTab = $this->testEmailCMSFields($enabled));
$fields->addFieldToTab('Root', $tabSet);
$hiddenFields = array('MailblockEnabledOnLive', 'MailblockOverrideConfiguration', 'MailblockRecipients', 'MailblockWhitelist');
if ($subsites && $currentSubsiteID == 0) {
$hiddenFields[] = 'MailblockApplyPerSubsite';
}
foreach ($hiddenFields as $field) {
$field = $fields->dataFieldByName($field);
$field->displayIf('MailblockEnabled')->isChecked();
}
}
}
开发者ID:signify-nz,项目名称:silverstripe-mailblock,代码行数:30,代码来源:MailblockSiteConfig.php
示例13: getCMSFields
function getCMSFields()
{
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
if (!$subsites) {
$subsites = new DataObjectSet();
}
if (Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
}
if ($subsites->Count()) {
$subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
}
// Setup the linking to the original page.
$pageSelectionField = new SubsitesTreeDropdownField("RelatedPageID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
if (isset($_GET['RelatedPageID_SubsiteID'])) {
$pageSelectionField->setSubsiteID($_GET['RelatedPageID_SubsiteID']);
}
$pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
if ($subsites->Count()) {
$fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
} else {
$fields = new FieldSet($pageSelectionField);
}
return $fields;
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:25,代码来源:RelatedPageLink.php
示例14: process
/**
* To process this job, we need to get the next page whose ID is the next greater than the last
* processed. This way we don't need to remember a bunch of data about what we've processed
*/
public function process()
{
if (ClassInfo::exists('Subsite')) {
Subsite::disable_subsite_filter();
}
$class = $this->reindexType;
$pages = $class::get();
$pages = $pages->filter(array('ID:GreaterThan' => $this->lastIndexedID));
$pages = $pages->limit(Config::inst()->get(__CLASS__, 'at_a_time'));
$pages = $pages->sort('ID ASC');
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
if (!$pages || !$pages->count()) {
$this->isComplete = true;
return;
}
$mode = Versioned::get_reading_mode();
Versioned::reading_stage('Stage');
// index away
$service = singleton('SolrSearchService');
$live = array();
$stage = array();
$all = array();
foreach ($pages as $page) {
// Make sure the current page is not orphaned.
if ($page->ParentID > 0) {
$parent = $page->getParent();
if (is_null($parent) || $parent === false) {
continue;
}
}
// Appropriately index the current page, taking versioning into account.
if ($page->hasExtension('Versioned')) {
$stage[] = $page;
$base = $page->baseTable();
$idField = '"' . $base . '_Live"."ID"';
$livePage = Versioned::get_one_by_stage($page->ClassName, 'Live', $idField . ' = ' . $page->ID);
if ($livePage) {
$live[] = $livePage;
}
} else {
$all[] = $page;
}
$this->lastIndexedID = $page->ID;
}
if (count($all)) {
$service->indexMultiple($all);
}
if (count($stage)) {
$service->indexMultiple($stage, 'Stage');
}
if (count($live)) {
$service->indexMultiple($live, 'Live');
}
Versioned::set_reading_mode($mode);
$this->lastIndexedID = $page->ID;
$this->currentStep += $pages->count();
}
开发者ID:nyeholt,项目名称:silverstripe-solr,代码行数:63,代码来源:SolrReindexJob.php
示例15: run
public function run($request)
{
$groups = Group::get();
echo 'Pass ?drop=1 to drop groups without members<br/>';
echo 'Want more dropping? Pass ?permission=1 to also drop groups without permissions even if they have members<br/>';
echo 'Pass ?merge=1 to merge groups with the same code<br/>';
echo 'Want to merge across subsites ? Pass ?subsite=1 to disable subsite filters<br/>';
echo '<hr/>';
$merge = $request->getVar('merge');
$drop = $request->getVar('drop');
$dropNoPermission = $request->getVar('permission');
$subsite = $request->getVar('subsite');
if (class_exists('Subsite') && $subsite) {
Subsite::$disable_subsite_filter = true;
}
if ($drop) {
DB::alteration_message("Dropping groups with no members");
if ($dropNoPermission) {
DB::alteration_message("Also dropping groups with no permissions");
}
foreach ($groups as $group) {
if (!$group->Members()->count()) {
DB::alteration_message("Removing group {$group->ID} because it has no members", "deleted");
$group->delete();
}
if ($dropNoPermission) {
$c = $group->Permissions()->count();
if (!$c) {
DB::alteration_message("Removing group {$group->ID} because it has no permissions", "deleted");
$group->delete();
}
}
}
}
if ($merge) {
DB::alteration_message("Merging groups with duplicated codes");
$index = array();
/* @var $group Group */
foreach ($groups as $group) {
DB::alteration_message("Found group " . $group->Code);
if (!isset($index[$group->Code])) {
$index[$group->Code] = $group;
DB::alteration_message("First instance of group, do not merge");
continue;
}
$mergeGroup = $index[$group->Code];
DB::alteration_message('Merge group ' . $group->ID . ' with ' . $mergeGroup->ID, 'repaired');
$i = 0;
foreach ($group->Members() as $m) {
$i++;
$mergeGroup->Members()->add($m);
}
DB::alteration_message('Added ' . $i . ' members to group', 'created');
DB::alteration_message("Group " . $group->ID . ' was deleted', 'deleted');
$group->delete();
}
}
DB::alteration_message('All done!');
}
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:59,代码来源:RemoveEmptyGroupsTask.php
示例16: getQuery
function getQuery()
{
$oldState = Subsite::$disable_subsite_filter;
Subsite::$disable_subsite_filter = true;
$return = parent::getQuery();
Subsite::$disable_subsite_filter = $oldState;
return $return;
}
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:8,代码来源:SubsiteAgnosticTableListField.php
示例17: updateEditForm
public function updateEditForm($form)
{
$gridField = $form->Fields()->fieldByName($this->sanitiseClassNameExtension($this->owner->modelClass));
if (class_exists('Subsite')) {
$list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID()));
$gridField->setList($list);
}
}
开发者ID:helpfulrobot,项目名称:adrexia-subsite-modeladmins,代码行数:8,代码来源:SubsiteAdminExtension.php
示例18: augmentSQL
/**
* @param SQLQuery $query
* @param DataQuery $dataQuery
*/
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
{
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
if (class_exists('Subsite')) {
$currentSubsiteID = Subsite::currentSubsiteID();
$query->addWhere("\"{$baseTable}\".\"SubsiteID\" = '{$currentSubsiteID}'");
}
}
开发者ID:helpfulrobot,项目名称:moe-subsite-config,代码行数:12,代码来源:SubsiteDataObject.php
示例19: done
/**
* @param array $compatibility
*/
public static function done(array $compatibility)
{
if (class_exists("Subsite")) {
Subsite::$disable_subsite_filter = $compatibility[self::SUBSITES];
}
if (class_exists("Translatable")) {
Translatable::enable_locale_filter($compatibility[self::TRANSLATABLE]);
}
}
开发者ID:GOVTNZ,项目名称:silverstripe-contentreview,代码行数:12,代码来源:ContentReviewCompatability.php
示例20: getCMSFields
/**
* make the form a bit more usable.
*
* @return FieldList
*/
public function getCMSFields()
{
$fields = parent::getCMSFields();
// remove it and, if needed re-add it as a hidden field
$fields->removeByName('SubsiteID');
if (class_exists('Subsite')) {
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}
return $fields;
}
开发者ID:friendsofsilverstripe,项目名称:handypages,代码行数:15,代码来源:SubsiteSafeDataObject.php
注:本文中的Subsite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论