mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-05 08:07:33 +02:00
[BridgeAbstract] Update constant definition
@@ -1,8 +1,7 @@
|
|||||||
`BridgeAbstract` is a base class intended for standard Bridges that need to filter HTML pages for content.
|
`BridgeAbstract` is a base class intended for standard Bridges that need to filter HTML pages for content.
|
||||||
|
|
||||||
To create a new Bridge extending `BridgeAbstract` you must implement following functions:
|
To create a new Bridge extending `BridgeAbstract` you must specify some [basic metadata](#basic-metadata) implement following functions:
|
||||||
|
|
||||||
- [`loadMetadatas`](#the-loadmetadatas-function) (**required**)
|
|
||||||
- [`collectData`](#the-collectdata-function) (**required**)
|
- [`collectData`](#the-collectdata-function) (**required**)
|
||||||
- [`getName`](#the-getname-function)
|
- [`getName`](#the-getname-function)
|
||||||
- [`getURI`](#the-geturi-function)
|
- [`getURI`](#the-geturi-function)
|
||||||
@@ -10,59 +9,54 @@ To create a new Bridge extending `BridgeAbstract` you must implement following f
|
|||||||
|
|
||||||
Find a [template](#template) at the end of this file.
|
Find a [template](#template) at the end of this file.
|
||||||
|
|
||||||
## The `loadMetadatas` function
|
## Basic metadata
|
||||||
|
|
||||||
This function is used by **RSS-Bridge** to determine the name, maintainer name, website, last updated date... of the bridge, and the user parameters.
|
|
||||||
|
|
||||||
### Basic metadata
|
|
||||||
|
|
||||||
The basic metadata are :
|
The basic metadata are :
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
$this->maintainer // Name of the maintainer
|
const NAME // Name of the Bridge
|
||||||
$this->name // Name of the bridge
|
const URI // URI to the target website of the bridge ("http://....")
|
||||||
$this->uri // URI to the target website of the bridge ("http://....")
|
const DESCRIPTION // A brief description of the Bridge
|
||||||
$this->description // A brief description of the bridge
|
const MAINTAINER // Name of the maintainer
|
||||||
$this->parameters // (optional) Definition of additional parameters
|
const PARAMETERS // (optional) Definition of additional parameters
|
||||||
```
|
```
|
||||||
|
|
||||||
Find a description of `$this->parameters` [below](#parameters)
|
Find a description of `const PARAMETERS` [below](#parameters)
|
||||||
|
|
||||||
The default values are :
|
The default values are :
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
$this->maintainer = 'No maintainer';
|
const NAME = "Unnamed bridge";
|
||||||
$this->name = "Unnamed bridge";
|
const URI = "";
|
||||||
$this->uri = "";
|
const DESCRIPTION = 'No description provided';
|
||||||
$this->description = 'No description provided';
|
const MAINTAINER = 'No maintainer';
|
||||||
$this->parameters = array();
|
const PARAMETERS = array();
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
Parameters are defined in an array, which is used to generate an HTML `<form>` by **RSS-Bridge**.
|
Parameters are defined in an array, which is used to generate an HTML `<form>` by **RSS-Bridge**.
|
||||||
|
|
||||||
The `$this->parameters` array is not mandatory if your bridge doesn't take any parameter.
|
The `const PARAMETERS` array is not mandatory if your bridge doesn't take any parameter.
|
||||||
|
|
||||||
The first level of this array describes every possible usage of a bridge.
|
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 :
|
The array can be a key-based array, but it is not necessary. The following syntaxes are hereby correct :
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
$this->parameters[] = ...
|
const PARAMETERS = array(array(...), array(...));
|
||||||
$this->parameters['First usage of my bridge'] = ...
|
const PARAMETERS = array('First usage' => array(...), 'Second usage' => array(...));
|
||||||
```
|
```
|
||||||
|
|
||||||
It is worth mentioning that you can also define a set of parameters that will be applied to every possible utilization of your bridge.
|
It is worth mentioning that you can also define a set of parameters that will be applied to every possible utilization of your bridge. To do this, just create a parameter array with the `global` key :
|
||||||
To do this, just create a parameter array with the `global` key :
|
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
$this->parameters['global'] = ...
|
const PARAMETERS = array('global' => array(...));
|
||||||
```
|
```
|
||||||
|
|
||||||
### Format specifications
|
### Format specifications
|
||||||
|
|
||||||
`$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.
|
`const 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 :
|
Following elements are supported :
|
||||||
|
|
||||||
@@ -81,9 +75,9 @@ Hence, the most basic parameter definition is the following :
|
|||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
...
|
...
|
||||||
$this->parameters[] = array(
|
const PARAMETERS = array(
|
||||||
'u' => array('name' => 'Username')
|
'u' => array('name' => 'Username')
|
||||||
)
|
);
|
||||||
|
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
@@ -132,7 +126,6 @@ If a more complex organization is required to display the values, the above key/
|
|||||||
|
|
||||||
## The `collectData` function
|
## 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`.
|
|
||||||
This function is the place where all the website scrapping and the RSS feed generation process must be implemented.
|
This function is the place where all the website scrapping and the RSS feed generation process must be implemented.
|
||||||
|
|
||||||
RSS elements collected by this function must be stored in the class variable `items[]`.
|
RSS elements collected by this function must be stored in the class variable `items[]`.
|
||||||
@@ -172,7 +165,7 @@ Parameter | ATOM | HTML | (M)RSS
|
|||||||
|
|
||||||
This function returns the name of the bridge as it will be displayed on the main page of **RSS-Bridge** or on top of the feed output (HTML, ATOM, etc...).
|
This function returns the name of the bridge as it will be displayed on the main page of **RSS-Bridge** or on top of the feed output (HTML, ATOM, etc...).
|
||||||
|
|
||||||
**Notice:** **RSS-Bridge** will by default return `$this->name` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior!
|
**Notice:** **RSS-Bridge** will by default return `const NAME` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior!
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
public function getName(){
|
public function getName(){
|
||||||
@@ -184,7 +177,7 @@ This function returns the name of the bridge as it will be displayed on the main
|
|||||||
|
|
||||||
This function returns the URI to the destination site of the bridge. It will be used on the main page of rss-bridge when clicking your bridge name.
|
This function returns the URI to the destination site of the bridge. It will be used on the main page of rss-bridge when clicking your bridge name.
|
||||||
|
|
||||||
**Notice:** **RSS-Bridge** will by default return `$this->uri` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior!
|
**Notice:** **RSS-Bridge** will by default return `const URI` which is defined in the [`loadMetadatas`](#the-loadmetadatas-function) function, so you only have to implement this function if you require different behavior!
|
||||||
|
|
||||||
```PHP
|
```PHP
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
@@ -262,15 +255,13 @@ This is the minimum template for a new bridge:
|
|||||||
```PHP
|
```PHP
|
||||||
<?php
|
<?php
|
||||||
class MySiteBridge extends BridgeAbstract {
|
class MySiteBridge extends BridgeAbstract {
|
||||||
public function loadMetadatas(){
|
const NAME = 'Unnamed bridge';
|
||||||
$this->maintainer = 'No maintainer';
|
const URI = '';
|
||||||
$this->name = 'Unnamed bridge';
|
const DESCRIPTION = 'No description provided';
|
||||||
$this->uri = '';
|
const MAINTAINER = 'No maintainer';
|
||||||
$this->description = 'No description provided';
|
const PARAMETERS = array();
|
||||||
$this->parameters = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData(array $params){
|
public function collectData(){
|
||||||
// Implement your bridge here!
|
// Implement your bridge here!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user