本文整理汇总了PHP中Subsite::currentSubsiteID方法的典型用法代码示例。如果您正苦于以下问题:PHP Subsite::currentSubsiteID方法的具体用法?PHP Subsite::currentSubsiteID怎么用?PHP Subsite::currentSubsiteID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subsite
的用法示例。
在下文中一共展示了Subsite::currentSubsiteID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: onBeforeWrite
function onBeforeWrite()
{
if (!$this->owner->ID && !$this->owner->SubsiteID) {
$this->owner->SubsiteID = Subsite::currentSubsiteID();
}
parent::onBeforeWrite();
}
示例4: updateCMSFields
public function updateCMSFields(FieldList $fields)
{
$fields->removeByName('SubsiteID');
if (class_exists('Subsite')) {
$fields->push(new HiddenField('SubsiteID', 'SubsiteID', Subsite::currentSubsiteID()));
}
}
示例5: 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();
}
}
}
示例6: 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
示例7: 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);
}
}
示例8: 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}'");
}
}
示例9: 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;
}
示例10: getList
/**
* List only newsitems from current subsite.
*
* @author Marcio Barrientos
* @return ArrayList $list
*/
public function getList()
{
/** @var DataList $list */
$list = parent::getList();
if ($this->modelClass === 'News' && class_exists('Subsite') && Subsite::currentSubsiteID() > 0) {
$pages = NewsHolderPage::get()->filter(array('SubsiteID' => (int) Subsite::currentSubsiteID()));
$filter = $pages->column('ID');
/* Manual join needed because otherwise no items are found. Unknown why. */
$list = $list->innerJoin('NewsHolderPage_Newsitems', 'NewsHolderPage_Newsitems.NewsID = News.ID')->filter(array('NewsHolderPage_Newsitems.NewsHolderPageID' => $filter));
}
return $list;
}
示例11: onBeforeInit
/**
* Detect if you're trying to access the admin section from the non main site
* @global string $_FILE_TO_URL_MAPPING
* @global string $_SERVER['REQUEST_URI'] this will be modified (bad practice warning)
* @return redirect location
*/
public function onBeforeInit()
{
if (!$this->owner->canAccess()) {
global $_FILE_TO_URL_MAPPING;
// redirect to domain.com/admin etc if there's the base path is set & you're in a subsite
if (Subsite::currentSubsiteID() != 0 && isset($_FILE_TO_URL_MAPPING[BASE_PATH])) {
$serverurl = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
$controller = Controller::curr();
if (strpos($serverurl, '/admin') === 0 && !$controller->getRequest()->getVar('SubsiteID')) {
// redirect to the correct site admin location
$url = Controller::join_links($_FILE_TO_URL_MAPPING[BASE_PATH], $serverurl, "?SubsiteID=" . Subsite::currentSubsiteID());
return Controller::curr()->redirect($url);
}
}
}
return parent::onBeforeInit();
}
示例12: loadFixtures
public function loadFixtures()
{
if (ClassInfo::exists('Subsite')) {
$currentSubsite = Subsite::currentSubsiteID();
}
foreach (self::$preload_fixtures as $desc) {
$fixtureFile = $desc['file'];
if (file_exists(Director::baseFolder() . '/' . $fixtureFile)) {
$siteID = null;
if (isset($desc['subsite'])) {
$site = DataObject::get_one('Subsite', '"Title" = \'' . Convert::raw2sql($desc['subsite']) . '\'');
if ($site && $site->ID) {
$siteID = $site->ID;
}
if (!$siteID) {
// no site, so just skip this file load
continue;
}
}
// need to disable the filter when running dev/build so that it actually searches
// within the relevant subsite, not the 'current' one.
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = true;
}
$filter = $desc['filter'] . ($siteID ? ' AND "SubsiteID"=' . $siteID : '');
$existing = DataObject::get_one($desc['type'], $filter);
if (ClassInfo::exists('Subsite')) {
Subsite::$disable_subsite_filter = false;
}
if (!$existing) {
if ($siteID) {
Subsite::changeSubsite($siteID);
}
$fixture = new YamlFixture($fixtureFile);
$fixture->saveIntoDatabase();
DB::alteration_message('YAML bootstrap loaded from ' . $fixtureFile, 'created');
}
}
}
if (ClassInfo::exists('Subsite')) {
Subsite::changeSubsite($currentSubsite);
}
}
示例13: testAlternateAccessCheck
function testAlternateAccessCheck()
{
$admin = $this->objFromFixture("Member", "admin");
$this->loginAs($admin);
$ids = array();
$subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
$subsite2 = $this->objFromFixture('Subsite', 'domaintest2');
$subsite3 = $this->objFromFixture('Subsite', 'domaintest3');
$ids[] = $subsite1->ID;
$ids[] = $subsite2->ID;
$ids[] = $subsite3->ID;
$ids[] = 0;
foreach ($ids as $id) {
Subsite::changeSubsite($id);
//switch to main site (subsite ID zero)
$left = new LeftAndMain();
$this->assertTrue($left->canView(), "Admin user can view subsites LeftAndMain with id = '{$id}'");
$this->assertEquals($id, Subsite::currentSubsiteID(), "The current subsite has not been changed in the process of checking permissions for admin user.");
}
}
示例14: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$fields = $form->Fields();
$params = $this->request->requestVar('q');
$gridField = $form->Fields()->fieldByName($this->modelClass);
if ($this->modelClass == 'Product') {
$gridField->setConfig(new GridFieldConfig_Catalogue($this->modelClass, $this->config()->product_page_length));
}
// Alterations for Hiarachy on product cataloge
if ($this->modelClass == 'Category') {
$gridField->setConfig(new GridFieldConfig_Catalogue($this->modelClass, $this->config()->category_page_length, "Sort"));
}
// 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;
}
示例15: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$fields = $form->Fields();
$config = null;
// Bulk manager
$manager = new GridFieldBulkManager();
$manager->removeBulkAction("bulkEdit");
$manager->removeBulkAction("unLink");
// Manage orders
if ($this->modelClass == 'Order') {
$gridField = $fields->fieldByName('Order');
$config = $gridField->getConfig();
$manager->addBulkAction('cancelled', 'Mark Cancelled', 'OrdersFieldBulkActions');
$manager->addBulkAction('paid', 'Mark Paid', 'OrdersFieldBulkActions');
$manager->addBulkAction('processing', 'Mark Processing', 'OrdersFieldBulkActions');
$manager->addBulkAction('dispatched', 'Mark Dispatched', 'OrdersFieldBulkActions');
// Update list of items for subsite (if used)
if (class_exists('Subsite')) {
$list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID()));
$gridField->setList($list);
}
}
// Manage Estimates
if ($this->modelClass == 'Estimate') {
$gridField = $fields->fieldByName('Estimate');
$config = $gridField->getConfig();
// Update list of items for subsite (if used)
if (class_exists('Subsite')) {
$list = $gridField->getList()->filter(array('SubsiteID' => Subsite::currentSubsiteID()));
$gridField->setList($list);
}
}
// Set our default detailform and bulk manager
if ($config) {
$config->removeComponentsByType('GridFieldDetailForm')->addComponent($manager)->addComponent(new OrdersGridFieldDetailForm());
}
$this->extend("updateEditForm", $form);
return $form;
}