silverstripe-subsites/code/SubsitesTreeDropdownField.php
Ingo Schommer e17ecfbdee FEATURE Support for VirtualPage-style linkage between subsites with new SubsiteVirtualPage class
ENHANCEMENT Allowing to select a subsite explicitly through admin-URLs, e.g. /admin/show/22/?SubsiteID=2
2008-12-02 03:50:06 +00:00

52 lines
1022 B
PHP

<?php
/**
* Wraps around a TreedropdownField to add ability for temporary
* switching of subsite sessions.
*
* @package subsites
*/
class SubsitesTreeDropdownField extends TreeDropdownField {
protected $subsiteID = 0;
protected $extraClasses = array('SubsitesTreeDropdownField');
function Field() {
$html = parent::Field();
Requirements::javascript('subsites/javascript/SubsitesTreeDropdownField.js');
return $html;
}
function setSubsiteID($id) {
$this->subsiteID = $id;
}
function getSubsiteID() {
return $this->subsiteID;
}
function gettree() {
$oldSubsiteID = Session::get('SubsiteID');
Session::set('SubsiteID', $this->subsiteID);
$results = parent::gettree();
Session::set('SubsiteID', $oldSubsiteID);
return $results;
}
function getsubtree() {
$oldSubsiteID = Session::get('SubsiteID');
Session::set('SubsiteID', $this->subsiteID);
$results = parent::getsubtree();
Session::set('SubsiteID', $oldSubsiteID);
return $results;
}
}
?>