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


PHP Subsite::currentSubsite方法代码示例

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


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

示例1: subsiteCMSShowInMenu

 public function subsiteCMSShowInMenu()
 {
     if (Subsite::currentSubsite()) {
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-subsites-extras,代码行数:7,代码来源:SubsiteActiveMenuExtension.php

示例2: 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

示例3: 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

示例4: 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

示例5: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // If subsites enabled
     if (class_exists('Subsite') && ($subsite = Subsite::currentSubsite())) {
         $this->SubsiteID = $subsite->ID;
     }
     // Ensure the slug is URL safe
     $this->Slug = $this->Slug ? Convert::raw2url($this->Slug) : Convert::raw2url($this->Title);
 }
开发者ID:henrypenny,项目名称:silverstripe-custommenus,代码行数:10,代码来源:CustomMenuHolder.php

示例6: get_directory_for_current_subsite

 /**
  * Getting subsite directory based on it's assets folder
  * 
  * @return bool|mixed
  */
 public static function get_directory_for_current_subsite()
 {
     $subsite = Subsite::currentSubsite();
     if ($subsite) {
         if ((int) $subsite->AssetsFolderID > 0) {
             $dirObj = $subsite->AssetsFolder();
             $dirName = str_replace('assets/', '', $dirObj->Filename);
             //make sure we've got no trailing slashes
             $dirName = str_replace('/', '', $dirName);
             return $dirName;
         }
     } else {
         return false;
     }
 }
开发者ID:helpfulrobot,项目名称:titledk-silverstripe-uploaddirrules,代码行数:20,代码来源:SubsiteUploadDirRules.php

示例7: onBeforeInit

 /**
  * @return void
  */
 public function onBeforeInit()
 {
     if (class_exists('Subsite') && Subsite::currentSubsite()) {
         // Set the location
         i18n::set_locale(Subsite::currentSubsite()->Language);
         // Check if url is primary domain, if not, re-direct
         if ($_SERVER['HTTP_HOST'] != Subsite::currentSubsite()->getPrimaryDomain()) {
             $this->owner->redirect(Subsite::currentSubsite()->absoluteBaseURL());
         }
     }
     // Setup currency globally based on what is set in admin
     $config = SiteConfig::current_site_config();
     if ($config->Currency()) {
         Currency::setCurrencySymbol($config->Currency()->HTMLNotation);
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:19,代码来源:Ext_Commerce_Controller.php

示例8: getFolderForClass

 /**
  * Get folder for a given class
  * 
  * @param mixed $class
  * @return string
  */
 public static function getFolderForClass($class)
 {
     $folderName = 'Uploads';
     if (is_object($class)) {
         if (method_exists($class, 'hasMethod') && $class->hasMethod('BaseFolder')) {
             $folderName = $class->BaseFolder();
         } else {
             if ($class instanceof Page) {
                 $folderName = get_class($class);
             } else {
                 if ($class instanceof DataObject) {
                     $folderName = $class->baseTable();
                 } else {
                     if ($class instanceof DataExtension) {
                         $folderName = $class->getOwner()->baseTable();
                     } else {
                         $folderName = get_class($class);
                     }
                 }
             }
         }
     } else {
         if (is_string($class)) {
             $folderName = $class;
         }
     }
     if (class_exists('Subsite') && Config::inst()->get(__CLASS__, 'use_subsite_integration')) {
         $subsite = Subsite::currentSubsite();
         if ($subsite) {
             // Subsite extras integration$
             if ($subsite->hasField('BaseFolder')) {
                 $baseFolder = $subsite->BaseFolder;
             } else {
                 $filter = new URLSegmentFilter();
                 $baseFolder = $filter->filter($subsite->getTitle());
                 $baseFolder = str_replace(' ', '', ucwords(str_replace('-', ' ', $baseFolder)));
             }
             if (!empty($baseFolder)) {
                 $folderName = $baseFolder . '/' . $folderName;
             }
         }
     }
     return $folderName;
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:50,代码来源:BaseUploadField.php

示例9: updateErrorFilename

 /**
  * Alter file path to generated a static (static) error page file to handle error page template on different sub-sites 
  *
  * {@see Error::get_error_filename()}
  *
  * 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.
  *
  * @param string $name Filename to write to
  * @param int $statusCode Integer error code
  */
 public function updateErrorFilename(&$name, $statusCode)
 {
     // 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);
         }
     }
     // Without subsite, don't rewrite
     if ($subsite) {
         // Add subdomain to end of filename, just before .html
         // This should preserve translatable locale in the filename as well
         $subdomain = $subsite->domain();
         $name = substr($name, 0, -5) . "-{$subdomain}.html";
     }
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:30,代码来源:ErrorPageSubsite.php

示例10: contentcontrollerInit

 /**
  * Called by ContentController::init();
  */
 public static function contentcontrollerInit($controller)
 {
     $subsite = Subsite::currentSubsite();
     if ($subsite && $subsite->Theme) {
         Config::inst()->update('SSViewer', 'theme', Subsite::currentSubsite()->Theme);
     }
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:10,代码来源:SiteTreeSubsites.php

示例11: canCreate

 /**
  * @param Member
  * @return boolean|null
  */
 function canCreate($member = null)
 {
     // Typically called on a singleton, so we're not using the Subsite() relation
     $subsite = Subsite::currentSubsite();
     if ($subsite && $subsite->exists() && $subsite->PageTypeBlacklist) {
         $blacklisted = explode(',', $subsite->PageTypeBlacklist);
         // All subclasses need to be listed explicitly
         if (in_array($this->owner->class, $blacklisted)) {
             return false;
         }
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-subsites-extras,代码行数:17,代码来源:SubsiteDataObject.php

示例12: getAvailableThemesExtended

 /**
  * Get all available themes that haven't been marked as disabled.
  * @param string $baseDir Optional alternative theme base directory for testing
  * @return array of theme directory names
  */
 public function getAvailableThemesExtended($baseDir = null)
 {
     if (class_exists('Subsite') && Subsite::currentSubsiteID()) {
         $subsiteThemes = Subsite::config()->allowed_themes;
         // Make sure set theme is allowed
         $subsite = Subsite::currentSubsite();
         if ($subsite->Theme && !in_array($subsite->Theme, $subsiteThemes)) {
             $subsiteThemes[] = $subsite->Theme;
         }
         // Make sure default theme is allowed
         $theme = Config::inst()->get('SSViewer', 'theme');
         if ($theme && !in_array($theme, $subsiteThemes)) {
             $subsiteThemes[] = $theme;
         }
         return array_combine($subsiteThemes, $subsiteThemes);
     }
     $themes = SSViewer::get_themes($baseDir);
     $disabled = (array) $this->owner->config()->disabled_themes;
     foreach ($disabled as $theme) {
         if (isset($themes[$theme])) {
             unset($themes[$theme]);
         }
     }
     return $themes;
 }
开发者ID:lekoala,项目名称:silverstripe-theme-framework,代码行数:30,代码来源:ThemeSiteConfigExtension.php

示例13: contentcontrollerInit

 /**
  * Called by ContentController::init();
  */
 public static function contentcontrollerInit($controller)
 {
     $subsite = Subsite::currentSubsite();
     if ($subsite && $subsite->Theme) {
         SSViewer::set_theme(Subsite::currentSubsite()->Theme);
     }
 }
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:10,代码来源:EmailTemplateSubsiteExtension.php

示例14: enable

 public static function enable($force_profile = null)
 {
     if ($force_profile) {
         self::$_current_profile = $force_profile;
         $force_profile::enable_custom_translations();
         $force_profile::enable_custom_code();
         return;
     }
     if (self::$_current_profile) {
         return;
     }
     if (!class_exists('Subsite')) {
         return;
     }
     if (!Subsite::currentSubsiteID()) {
         return;
     }
     $profile = Subsite::currentSubsite()->Profile;
     if (!$profile) {
         return;
     }
     self::$_current_profile = $profile;
     $profile::enable_custom_translations();
     $profile::enable_custom_code();
 }
开发者ID:lekoala,项目名称:silverstripe-subsites-extras,代码行数:25,代码来源:SubsiteProfile.php

示例15: contentcontrollerInit

 /**
  * Called by ContentController::init();
  */
 static function contentcontrollerInit($controller)
 {
     // Need to set the SubsiteID to null incase we've been in the CMS
     Session::set('SubsiteID', null);
     $subsite = Subsite::currentSubsite();
     if ($subsite && $subsite->Theme) {
         SSViewer::set_theme(Subsite::currentSubsite()->Theme);
     }
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:12,代码来源:SiteTreeSubsites.php


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