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


PHP Subsite::get方法代码示例

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


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

示例1: getSubsite

 /**
  * @return null
  */
 function getSubsite()
 {
     if (class_exists('Subsite')) {
         return Subsite::get()->byID($this->owner->SubsiteID);
     } else {
         return null;
     }
 }
开发者ID:helpfulrobot,项目名称:moe-subsite-config,代码行数:11,代码来源:SubsiteDataObject.php

示例2: link_shortcode_handler

 /**
  * Modify the content to include subsite links
  * @global array $subsiteDomainIDs
  * @param array $arguments
  * @param string $content
  * @param type $parser
  * @return string links
  */
 public static function link_shortcode_handler($arguments, $content = null, $parser = null)
 {
     if (!isset($arguments['id'])) {
         return;
     }
     $argumentarray = explode('-', $arguments['id']);
     if (count($argumentarray) != 2) {
         return;
     }
     $subsiteid = $argumentarray[0];
     $id = $argumentarray[1];
     $page = null;
     if ($id) {
         $page = DataObject::get_by_id('SiteTree', $id);
         // Get the current page by ID.
         if (!$page) {
             $page = Versioned::get_latest_version('SiteTree', $id);
             // Attempt link to old version.
         }
     } else {
         $page = DataObject::get_one('ErrorPage', '"ErrorPage"."ErrorCode" = \'404\'');
         // Link to 404 page.
     }
     if (!$page) {
         return;
         // There were no suitable matches at all.
     }
     $currentSubsite = Subsite::get()->byID((int) $subsiteid);
     $currenturl = null;
     if ($currentSubsite) {
         if (Director::isDev()) {
             $currenturl = $currentSubsite->DevDomainID ? $currentSubsite->DevDomain() : null;
         }
         if (Director::isTest()) {
             $currenturl = $currentSubsite->TestDomainID ? $currentSubsite->TestDomain() : null;
         }
         if (!$currenturl) {
             $currenturl = $currentSubsite->getPrimarySubsiteDomain();
         }
         $currenturl = $currenturl->getFullProtocol() . $currenturl->Domain;
         // override
         if (Director::isDev() || Director::isTest()) {
             if (defined('DEV_SUBSITE_' . (int) $subsiteid)) {
                 $subsiteurl = 'DEV_SUBSITE_' . (int) $subsiteid;
                 $currenturl = constant($subsiteurl);
             }
         }
     }
     $link = Convert::raw2att($page->Link());
     if ($content) {
         return sprintf('<a href="%s">%s</a>', $currenturl . $link, $parser->parse($content));
     } else {
         return $currenturl . $link;
     }
 }
开发者ID:otago,项目名称:subsites-domains,代码行数:63,代码来源:HtmlEditorField_ToolbarExtension.php

示例3: doSave

 function doSave($data, $form)
 {
     $new_record = $this->record->ID == 0;
     if ($new_record && isset($data['TemplateID']) && !empty($data['TemplateID'])) {
         $template = Subsite::get()->byID(intval($data['TemplateID']));
         if ($template) {
             $this->record = $template->duplicate();
         }
     }
     return parent::doSave($data, $form);
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:11,代码来源:GridFieldSubsiteDetailForm.php

示例4: sourceRecords

 /**
  * Returns an array with 2 elements, one with a list of Page on the site (and all subsites if
  * applicable) and another with files.
  *
  * @return array
  */
 public function sourceRecords()
 {
     if (class_exists('Subsite') && Subsite::get()->count() > 0) {
         $origMode = Versioned::get_reading_mode();
         Versioned::set_reading_mode('Stage.Stage');
         $items = array('Pages' => Subsite::get_from_all_subsites('SiteTree'), 'Files' => Subsite::get_from_all_subsites('File'));
         Versioned::set_reading_mode($origMode);
         return $items;
     } else {
         return array('Pages' => Versioned::get_by_stage('SiteTree', 'Stage'), 'Files' => File::get());
     }
 }
开发者ID:silverstripe,项目名称:sitewidecontent-report,代码行数:18,代码来源:SitewideContentReport.php

示例5: subsitesTests

 public function subsitesTests()
 {
     $this->doEcho('Subsites', true);
     $subsites = Subsite::get()->sort('ID ASC');
     foreach ($subsites as $s) {
         $this->doEcho("{$s->Title} (#{$s->ID}):");
         //Setting subsite via $_GET
         //this is not bes practice, but this seems to be the only way that works
         //when running this over the command line
         $_GET['SubsiteID'] = $s->ID;
         $this->doEcho(SubsiteUploadDirRules::get_directory_for_subsite());
         $this->doEcho();
     }
 }
开发者ID:titledk,项目名称:silverstripe-uploaddirrules,代码行数:14,代码来源:UploadDirRulesTestTask.php

示例6: run

 public function run($request)
 {
     set_time_limit(0);
     increase_memory_limit_to();
     Subsite::$disable_subsite_filter = true;
     $mainConfig = SiteConfig::current_site_config();
     $mainConfig->compileStyles();
     DB::alteration_message("Compile styles for main site");
     $subsites = Subsite::get();
     foreach ($subsites as $subsite) {
         $subsiteConfig = SiteConfig::get()->filter('SubsiteID', $subsite->ID)->first();
         if (!$subsiteConfig) {
             DB::alteration_message("No config for subsite " . $subsite->ID, "error");
             continue;
         }
         $subsiteConfig->compileStyles();
         DB::alteration_message("Compile styles for subsite " . $subsite->ID);
     }
     DB::alteration_message("All done");
 }
开发者ID:lekoala,项目名称:silverstripe-theme-framework,代码行数:20,代码来源:ThemeRebuildAllStylesTask.php

示例7: updateColumns

 /**
  * Update columns to include subsite details.
  *
  * @param string $itemType (i.e 'Pages' or 'Files')
  * @param array  $columns  Columns
  */
 public function updateColumns($itemType, &$columns)
 {
     // Skip single subsite setups
     if (!Subsite::get()->count()) {
         return;
     }
     // Set title
     $mainSiteLabel = _t('SitewideContentReport.MainSite', 'Main Site');
     if ($itemType !== 'Pages') {
         $mainSiteLabel .= ' ' . _t('SitewideContentReport.AccessFromAllSubsites', '(accessible by all subsites)');
     }
     // Add subsite name
     $columns['SubsiteName'] = array('title' => _t('SitewideContentReport.Subsite', 'Subsite'), 'datasource' => function ($item) use($mainSiteLabel) {
         $subsite = $item->Subsite();
         if ($subsite && $subsite->exists() && $subsite->Title) {
             return $subsite->Title;
         } else {
             return $mainSiteLabel;
         }
     });
 }
开发者ID:camfindlay,项目名称:silverstripe-sitewidecontent-report,代码行数:27,代码来源:SitewideContentSubsites.php

示例8: sync

 /**
  * This function ensures the file table is correct with the files in the assets folder.
  * 
  * If a Folder record ID is given, all of that folder's children will be synchronised.
  * If the given Folder ID isn't found, or not specified at all, then everything will
  * be synchronised from the root folder (singleton Folder).
  * 
  * See {@link File->updateFilesystem()} to sync properties of a single database record 
  * back to the equivalent filesystem record.
  * 
  * @param int $folderID Folder ID to sync along with all it's children
  * @param Boolean $syncLinkTracking Determines if the link tracking data should also 
  *        be updated via {@link SiteTree->syncLinkTracking()}. Setting this to FALSE
  *        means that broken links inside page content are not noticed, at least until the next
  *        call to {@link SiteTree->write()} on this page.
  * @return string Localized status message
  */
 public static function sync($folderID = null, $syncLinkTracking = true)
 {
     $folder = DataObject::get_by_id('Folder', (int) $folderID);
     if (!($folder && $folder->exists())) {
         $folder = singleton('Folder');
     }
     $results = $folder->syncChildren();
     $finished = false;
     while (!$finished) {
         $orphans = DB::query("SELECT \"C\".\"ID\" FROM \"File\" AS \"C\" \n\t\t\t\tLEFT JOIN \"File\" AS \"P\" ON \"C\".\"ParentID\" = \"P\".\"ID\" \n\t\t\t\tWHERE \"P\".\"ID\" IS NULL AND \"C\".\"ParentID\" > 0");
         $finished = true;
         if ($orphans) {
             foreach ($orphans as $orphan) {
                 $finished = false;
                 // Delete the database record but leave the filesystem alone
                 $file = DataObject::get_by_id("File", $orphan['ID']);
                 $file->deleteDatabaseOnly();
                 unset($file);
             }
         }
     }
     // Update the image tracking of all pages
     if ($syncLinkTracking) {
         if (class_exists('SiteTree')) {
             // if subsites exist, go through each subsite and sync each subsite's pages.
             // disabling the filter doesn't work reliably, because writing pages that share
             // the same URLSegment between subsites will break, e.g. "home" between two
             // sites will modify one of them to "home-2", thinking it's a duplicate. The
             // check before a write is done in SiteTree::validURLSegment()
             if (class_exists('Subsite')) {
                 // loop through each subsite ID, changing the subsite, then query it's pages
                 foreach (Subsite::get()->getIDList() as $id) {
                     Subsite::changeSubsite($id);
                     foreach (SiteTree::get() as $page) {
                         // syncLinkTracking is called by SiteTree::onBeforeWrite().
                         // Call it without affecting the page version, as this is an internal change.
                         $page->writeWithoutVersion();
                     }
                 }
                 // change back to the main site so the foreach below works
                 Subsite::changeSubsite(0);
             }
             foreach (SiteTree::get() as $page) {
                 // syncLinkTracking is called by SiteTree::onBeforeWrite().
                 // Call it without affecting the page version, as this is an internal change.
                 $page->writeWithoutVersion();
             }
         }
     }
     return _t('Filesystem.SYNCRESULTS', 'Sync complete: {createdcount} items created, {deletedcount} items deleted', array('createdcount' => (int) $results['added'], 'deletedcount' => (int) $results['deleted']));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:68,代码来源:Filesystem.php

示例9: run

 public function run($request)
 {
     echo 'Run with ?clear=1 to clear empty database before running the task<br/>';
     echo 'Run with ?overwrite=soft|hard to overwrite templates that exists in the cms. Soft will replace template if not modified by the user, hard will replace template even if modified by user.<br/>';
     echo 'Run with ?templates=xxx,yyy to specify which template should be imported<br/>';
     echo 'Run with ?subsite=all|subsiteID to create email templates in all subsites (including main site) or only in the chosen subsite (if a subsite is active, it will be used by default).<br/>';
     echo 'Run with ?locales=fr,en to choose which locale to import.<br/>';
     echo '<strong>Remember to flush the templates/translations if needed</strong><br/>';
     echo '<hr/>';
     $overwrite = $request->getVar('overwrite');
     $clear = $request->getVar('clear');
     $templatesToImport = $request->getVar('templates');
     $importToSubsite = $request->getVar('subsite');
     $chosenLocales = $request->getVar('locales');
     // Normalize argument
     if ($overwrite && $overwrite != 'soft' && $overwrite != 'hard') {
         $overwrite = 'soft';
     }
     $subsites = array();
     if ($importToSubsite == 'all') {
         $subsites = Subsite::get()->map();
     } else {
         if (is_numeric($importToSubsite)) {
             $subsites = array($importToSubsite => Subsite::get()->byID($importToSubsite)->Title);
         }
     }
     if (class_exists('Subsite') && Subsite::currentSubsiteID()) {
         DB::alteration_message("Importing to current subsite. Run from main site to import other subsites at once.", "created");
         $subsites = array();
     }
     if (!empty($subsites)) {
         DB::alteration_message("Importing to subsites : " . implode(',', array_values($subsites)), "created");
     }
     if ($templatesToImport) {
         $templatesToImport = explode(',', $templatesToImport);
     }
     if ($clear == 1) {
         DB::alteration_message("Clear all email templates", "created");
         $emailTemplates = EmailTemplate::get();
         foreach ($emailTemplates as $emailTemplate) {
             $emailTemplate->delete();
         }
     }
     $emailTemplateSingl = singleton('EmailTemplate');
     $ignoredModules = self::config()->ignored_modules;
     if (!is_array($ignoredModules)) {
         $ignoredModules = array();
     }
     $locales = null;
     if (class_exists('Fluent') && Fluent::locale_names()) {
         if ($emailTemplateSingl->hasExtension('FluentExtension')) {
             $locales = array_keys(Fluent::locale_names());
             if ($chosenLocales) {
                 $arr = explode(',', $chosenLocales);
                 $locales = array();
                 foreach ($arr as $a) {
                     if (strlen($a) == 2) {
                         $a = i18n::get_locale_from_lang($a);
                     }
                     $locales[] = $a;
                 }
             }
         }
     }
     $defaultLocale = i18n::get_locale();
     $templates = SS_TemplateLoader::instance()->getManifest()->getTemplates();
     foreach ($templates as $t) {
         $isOverwritten = false;
         // Emails in mysite/email are not properly marked as emails
         if (isset($t['mysite']) && isset($t['mysite']['email'])) {
             $t['email'] = $t['mysite']['email'];
         }
         // Should be in the /email folder
         if (!isset($t['email'])) {
             continue;
         }
         $filePath = $t['email'];
         $fileName = basename($filePath, '.ss');
         // Should end with *Email
         if (!preg_match('/Email$/', $fileName)) {
             continue;
         }
         $relativeFilePath = str_replace(Director::baseFolder(), '', $filePath);
         $relativeFilePathParts = explode('/', trim($relativeFilePath, '/'));
         // Group by module
         $module = array_shift($relativeFilePathParts);
         // Ignore some modules
         if (in_array($module, $ignoredModules)) {
             continue;
         }
         array_shift($relativeFilePathParts);
         // remove /templates part
         $templateName = str_replace('.ss', '', implode('/', $relativeFilePathParts));
         $templateTitle = basename($templateName);
         // Create a default code from template name
         $code = strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $fileName));
         $code = preg_replace('/-email$/', '', $code);
         if (!empty($templatesToImport) && !in_array($code, $templatesToImport)) {
             DB::alteration_message("Template with code <b>{$code}</b> was ignored.", "repaired");
             continue;
//.........这里部分代码省略.........
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:101,代码来源:EmailImportTask.php

示例10: all_sites

 /**
  * Return all subsites, regardless of permissions (augmented with main site).
  *
  * @return SS_List List of {@link Subsite} objects (DataList or ArrayList).
  */
 public static function all_sites($includeMainSite = true, $mainSiteTitle = "Main site")
 {
     $subsites = Subsite::get();
     if ($includeMainSite) {
         $subsites = $subsites->toArray();
         $mainSite = new Subsite();
         $mainSite->Title = $mainSiteTitle;
         array_unshift($subsites, $mainSite);
         $subsites = ArrayList::create($subsites);
     }
     return $subsites;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:17,代码来源:Subsite.php

示例11: all_sites

 /**
  * Return all subsites, regardless of permissions (augmented with main site).
  *
  * @return SS_List List of {@link Subsite} objects (DataList or ArrayList).
  */
 public static function all_sites()
 {
     return Subsite::get();
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:9,代码来源:Subsite.php

示例12: run

 public function run($request)
 {
     echo 'Run with ?clear=1 to clear empty database before running the task<br/>';
     echo 'Run with ?overwrite=1 to overwrite templates that exists in the cms<br/>';
     echo 'Run with ?templates=xxx,yyy to specify which template should be imported<br/>';
     echo 'Run with ?subsite=1 to create email templates in all subsites as well. Overwriting is based on main site.<br/>';
     echo '<hr/>';
     $overwrite = $request->getVar('overwrite');
     $clear = $request->getVar('clear');
     $templatesToImport = $request->getVar('templates');
     $importToSubsite = $request->getVar('subsite');
     $subsites = array();
     if ($importToSubsite) {
         $subsites = Subsite::get()->map();
     }
     if ($templatesToImport) {
         $templatesToImport = explode(',', $templatesToImport);
     }
     if ($clear == 1) {
         echo '<strong>Clear all email templates</strong><br/>';
         $emailTemplates = EmailTemplate::get();
         foreach ($emailTemplates as $emailTemplate) {
             $emailTemplate->delete();
         }
     }
     $o = singleton('EmailTemplate');
     $ignoredModules = self::config()->ignored_modules;
     if (!is_array($ignoredModules)) {
         $ignoredModules = array();
     }
     $locales = null;
     if (class_exists('Fluent') && Fluent::locale_names()) {
         if ($o->hasExtension('FluentExtension')) {
             $locales = array_keys(Fluent::locale_names());
         }
     }
     $defaultLocale = i18n::get_locale();
     $templates = SS_TemplateLoader::instance()->getManifest()->getTemplates();
     foreach ($templates as $t) {
         $isOverwritten = false;
         // Emails in mysite/email are not properly marked as emails
         if (isset($t['mysite']) && isset($t['mysite']['email'])) {
             $t['email'] = $t['mysite']['email'];
         }
         // Should be in the /email folder
         if (!isset($t['email'])) {
             continue;
         }
         $filePath = $t['email'];
         $fileName = basename($filePath, '.ss');
         // Should end with *Email
         if (!preg_match('/Email$/', $fileName)) {
             continue;
         }
         $relativeFilePath = str_replace(Director::baseFolder(), '', $filePath);
         $relativeFilePathParts = explode('/', trim($relativeFilePath, '/'));
         // Group by module
         $module = array_shift($relativeFilePathParts);
         // Ignore some modules
         if (in_array($module, $ignoredModules)) {
             continue;
         }
         array_shift($relativeFilePathParts);
         // remove /templates part
         $templateName = str_replace('.ss', '', implode('/', $relativeFilePathParts));
         $templateTitle = basename($templateName);
         // Create a default code from template name
         $code = strtolower(preg_replace('/([a-zA-Z])(?=[A-Z])/', '$1-', $fileName));
         $code = preg_replace('/-email$/', '', $code);
         if (!empty($templatesToImport) && !in_array($code, $templatesToImport)) {
             echo "<div style='color:blue'>Template with code '{$code}' was ignored.</div>";
             continue;
         }
         $emailTemplate = EmailTemplate::get()->filter('Code', $code)->first();
         if (!$overwrite && $emailTemplate) {
             echo "<div style='color:blue'>Template with code '{$code}' already exists.</div>";
             continue;
         }
         // Create a default title from code
         $title = explode('-', $code);
         $title = array_map(function ($item) {
             return ucfirst($item);
         }, $title);
         $title = implode(' ', $title);
         // Get content of the email
         $content = file_get_contents($filePath);
         // Analyze content to find incompatibilities
         $errors = array();
         if (strpos($content, '<% with') !== false) {
             $errors[] = 'Replace "with" blocks by plain calls to the variable';
         }
         if (strpos($content, '<% if') !== false) {
             $errors[] = 'If/else logic is not supported. Please create one template by use case or abstract logic into the model';
         }
         if (strpos($content, '<% loop') !== false) {
             $errors[] = 'Loops are not supported. Please create a helper method on the model to render the loop';
         }
         if (strpos($content, '<% sprintf') !== false) {
             $errors[] = 'You should not use sprintf to escape content, please use plain _t calls';
         }
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-mandrill,代码行数:101,代码来源:EmailImportTask.php

示例13: getUsersBlogs

 /**
  * Gets the site config or subsites for the current site
  * @return {array} Nested array of sites
  */
 protected function getUsersBlogs($app_id)
 {
     if (SiteConfig::has_extension('SiteConfigSubsites')) {
         $response = array();
         //Disable subsite filter
         Subsite::disable_subsite_filter();
         $subsites = Subsite::get();
         foreach ($subsites as $subsite) {
             $response[] = array('blogid' => $subsite->ID, 'blogname' => $subsite->Title);
         }
         //Re-enable subsite filter
         Subsite::disable_subsite_filter(false);
         return $response;
     }
     $siteConfig = SiteConfig::current_site_config();
     return array(array('blogid' => $siteConfig->ID, 'blogname' => $siteConfig->Title));
 }
开发者ID:webbuilders-group,项目名称:silverstripe-kapost-bridge,代码行数:21,代码来源:KapostService.php


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