本文整理汇总了PHP中Subsite::all_sites方法的典型用法代码示例。如果您正苦于以下问题:PHP Subsite::all_sites方法的具体用法?PHP Subsite::all_sites怎么用?PHP Subsite::all_sites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subsite
的用法示例。
在下文中一共展示了Subsite::all_sites方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
*
* @param SS_HTTPRequest $request
*/
public function run($request)
{
$cacheBaseDir = singleton('FilesystemPublisher')->getDestDir();
// First generate the search file for the base site
$viewer = new SSViewer(array('StaticSearchJSON'));
$item = new ViewableData($this);
$json = $viewer->process($this->getAllLivePages(0));
$domain = Config::inst()->get('FilesystemPublisher', 'static_base_url');
$urlFragments = parse_url($domain);
$cacheDir = $cacheBaseDir . "/" . $urlFragments['host'];
file_put_contents($cacheDir . '/search_index.html', $json);
if (class_exists('Subsite')) {
// Then generate the files for the subsites
$subsites = Subsite::all_sites();
foreach ($subsites as $subsite) {
$viewer = new SSViewer(array('StaticSearchJSON'));
$item = new ViewableData($this);
$json = $viewer->process($this->getAllLivePages($subsite->ID));
$domains = DataObject::get("SubsiteDomain")->filter(array("SubsiteID" => $subsite->ID));
foreach ($domains as $domain) {
$urlFragments = parse_url($domain->Domain);
$cacheDir = $cacheBaseDir . "/" . $urlFragments['path'];
file_put_contents($cacheDir . '/search_index.html', $json);
}
}
}
return true;
}
示例2: sectionSites
/**
* Find all subsites accessible for current user on this controller.
*
* @return ArrayList of {@link Subsite} instances.
*/
function sectionSites($includeMainSite = true, $mainSiteTitle = "Main site", $member = null)
{
if ($mainSiteTitle == 'Main site') {
$mainSiteTitle = _t('Subsites.MainSiteTitle', 'Main site');
}
// Rationalise member arguments
if (!$member) {
$member = Member::currentUser();
}
if (!$member) {
return new ArrayList();
}
if (!is_object($member)) {
$member = DataObject::get_by_id('Member', $member);
}
// Collect permissions - honour the LeftAndMain::required_permission_codes, current model requires
// us to check if the user satisfies ALL permissions. Code partly copied from LeftAndMain::canView.
$codes = array();
$extraCodes = Config::inst()->get($this->owner->class, 'required_permission_codes');
if ($extraCodes !== false) {
if ($extraCodes) {
$codes = array_merge($codes, (array) $extraCodes);
} else {
$codes[] = "CMS_ACCESS_{$this->owner->class}";
}
} else {
// Check overriden - all subsites accessible.
return Subsite::all_sites();
}
// Find subsites satisfying all permissions for the Member.
$codesPerSite = array();
$sitesArray = array();
foreach ($codes as $code) {
$sites = Subsite::accessible_sites($code, $includeMainSite, $mainSiteTitle, $member);
foreach ($sites as $site) {
// Build the structure for checking how many codes match.
$codesPerSite[$site->ID][$code] = true;
// Retain Subsite objects for later.
$sitesArray[$site->ID] = $site;
}
}
// Find sites that satisfy all codes conjuncitvely.
$accessibleSites = new ArrayList();
foreach ($codesPerSite as $siteID => $siteCodes) {
if (count($siteCodes) == count($codes)) {
$accessibleSites->push($sitesArray[$siteID]);
}
}
return $accessibleSites;
}
示例3: getCMSFields
/**
* @return FieldList
*/
public function getCMSFields()
{
Requirements::javascript(SITEWIDE_CONTENT_REPORT . '/javascript/sitewidecontentreport.js');
$fields = parent::getCMSFields();
if (class_exists('Subsite')) {
$subsites = Subsite::all_sites()->map();
$fields->insertBefore(HeaderField::create('PagesTitle', _t('SitewideContentReport.Pages', 'Pages'), 3), 'Report-Pages');
$fields->insertBefore(DropdownField::create('AllSubsites', _t('SitewideContentReport.FilterBy', 'Filter by:'), $subsites)->addExtraClass('subsite-filter no-change-track')->setEmptyString('All Subsites'), 'Report-Pages');
}
$fields->push(HeaderField::create('FilesTitle', _t('SitewideContentReport.Files', 'Files'), 3));
$fields->push($this->getReportField('Files'));
return $fields;
}
示例4: testAllSites
function testAllSites()
{
$subsites = Subsite::all_sites();
$this->assertDOSEquals(array(array('Title' => 'Main site'), array('Title' => 'Template'), array('Title' => 'Subsite1 Template'), array('Title' => 'Subsite2 Template'), array('Title' => 'Test 1'), array('Title' => 'Test 2'), array('Title' => 'Test 3')), $subsites, 'Lists all subsites');
}