Skip to content

Commit

Permalink
Fixed references to deprecated APIs in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jun 28, 2012
1 parent 0236a3c commit 19e087d
Show file tree
Hide file tree
Showing 29 changed files with 243 additions and 357 deletions.
2 changes: 1 addition & 1 deletion docs/en/changelogs/3.0.0.md
Expand Up @@ -625,7 +625,7 @@ Note that its just necessary if SilverStripe is used in a language other than th
The SS_Report::register() method is deprecated. You no longer need to explicitly register reports. The CMS now The SS_Report::register() method is deprecated. You no longer need to explicitly register reports. The CMS now
automatically picks up and adds all Report classes to the list of reports in ReportAdmin. You can choose to exclude automatically picks up and adds all Report classes to the list of reports in ReportAdmin. You can choose to exclude
certain reports by using the SS_Report::add_excluded_reports() method. certain reports by using the SS_Report::add_excluded_reports() method.
fe
### Removed the ability use a SQLQuery object in a SS_Report ### Removed the ability use a SQLQuery object in a SS_Report


You can no longer create reports that using the deprecated DataObject->buildSQL and DataObject->extendedSQL You can no longer create reports that using the deprecated DataObject->buildSQL and DataObject->extendedSQL
Expand Down
4 changes: 1 addition & 3 deletions docs/en/howto/dynamic-default-fields.md
Expand Up @@ -2,7 +2,7 @@


The [api:DataObject::$defaults] array allows you to specify simple static values to be the default value for when a The [api:DataObject::$defaults] array allows you to specify simple static values to be the default value for when a
record is created, but in many situations default values needs to be dynamically calculated. In order to do this, the record is created, but in many situations default values needs to be dynamically calculated. In order to do this, the
[api:DataObjectSet->populateDefaults()] method will need to be overloaded. `[api:DataObject->populateDefaults()]` method will need to be overloaded.


This method is called whenever a new record is instantiated, and you must be sure to call the method on the parent This method is called whenever a new record is instantiated, and you must be sure to call the method on the parent
object! object!
Expand All @@ -13,7 +13,6 @@ A simple example is to set a field to the current date and time:
/** /**
* Sets the Date field to the current date. * Sets the Date field to the current date.
*/ */

