mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-29 23:25:45 +02:00
Updated BridgeAbstract (markdown)
parent
100b81caa6
commit
fdd92b9d9d
1 changed files with 43 additions and 14 deletions
|
@ -40,11 +40,11 @@ $this->parameters = array();
|
|||
|
||||
### Parameters
|
||||
|
||||
Parameters are defined in a JSON-like format, which is parsed and transformed into a HTML `<form>` by **RSS-Bridge**.
|
||||
Parameters are defined in an array, which is used to generate an HTML `<form>` by **RSS-Bridge**.
|
||||
|
||||
These data go into the `$this->parameters` array, which is not mandatory if your bridge doesn't take any parameter.
|
||||
The `$this->parameters` array is not mandatory if your bridge doesn't take any parameter.
|
||||
|
||||
Every possible usage of a bridge is an array element.
|
||||
The first level of this array describes every possible usage of a bridge.
|
||||
|
||||
The array can be a key-based array, but it is not necessary. The following syntaxes are hereby correct :
|
||||
|
||||
|
@ -62,17 +62,16 @@ $this->parameters['global'] = ...
|
|||
|
||||
### Format specifications
|
||||
|
||||
Every `$this->parameters` element is a JSON array of cluster (`[ ... ]`) containing all input fields.
|
||||
`$this->parameters[]` element is an associative array whose key is the input field identifier, and the value is another array containing all input fields names and values.
|
||||
|
||||
Following elements are supported :
|
||||
|
||||
Parameter Name | Required | Type | Supported values | Description
|
||||
---------------|----------|------|------------------| -----------
|
||||
`name` | **yes** | Text | | Input name as displayed to the user
|
||||
`identifier` | **yes** | Text | | Identifier, which will be the key in the `$param` array for the [`collectData`](#the-collectdata-function) function
|
||||
`type` | no | Text | `text`, `number`, `list`, `checkbox` |Type of the input, default is text
|
||||
`required` | no | Boolean | `true`, `false` | Set this if you want your attribute to be required
|
||||
`values` | no | Text | `[ {"name" : option1Name, "value" : "option1Value"}, ... ]` | Values list, required with the '`list`' type
|
||||
[`values`](#list-values) | no | associative array | | name/value pairs used by the HTML option tag, required with the '`list`' type
|
||||
`title` | no | Text | | Will be shown as tool-tip when mouse-hovering over the input
|
||||
`pattern` | no | Text | | Defines a pattern for an element of type `text`. The required pattern should be mentioned in the `title` attribute!
|
||||
`exampleValue` | no | Text | | Defines an example value that is shown for elements of type `text` and `number`
|
||||
|
@ -82,13 +81,10 @@ Hence, the most basic parameter definition is the following :
|
|||
|
||||
```PHP
|
||||
...
|
||||
$this->parameters[] =
|
||||
'[
|
||||
{
|
||||
"name" : "Username",
|
||||
"identifier" : "u"
|
||||
}
|
||||
]';
|
||||
$this->parameters[] = array(
|
||||
'u'=>array('name'=>'Username')
|
||||
)
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
|
@ -101,6 +97,39 @@ This attribute defines the default value for your parameter. Its behavior depend
|
|||
- `list`: Must match either name or value of one element
|
||||
- `checkbox`: Must be "checked" to activate the checkbox
|
||||
|
||||
#### List values
|
||||
|
||||
List values are defined in an associative array where keys are the string displayed in the combo list of the **RSS-Bridge** web interface, and values are the content of the \<option\> HTML tag value attribute.
|
||||
|
||||
```PHP
|
||||
...
|
||||
'type'=>'list',
|
||||
'values'=>array(
|
||||
'Item A'=>'itemA'
|
||||
'Item B'=>'itemB'
|
||||
)
|
||||
...
|
||||
```
|
||||
|
||||
If a more complex organization is required to display the values, the above key/value can be used to set a title as a key and another array as a value:
|
||||
```PHP
|
||||
...
|
||||
'type'=>'list',
|
||||
'values'=>array(
|
||||
'Item A'=>'itemA',
|
||||
'List 1'=>array(
|
||||
'Item C'=>'itemC',
|
||||
'Item D'=>'itemD'
|
||||
),
|
||||
'List 2'=>array(
|
||||
'Item E'=>'itemE',
|
||||
'Item F'=>'itemF'
|
||||
),
|
||||
'Item B'=>'itemB'
|
||||
)
|
||||
...
|
||||
```
|
||||
|
||||
## The `collectData` function
|
||||
|
||||
This function takes as a parameter an array called `$param`, that is automatically filled with values from the user, according to the values defined in the parameters array in `loadMetadatas`.
|
||||
|
@ -246,4 +275,4 @@ class MySiteBridge extends BridgeAbstract{
|
|||
}
|
||||
}
|
||||
// Imaginary empty line!
|
||||
```
|
||||
`
|
Loading…
Add table
Add a link
Reference in a new issue