(merged from branches/roa. use "svn log -c <changeset> -g <module-svn-path>" for detailed commit message)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60327 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3f9c14d60c
commit
2d8434a43f
|
@ -225,12 +225,13 @@ class RestfulServer extends Controller {
|
||||||
$extension = $this->request->getExtension();
|
$extension = $this->request->getExtension();
|
||||||
$contentType = $this->request->getHeader('Content-Type');
|
$contentType = $this->request->getHeader('Content-Type');
|
||||||
$accept = $this->request->getHeader('Accept');
|
$accept = $this->request->getHeader('Accept');
|
||||||
|
$mimetypes = $this->request->getAcceptMimetypes();
|
||||||
|
|
||||||
// get formatter
|
// get formatter
|
||||||
if(!empty($extension)) {
|
if(!empty($extension)) {
|
||||||
$formatter = DataFormatter::for_extension($extension);
|
$formatter = DataFormatter::for_extension($extension);
|
||||||
}elseif($includeAcceptHeader && !empty($accept) && $accept != '*/*') {
|
}elseif($includeAcceptHeader && !empty($accept) && $accept != '*/*') {
|
||||||
$formatter = DataFormatter::for_mimetypes(explode(',',$accept));
|
$formatter = DataFormatter::for_mimetypes($mimetypes);
|
||||||
} elseif(!empty($contentType)) {
|
} elseif(!empty($contentType)) {
|
||||||
$formatter = DataFormatter::for_mimetype($contentType);
|
$formatter = DataFormatter::for_mimetype($contentType);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -58,7 +58,7 @@ class RestfulService extends ViewableData {
|
||||||
* Connects to the RESTful service and gets its response.
|
* Connects to the RESTful service and gets its response.
|
||||||
* @deprecated Use {@link request()} instead.
|
* @deprecated Use {@link request()} instead.
|
||||||
*/
|
*/
|
||||||
function connect($subURL = ""){
|
public function connect($subURL = ""){
|
||||||
|
|
||||||
// url for the request
|
// url for the request
|
||||||
$url = $this->constructURL() . $subURL;
|
$url = $this->constructURL() . $subURL;
|
||||||
|
@ -148,7 +148,7 @@ class RestfulService extends ViewableData {
|
||||||
*
|
*
|
||||||
* This is a replacement of {@link connect()}.
|
* This is a replacement of {@link connect()}.
|
||||||
*/
|
*/
|
||||||
function request($subURL, $method = "GET", $data = null, $headers = null) {
|
public function request($subURL, $method = "GET", $data = null, $headers = null) {
|
||||||
$url = $this->baseURL . $subURL; //url for the request
|
$url = $this->baseURL . $subURL; //url for the request
|
||||||
$method = strtoupper($method);
|
$method = strtoupper($method);
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ class RestfulService extends ViewableData {
|
||||||
* @param string $element The element we need to extract the attributes.
|
* @param string $element The element we need to extract the attributes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getAttributes($xml, $collection=NULL, $element=NULL){
|
public function getAttributes($xml, $collection=NULL, $element=NULL){
|
||||||
$xml = new SimpleXMLElement($xml);
|
$xml = new SimpleXMLElement($xml);
|
||||||
$output = new DataObjectSet();
|
$output = new DataObjectSet();
|
||||||
|
|
||||||
|
@ -249,21 +249,22 @@ class RestfulService extends ViewableData {
|
||||||
* @param string $attr The name of the attribute
|
* @param string $attr The name of the attribute
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getAttribute($xml, $collection=NULL, $element=NULL, $attr){
|
public function getAttribute($xml, $collection=NULL, $element=NULL, $attr){
|
||||||
$xml = new SimpleXMLElement($xml);
|
$xml = new SimpleXMLElement($xml);
|
||||||
$attr_value = "";
|
$attr_value = "";
|
||||||
|
|
||||||
if($collection)
|
if($collection)
|
||||||
$childElements = $xml->{$collection};
|
$childElements = $xml->{$collection};
|
||||||
if($element)
|
if($element)
|
||||||
$childElements = $xml->{$collection}->{$element};
|
$childElements = $xml->{$collection}->{$element};
|
||||||
|
|
||||||
if($childElements)
|
if($childElements)
|
||||||
$attr_value = (string) $childElements[$attr];
|
$attr_value = (string) $childElements[$attr];
|
||||||
|
|
||||||
return Convert::raw2xml($attr_value);
|
return Convert::raw2xml($attr_value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets set of node values as an array.
|
* Gets set of node values as an array.
|
||||||
|
@ -273,7 +274,7 @@ class RestfulService extends ViewableData {
|
||||||
* @param string $element The element we need to extract the node values.
|
* @param string $element The element we need to extract the node values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getValues($xml, $collection=NULL, $element=NULL){
|
public function getValues($xml, $collection=NULL, $element=NULL){
|
||||||
$xml = new SimpleXMLElement($xml);
|
$xml = new SimpleXMLElement($xml);
|
||||||
$output = new DataObjectSet();
|
$output = new DataObjectSet();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ class XMLDataFormatter extends DataFormatter {
|
||||||
public function supportedMimeTypes() {
|
public function supportedMimeTypes() {
|
||||||
return array(
|
return array(
|
||||||
'text/xml',
|
'text/xml',
|
||||||
|
'application/xml',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,15 @@ class Controller extends RequestHandlingData {
|
||||||
|
|
||||||
$body = parent::handleRequest($request);
|
$body = parent::handleRequest($request);
|
||||||
if($body instanceof HTTPResponse) {
|
if($body instanceof HTTPResponse) {
|
||||||
|
if(isset($_REQUEST['debug_request'])) Debug::message("Request handler returned HTTPResponse object to $this->class controller; returning it without modification.");
|
||||||
$this->response = $body;
|
$this->response = $body;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(is_object($body)) $body = $body->getViewer($request->latestParam('Action'))->process($body);
|
if(is_object($body)) {
|
||||||
|
if(isset($_REQUEST['debug_request'])) Debug::message("Request handler $body->class object to $this->class controller;, rendering with template returned by $body->class::getViewer()");
|
||||||
|
$body = $body->getViewer($request->latestParam('Action'))->process($body);
|
||||||
|
}
|
||||||
|
|
||||||
$this->response->setBody($body);
|
$this->response->setBody($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,4 +353,20 @@ class HTTPRequest extends Object implements ArrayAccess {
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
return $_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all mimetypes from the HTTP "Accept" header
|
||||||
|
* as an array.
|
||||||
|
*
|
||||||
|
* @param boolean $includeQuality Don't strip away optional "quality indicators", e.g. "application/xml;q=0.9" (Default: false)
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getAcceptMimetypes($includeQuality = false) {
|
||||||
|
$mimetypes = array();
|
||||||
|
$mimetypesWithQuality = explode(',',$this->getHeader('Accept'));
|
||||||
|
foreach($mimetypesWithQuality as $mimetypeWithQuality) {
|
||||||
|
$mimetypes[] = ($includeQuality) ? $mimetypeWithQuality : preg_replace('/;.*/', '', $mimetypeWithQuality);
|
||||||
|
}
|
||||||
|
return $mimetypes;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -235,13 +235,13 @@ class SQLQuery extends Object {
|
||||||
foreach($lumpedSortParts as $i => $sortPart) {
|
foreach($lumpedSortParts as $i => $sortPart) {
|
||||||
$sortPart = trim($sortPart);
|
$sortPart = trim($sortPart);
|
||||||
if(substr(strtolower($sortPart),-5) == ' desc') {
|
if(substr(strtolower($sortPart),-5) == ' desc') {
|
||||||
$select[] = substr($sortPart,0,-5) . " AS _SortColumn{$i}";
|
$this->select[] = substr($sortPart,0,-5) . " AS _SortColumn{$i}";
|
||||||
$newSorts[] = "_SortColumn{$i} DESC";
|
$newSorts[] = "_SortColumn{$i} DESC";
|
||||||
} else if(substr(strtolower($sortPart),-4) == ' asc') {
|
} else if(substr(strtolower($sortPart),-4) == ' asc') {
|
||||||
$select[] = substr($sortPart,0,-4) . " AS _SortColumn{$i}";
|
$this->select[] = substr($sortPart,0,-4) . " AS _SortColumn{$i}";
|
||||||
$newSorts[] = "_SortColumn{$i} ASC";
|
$newSorts[] = "_SortColumn{$i} ASC";
|
||||||
} else {
|
} else {
|
||||||
$select[] = "$sortPart AS _SortColumn{$i}";
|
$this->select[] = "$sortPart AS _SortColumn{$i}";
|
||||||
$newSorts[] = "_SortColumn{$i} ASC";
|
$newSorts[] = "_SortColumn{$i} ASC";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ class ComplexTableField extends TableListField {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewer() {
|
function getViewer() {
|
||||||
return new SSViewer('ComplexTableField');
|
return new SSViewer($this->template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -982,7 +982,20 @@ JS
|
||||||
function setTemplate($template) {
|
function setTemplate($template) {
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function CurrentLink() {
|
||||||
|
$link = $this->Link();
|
||||||
|
|
||||||
|
if(isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) {
|
||||||
|
$start = ($_REQUEST['ctf'][$this->Name()]['start'] < 0) ? 0 : $_REQUEST['ctf'][$this->Name()]['start'];
|
||||||
|
$link .= "/?ctf[{$this->Name()}][start]={$start}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
|
||||||
|
|
||||||
|
return $link;
|
||||||
|
}
|
||||||
|
|
||||||
function BaseLink() {
|
function BaseLink() {
|
||||||
user_error("TableListField::BaseLink() deprecated, use Link() instead", E_USER_NOTICE);
|
user_error("TableListField::BaseLink() deprecated, use Link() instead", E_USER_NOTICE);
|
||||||
return $this->Link();
|
return $this->Link();
|
||||||
|
@ -1130,14 +1143,15 @@ class TableListField_Item extends ViewableData {
|
||||||
function Can($mode) {
|
function Can($mode) {
|
||||||
return $this->parent->Can($mode);
|
return $this->parent->Can($mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Link() {
|
||||||
|
return Controller::join_links($this->parent->Link() . "item/" . $this->item->ID);
|
||||||
|
}
|
||||||
|
|
||||||
function BaseLink() {
|
function BaseLink() {
|
||||||
user_error("TableListField_Item::BaseLink() deprecated, use Link() instead", E_USER_NOTICE);
|
user_error("TableListField_Item::BaseLink() deprecated, use Link() instead", E_USER_NOTICE);
|
||||||
return $this->Link() . '/ajax_refresh';
|
return $this->Link() . '/ajax_refresh';
|
||||||
}
|
}
|
||||||
function Link() {
|
|
||||||
return Controller::join_links($this->parent->Link() . "item/" . $this->item->ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
function DeleteLink() {
|
function DeleteLink() {
|
||||||
return Controller::join_links($this->Link(), "delete");
|
return Controller::join_links($this->Link(), "delete");
|
||||||
|
|
|
@ -126,12 +126,13 @@ TableListField.prototype = {
|
||||||
} else {
|
} else {
|
||||||
var el = $(this.id);
|
var el = $(this.id);
|
||||||
}
|
}
|
||||||
new Ajax.Updater(
|
|
||||||
$(this.id),
|
new Ajax.Request(
|
||||||
el.getAttribute('href'),
|
el.getAttribute('href'),
|
||||||
{
|
{
|
||||||
postBody: 'update=1',
|
postBody: 'update=1',
|
||||||
onComplete: function() {
|
onComplete: function(response) {
|
||||||
|
Element.replace(this.id, response.responseText)
|
||||||
Behaviour.apply($(this.id))
|
Behaviour.apply($(this.id))
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,9 @@ class Member extends DataObject {
|
||||||
* (LIKE, FULLTEXT) and default FormFields to construct a searchform.
|
* (LIKE, FULLTEXT) and default FormFields to construct a searchform.
|
||||||
*/
|
*/
|
||||||
static $searchable_fields = array(
|
static $searchable_fields = array(
|
||||||
'FirstName' => true,
|
'FirstName',
|
||||||
'Surname' => true,
|
'Surname',
|
||||||
'Email' => true,
|
'Email',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div id="$id" class="$CSSClasses field" href="$Link">
|
<div id="$id" class="$CSSClasses field" href="$CurrentLink">
|
||||||
<div class="middleColumn">
|
<div class="middleColumn">
|
||||||
<% include TableListField_PageControls %>
|
<% include TableListField_PageControls %>
|
||||||
<table class="data">
|
<table class="data">
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the security class, including log-in form, change password form, etc
|
* Test the security class, including log-in form, change password form, etc
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue