forked from blallo/rss-bridge
[core] simplify dynamic formats discovery
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
13285f080a
commit
eb3392db82
6 changed files with 5 additions and 35 deletions
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* Atom
|
* Atom
|
||||||
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
|
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
|
||||||
*
|
|
||||||
* @name Atom
|
|
||||||
*/
|
*/
|
||||||
class AtomFormat extends FormatAbstract{
|
class AtomFormat extends FormatAbstract{
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Html
|
|
||||||
* Documentation Source http://en.wikipedia.org/wiki/Atom_%28standard%29 and http://tools.ietf.org/html/rfc4287
|
|
||||||
*
|
|
||||||
* @name Html
|
|
||||||
*/
|
|
||||||
class HtmlFormat extends FormatAbstract{
|
class HtmlFormat extends FormatAbstract{
|
||||||
|
|
||||||
public function stringify(){
|
public function stringify(){
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* Json
|
* Json
|
||||||
* Builds a JSON string from $this->items and return it to browser.
|
* Builds a JSON string from $this->items and return it to browser.
|
||||||
*
|
|
||||||
* @name Json
|
|
||||||
*/
|
*/
|
||||||
class JsonFormat extends FormatAbstract{
|
class JsonFormat extends FormatAbstract{
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* Mrss
|
* Mrss
|
||||||
* Documentation Source http://www.rssboard.org/media-rss
|
* Documentation Source http://www.rssboard.org/media-rss
|
||||||
*
|
|
||||||
* @name Media RSS
|
|
||||||
*/
|
*/
|
||||||
class MrssFormat extends FormatAbstract{
|
class MrssFormat extends FormatAbstract{
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* Plaintext
|
* Plaintext
|
||||||
* Returns $this->items as raw php data.
|
* Returns $this->items as raw php data.
|
||||||
*
|
|
||||||
* @name Plaintext
|
|
||||||
*/
|
*/
|
||||||
class PlaintextFormat extends FormatAbstract{
|
class PlaintextFormat extends FormatAbstract{
|
||||||
|
|
||||||
|
|
|
@ -168,29 +168,13 @@ class Format{
|
||||||
|
|
||||||
$dirFiles = scandir($pathDirFormat);
|
$dirFiles = scandir($pathDirFormat);
|
||||||
if( $dirFiles !== false ){
|
if( $dirFiles !== false ){
|
||||||
foreach( $dirFiles as $fileName ){
|
foreach( $dirFiles as $fileName ){
|
||||||
if( preg_match('@([^.]+)\.php@U', $fileName, $out) ){ // Is PHP file ?
|
if( preg_match('@^([^.]+)\.php$@U', $fileName, $out) ){ // Is PHP file ?
|
||||||
$infos = array(); // Information about the bridge
|
$listFormat[] = $out[1];
|
||||||
$resParse = token_get_all(file_get_contents($pathDirFormat . $fileName)); // Parse PHP file
|
|
||||||
foreach($resParse as $v){
|
|
||||||
if( is_array($v) && $v[0] == T_DOC_COMMENT ){ // Lexer node is COMMENT ?
|
|
||||||
$commentary = $v[1];
|
|
||||||
foreach( $searchCommonPattern as $name){ // Catch information with common pattern
|
|
||||||
preg_match('#@' . preg_quote($name, '#') . '\s+(.+)#', $commentary, $outComment);
|
|
||||||
if( isset($outComment[1]) ){
|
|
||||||
$infos[$name] = $outComment[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( isset($infos['name']) ){ // If informations containt at least a name
|
|
||||||
$listFormat[$out[1]] = $infos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $listFormat;
|
return $listFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue