本文整理汇总了PHP中Site::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::get方法的具体用法?PHP Site::get怎么用?PHP Site::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requireDefaultRecords
/**
* Instantiate a search page, should one not exist.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$mode = Versioned::get_reading_mode();
Versioned::reading_stage('Stage');
// Determine whether pages should be created.
if (self::config()->create_default_pages) {
// Determine whether an extensible search page already exists.
if (!ExtensibleSearchPage::get()->first()) {
// Instantiate an extensible search page.
$page = ExtensibleSearchPage::create();
$page->Title = 'Search Page';
$page->write();
DB::alteration_message('"Default" Extensible Search Page', 'created');
}
} else {
if (ClassInfo::exists('Multisites')) {
foreach (Site::get() as $site) {
// Determine whether an extensible search page already exists.
if (!ExtensibleSearchPage::get()->filter('SiteID', $site->ID)->first()) {
// Instantiate an extensible search page.
$page = ExtensibleSearchPage::create();
$page->ParentID = $site->ID;
$page->Title = 'Search Page';
$page->write();
DB::alteration_message("\"{$site->Title}\" Extensible Search Page", 'created');
}
}
}
}
Versioned::set_reading_mode($mode);
}
示例2: requireDefaultRecords
/**
* Create default blog setup
*/
function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!DataObject::get_one('UserAgreementPage')) {
if (class_exists('Site') && ($sites = Site::get())) {
if ($sites->first()) {
foreach ($sites as $site) {
$page = new UserAgreementPage();
$page->Title = "User Agreement";
$page->URLSegment = "user-agreement";
$page->Status = "Published";
$page->ShowInMenus = 0;
$page->ParentID = $site->ID;
$page->write();
$page->publish("Stage", "Live");
DB::alteration_message("User Agreement Page Created", "created");
}
}
} else {
$page = new UserAgreementPage();
$page->Title = "User Agreement";
$page->URLSegment = "user-agreement";
$page->Status = "Published";
$page->ShowInMenus = 0;
$page->write();
$page->publish("Stage", "Live");
DB::alteration_message("User Agreement Page Created", "created");
}
}
}
示例3: __construct
/**
* @constructor
*/
public function __construct($data_folder = '')
{
// load the config file.
$this->config = new Config();
$this->config->load($data_folder);
// load the templates.
$this->templates = new Templates();
$this->templates->load($data_folder);
// loading data files.
$this->files = new Files();
$this->files->load($data_folder, $this->config->get('pages_data'));
// initialize database.
$this->db = new Database();
//
$this->renders = new Renders();
}
示例4: getSiteParameterField
public static function getSiteParameterField()
{
$source = Site::get()->map('ID', 'Title')->toArray();
$source = array('0' => 'All') + $source;
// works around ajax bug
return DropdownField::create('Site', 'Site', $source)->setHasEmptyDefault(false);
}
示例5: updateSearchForm
/**
* Adds a dropdown field to the search form to filter searches by Site
**/
public function updateSearchForm(Form $form)
{
$cms = $this->owner;
$req = $cms->getRequest();
$sites = Site::get()->sort(array('IsDefault' => 'DESC', 'Title' => 'ASC'));
$site = new DropdownField('q[SiteID]', _t('Multisites.SITE', 'Site'), $sites->map(), isset($req['q']['SiteID']) ? $req['q']['SiteID'] : null);
$site->setEmptyString(_t('Multisites.ALLSITES', 'All sites'));
$form->Fields()->insertAfter($site, 'q[Term]');
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:12,代码来源:MultisitesCmsMainExtension.php
示例6: updateSearchForm
/**
* Provide a Site filter
**/
public function updateSearchForm($form)
{
if (singleton($this->owner->getList()->dataClass())->hasExtension('MultisitesAware')) {
$managedSites = Multisites::inst()->sitesManagedByMember();
$source = Site::get()->filter('ID', Multisites::inst()->sitesManagedByMember())->map('ID', 'Title')->toArray();
$plural = singleton($this->owner->modelClass)->plural_name();
if (count($source)) {
$form->Fields()->push(DropdownField::create('SiteID', "Site: ", $source, Session::get('MultisitesModelAdmin_SiteID')));
}
}
}
示例7: index
public function index()
{
$site = Multisites::inst()->getCurrentSiteId();
if (!$site) {
return $this->httpError(404);
}
$page = Site::get()->filter(array('ID' => $site));
$page = $page->first();
if (!$page) {
return $this->httpError(404);
}
/*
* Trim the RobotsTxt field because it may be an empty string.
* and since SilverStripe doesn't ship with a default robots.txt
* file, we'll want to return a 404 if there isn't any text for
* the site's robots.txt file.
*/
$text = trim($page->RobotsTxt);
if (empty($text)) {
return $this->httpError(404);
}
$this->getResponse()->addHeader('Content-Type', 'text/plain; charset="utf-8"');
return $text;
}
示例8: requireDefaultRecords
/**
* Make sure there is a site record.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!Site::get()->count()) {
$site = new Site();
$site->Title = _t('Multisites.DEFAULTSITE', 'Default Site');
$site->IsDefault = true;
$site->write();
DB::alteration_message('Default site created', 'created');
$pages = SiteTree::get()->exclude('ID', $site->ID)->filter('ParentID', 0);
$count = count($pages);
foreach ($pages as $page) {
$page->ParentID = $site->ID;
$page->write();
if ($page->isPublished()) {
$page->publish('Stage', 'Live');
}
}
DB::alteration_message("Moved {$count} existing pages under new default site.", 'changed');
}
}
示例9: validateEnvironment
/**
* Validates that the environment's connection mode is appropriately set
*
* @param Site $site
* @param Environment $environment
*/
protected function validateEnvironment($site, $environment)
{
$this->validateConnectionMode($environment->get('connection_mode'));
$this->validateFramework($site->get('framework'));
}
示例10: __construct
public function __construct()
{
parent::__construct();
// Put extension checks into hash maps
foreach (ClassInfo::subclassesFor('DataObject') as $class) {
if ($class::has_extension('ElementPageExtension')) {
$this->_classes_using_elemental[$class] = true;
}
if ($class::has_extension('WordpressImportDataExtension')) {
$this->_classes_using_wordpress_extension[$class] = true;
}
}
// If Elemental is on the base SiteTree or Page type, use the elemental callback by default.
if (isset($this->_classes_using_elemental['SiteTree']) || isset($this->_classes_using_elemental['Page'])) {
$this->setContentCallbacks('setElementalContent', 'getElementalContent');
}
// Set default root parent ID
if (class_exists('Multisites') && $this->root_parent_id == 0) {
$site = null;
$sites = Site::get()->toArray();
if (count($sites) == 1) {
$site = $sites[0];
} else {
foreach ($sites as $it) {
if ($site->IsDefault) {
$site = $it;
break;
}
}
}
if ($site) {
$this->root_parent_id = $site->ID;
}
}
}
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:35,代码来源:WordpressImportService.php
示例11: getActiveSite
/**
* get the active site for this model admin
*
* @return Site
**/
public function getActiveSite()
{
if ($this->owner->config()->use_active_site_session) {
return Multisites::inst()->getActiveSite();
} else {
if ($this->modelIsMultiSitesAware()) {
if ($active = Session::get($this->getActiveSiteSessionKey())) {
return Site::get()->byID($active);
}
}
}
}
示例12: process_rglist_addsc
private function process_rglist_addsc(&$rg_ids, $sc_id)
{
$site_ids = array();
//load all site id under the requested sc
$model = new Site();
$sites = $model->get(array("sc_id" => $sc_id, "filter_disabled" => false));
foreach ($sites as $site) {
if (!in_array($site->id, $site_ids)) {
$site_ids[] = $site->id;
}
}
foreach ($site_ids as $site_id) {
$this->process_rglist_addsite($rg_ids, $site_id);
}
}
示例13: process_site_filter_disable
private function process_site_filter_disable()
{
$sites_to_keep = array();
$model = new Site();
$sites = $model->get();
$disable_value = $_REQUEST["disable_value"];
foreach ($sites as $site) {
if ($site->disable == $disable_value) {
if (!in_array($site->id, $sites_to_keep)) {
$sites_to_keep[] = $site->id;
}
}
}
return $sites_to_keep;
}
示例14: getActiveSite
/**
* get the active site for this model admin
*
* @return Site
**/
public function getActiveSite()
{
if ($this->owner->config()->use_active_site_session) {
return Multisites::inst()->getActiveSite();
} else {
if ($this->getListDataClass()->hasExtension('MultisitesAware')) {
if ($active = Session::get($this->getActiveSiteSessionKey())) {
return Site::get()->byID($active);
}
}
}
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:17,代码来源:MultisitesModelAdminExtension.php
示例15: showSite
public function showSite()
{
/* Bail out if the user doesn't have SA permissions. */
if ($this->_siteID > 1 || $this->_realAccessLevel < ACCESS_LEVEL_DEMO)
{
CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
return;
//$this->fatal(ERROR_NO_PERMISSION);
}
$privledged = true;
$siteID = $_GET['siteID'];
$site = new Site($this->_siteID);
$data = $site->get($siteID);
if (empty($data))
{
CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'No Site found with selected ID.');
}
$this->_template->assign('site_id', $siteID);
$this->_template->assign('active', $this);
$this->_template->assign('subActive', '');
$this->_template->assign('data', $data);
$this->_template->display('./modules/settings/ShowSite.php');
}