public function populateDefaults() { public function populateDefaults() {
$this->Date = date('Y-m-d'); $this->Date = date('Y-m-d');
parent::populateDefaults(); parent::populateDefaults();
Expand All @@ -27,7 +26,6 @@ methods. For example:
* This method combines the Title of the parent object with the Title of this * This method combines the Title of the parent object with the Title of this
* object in the FullTitle field. * object in the FullTitle field.
*/ */

public function populateDefaults() { public function populateDefaults() {
if($parent = $this->Parent()) { if($parent = $this->Parent()) {
$this->FullTitle = $parent->Title . ': ' . $this->Title; $this->FullTitle = $parent->Title . ': ' . $this->Title;
Expand Down
5 changes: 2 additions & 3 deletions docs/en/howto/extend-cms-interface.md
Expand Up @@ -85,9 +85,8 @@ Create a new file called `zzz_admin/code/BookmarkedPageExtension.php` and insert
:::php :::php
<?php <?php
class BookmarkedPageExtension extends DataExtension { class BookmarkedPageExtension extends DataExtension {
public function extraStatics() { static $db = array('IsBookmarked' => 'Boolean');
return array('db' => array('IsBookmarked' => 'Boolean'));
}
public function updateCMSFields(&$fields) { public function updateCMSFields(&$fields) {
$fields->addFieldToTab('Root.Main', $fields->addFieldToTab('Root.Main',
new CheckboxField('IsBookmarked', "Show in CMS bookmarks?") new CheckboxField('IsBookmarked', "Show in CMS bookmarks?")
Expand Down
25 changes: 5 additions & 20 deletions docs/en/reference/complextablefield.md
Expand Up @@ -2,6 +2,10 @@


## Introduction ## Introduction


<div class="warning" markdown="1">
This field is deprecated in favour of the new [GridField](/topics/grid-field) API.
</div>

Shows a group of DataObjects as a (readonly) tabular list (similiar to `[api:TableListField]`.) Shows a group of DataObjects as a (readonly) tabular list (similiar to `[api:TableListField]`.)


You can specify limits and filters for the resultset by customizing query-settings (mostly the ID-field on the other You can specify limits and filters for the resultset by customizing query-settings (mostly the ID-field on the other
Expand Down Expand Up @@ -128,23 +132,4 @@ Most of the time, you need to override the following methods:


* ComplexTableField->sourceItems() - querying * ComplexTableField->sourceItems() - querying
* ComplexTableField->DetailForm() - form output * ComplexTableField->DetailForm() - form output
* ComplexTableField_Popup->saveComplexTableField() - saving * ComplexTableField_Popup->saveComplexTableField() - saving

### Examples

* `[api:AssetTableField]`
* `[api:MemberTableField]`

## API Documentation

`[api:ComplexTableField]`

## Todo

* Find a less fragile solution for accessing this field through the main controller and ReferencedField, e.g. build a
seperate CTF-instance (doesn't necessarly have to be connected to the original by ReferencedField)
* Control width/height of popup by constructor (hardcoded at the moment)
* Integrate search from MemberTableField.php directly on `[api:ComplexTableField]`
* Less performance-hungry implementation of detail-view paging (don't return all items on a single view)
* Use automatic has-many and many-many functions to return a ComponentSet rather than building the join manually
* Javascript/Ajax-Sorting (see [http://www.activewidgets.com/grid/](http://www.activewidgets.com/grid/) and [http://openrico.org/rico/livegrid.page](http://openrico.org/rico/livegrid.page))
46 changes: 16 additions & 30 deletions docs/en/reference/dataextension.md
Expand Up @@ -45,56 +45,42 @@ For example above we want to override Member with a Custom Member so we would wr


### Adding extra database fields ### Adding extra database fields


Extra database fields can be added with a extension by defining an **extraStatics()** method. These will be added to the table of the base object - the extension will actually edit the $db, $has_one, etc static variables on load. Extra database fields can be added with a extension in the same manner as if they
were placed on the `DataObject` class they're applied to. These will be added to the table of the base object - the extension will actually edit the $db, $has_one, etc static variables on load.


The function should return a map where the keys are the names of the static variables to update: The function should return a map where the keys are the names of the static variables to update:


:::php :::php
class CustomMember extends DataExtension { class CustomMember extends DataExtension {

static $db = array(
public function extraStatics() { 'AvatarURL' => 'Varchar',
return array( );
'db' => array( static $has_one = array(
'AvatarURL' => 'Varchar', 'RelatedMember' => 'Member',
), );
'has_one' => array(
'RelatedMember' => 'Member',
),
);
}
} }



*NOTE*
If you want to add has_one or db items to a particular class, then that class **must** have that static variable
explicitly defined, even if it's just a blank array. For example, the extension method above wouldn't work if you added
to a class that didn't have static $has_one explicitly declared on the object. This is because of PHP's crappy support
for statics.


### Modifying CMS Fields ### Modifying CMS Fields


The member class demonstrates an extension that allows you to update the default CMS fields for an object in a The member class demonstrates an extension that allows you to update the default CMS fields for an
extension: object in an extension:


:::php :::php
public function getCMSFields() { public function getCMSFields() {
... // ...
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);
return $fields; return $fields;
} }




The $fields parameter is passed by reference, as it is an object. The `$`fields parameter is passed by reference, as it is an object.


:::php :::php
public function updateCMSFields(FieldList $fields) { public function updateCMSFields(FieldList $fields) {
$fields->push(new TextField('Position', 'Position Title')); $fields->push(new TextField('Position', 'Position Title'));
$fields->push(new UploadField('Image', 'Profile Image')); $fields->push(new UploadField('Image', 'Profile Image'));
} }




### Custom database generation ### Custom database generation


Some extensions are designed to transparently add more sophisticated data-collection capabilities to your data object. Some extensions are designed to transparently add more sophisticated data-collection capabilities to your data object.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/dataobject.md
Expand Up @@ -31,7 +31,7 @@ by adding, removing or configuring fields.
'IsActive' => 'Boolean' 'IsActive' => 'Boolean'
); );
public function getCMSFields() { public function getCMSFields() {
return new FieldSet( return new FieldList(
new CheckboxField('IsActive') new CheckboxField('IsActive')
); );
} }
Expand Down
18 changes: 0 additions & 18 deletions docs/en/reference/director.md
Expand Up @@ -10,24 +10,6 @@ the viewer and/or perform processing steps.


* Checking for an Ajax-Request: Use Director::is_ajax() instead of checking for $_REQUEST['ajax']. * Checking for an Ajax-Request: Use Director::is_ajax() instead of checking for $_REQUEST['ajax'].


## Redirection

The `[api:Director]` class has a number of methods to facilitate 301 and 302 HTTP redirection.

* **Director::redirect("action-name")**: If there's no slash in the URL passed to redirect, then it is assumed that you
want to go to a different action on the current controller.
* **Director::redirect("relative/url")**: If there is a slash in the URL, it's taken to be a normal URL. Relative URLs
will are assumed to be relative to the site-root; so Director::redirect("home/") will work no matter what the current
URL is.
* **Director::redirect("http://www.absoluteurl.com")**: Of course, you can pass redirect() absolute URL s too.
* **Director::redirectPerm("any-url")**: redirectPerm takes the same arguments as redirect, but it will send a 301
(permanent) instead of a 302 (temporary) header. It improves search rankings, so this should be used whenever the
following two conditions are true:
* Nothing happens server-side prior to the redirection
* The redirection will always occur
* **Director::redirectBack()**: This will return you to the previous page. There's no permanent version of
redirectBack().



## Request processing ## Request processing


Expand Down
2 changes: 0 additions & 2 deletions docs/en/reference/form-field-types.md
Expand Up @@ -34,8 +34,6 @@ This is a highlevel overview of available `[api:apiFormField]` subclasses. An au
* `[api:NumericField]`: Text input field with validation for numeric values. * `[api:NumericField]`: Text input field with validation for numeric values.
* `[api:OptionsetField]`: Set of radio buttons designed to emulate a dropdown. * `[api:OptionsetField]`: Set of radio buttons designed to emulate a dropdown.
* `[api:PhoneNumberField]`: Field for displaying phone numbers. It separates the number, the area code and optionally the country code and extension. * `[api:PhoneNumberField]`: Field for displaying phone numbers. It separates the number, the area code and optionally the country code and extension.
* `[api:UniqueRestrictedTextField]`: Text field that automatically checks that the value entered is unique for the given set of fields in a given set of tables

* `[api:SelectionGroup]`: SelectionGroup represents a number of fields which are selectable by a radio button that appears at the beginning of each item. * `[api:SelectionGroup]`: SelectionGroup represents a number of fields which are selectable by a radio button that appears at the beginning of each item.
* `[api:TimeField]`: Input field with time-specific, localized validation. * `[api:TimeField]`: Input field with time-specific, localized validation.


Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/image.md
Expand Up @@ -72,10 +72,10 @@ You can also create your own functions by extending the image class, for example
public function Exif(){ public function Exif(){
//http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data //http://www.v-nessa.net/2010/08/02/using-php-to-extract-image-exif-data
$image = $this->AbsoluteURL; $image = $this->AbsoluteURL;
$d=new DataObjectSet(); $d=new ArrayList();
$exif = exif_read_data($image, 0, true); $exif = exif_read_data($image, 0, true);
foreach ($exif as $key => $section) { foreach ($exif as $key => $section) {
$a=new DataObjectSet(); $a=new ArrayList();
foreach ($section as $name => $val) foreach ($section as $name => $val)
$a->push(new ArrayData(array("Title"=>$name,"Content"=>$val))); $a->push(new ArrayData(array("Title"=>$name,"Content"=>$val)));
$d->push(new ArrayData(array("Title"=>strtolower($key),"Content"=>$a))); $d->push(new ArrayData(array("Title"=>strtolower($key),"Content"=>$a)));
Expand Down
9 changes: 6 additions & 3 deletions docs/en/reference/member.md
Expand Up @@ -113,9 +113,12 @@ things, you should add appropriate `[api:Permission::checkMember()]` calls to th
} }
} }


public function extraStatics() { // define additional properties
// Return an array containing keys 'db', 'has_one', 'many_many', 'belongs_many_many', static $db = array();
} static $has_one = array();
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();


public function somethingElse() { public function somethingElse() {
// You can add any other methods you like, which you can call directly on the member object. // You can add any other methods you like, which you can call directly on the member object.
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/searchcontext.md
Expand Up @@ -12,7 +12,7 @@ The default output of a `[api:SearchContext]` is either a `[api:SQLQuery]` objec
In case you need multiple contexts, consider namespacing your request parameters by using `FieldList->namespace()` on In case you need multiple contexts, consider namespacing your request parameters by using `FieldList->namespace()` on
the $fields constructor parameter. the $fields constructor parameter.


`[api:SearchContext]` is mainly used by `[api:ModelAdmin]`, our generic data administration interface. Another `[api:SearchContext]` is mainly used by `[ModelAdmin](/reference/modeladmin)`, our generic data administration interface. Another
implementation can be found in generic frontend search forms through the [genericviews](http://silverstripe.org/generic-views-module) module. implementation can be found in generic frontend search forms through the [genericviews](http://silverstripe.org/generic-views-module) module.


## Usage ## Usage
Expand Down Expand Up @@ -187,6 +187,6 @@ See `[api:SearchFilter]` API Documentation


## Related ## Related


* `[api:ModelAdmin]` * [ModelAdmin](/reference/modeladmin)
* [RestfulServer module](https://github.com/silverstripe/silverstripe-restfulserver) * [RestfulServer module](https://github.com/silverstripe/silverstripe-restfulserver)
* [Tutorial: Site Search](/tutorials/4-site-search) * [Tutorial: Site Search](/tutorials/4-site-search)
10 changes: 3 additions & 7 deletions docs/en/reference/siteconfig.md
Expand Up @@ -39,13 +39,9 @@ Create a mysite/code/CustomSiteConfig.php file.


class CustomSiteConfig extends DataExtension { class CustomSiteConfig extends DataExtension {
public function extraStatics() { static $db = array(
return array( 'FooterContent' => 'HTMLText'
'db' => array( );
'FooterContent' => 'HTMLText'
)
);
}


public function updateCMSFields(FieldList $fields) { public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content")); $fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
Expand Down

0 comments on commit 19e087d

Please sign in to comment.