diff --git a/.gitignore b/.gitignore index 2359a6d5..4c658bf7 100644 --- a/.gitignore +++ b/.gitignore @@ -170,6 +170,7 @@ App_Data/*.ldf ## Other ide stuff ################# .idea/* +[#]*[#] ############# ## Windows detritus diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md index 6324221c..7041ec93 100644 --- a/CREATE_BRIDGE.md +++ b/CREATE_BRIDGE.md @@ -90,6 +90,7 @@ Parameter Name | Parameter values | Description type|text, number, list, checkbox| Type of the input, default is text required| true | Set this if you want your attribute to be required values| [ {"name" : option1Name, "value" : "option1Value"}, ...] | Values list, required with the 'list' type +title| text | Will be shown as tooltip when mouse-hovering over the input #### Guidelines diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 24cd3891..b1d8515e 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -53,6 +53,16 @@ class DemoBridge extends BridgeAbstract{ public function collectData(array $param){ + $item = new \Item(); + $item->name = "TestElement"; + $item->title = "Test"; + $item->content = "Awesome content !"; + $item->id = "Lalala"; + $item->uri = "http://test.test/test"; + $item->enclosures[] = "http://www.ardmediathek.de/ard/servlet/image/00/32/68/18/38/1135274624/16x9/960"; + + $this->items[] = $item; + } public function getName() { @@ -68,6 +78,6 @@ class DemoBridge extends BridgeAbstract{ } public function getCacheDuration(){ - return 3600; // 1 hour + return 00; // 1 hour } } diff --git a/bridges/JapanExpoBridge.php b/bridges/JapanExpoBridge.php new file mode 100644 index 00000000..c9ebbbaa --- /dev/null +++ b/bridges/JapanExpoBridge.php @@ -0,0 +1,42 @@ +maintainer = "Ginko"; + $this->name = "JapanExpo"; + $this->uri = "http://www.japan-expo-paris.com/fr/actualites"; + $this->description = "Returns most recent results from Japan Expo actualités."; + $this->update = "2016-01-19"; + + } + + public function collectData(array $param){ + $link = 'http://www.japan-expo-paris.com/fr/actualites'; + + $html = file_get_html($link) or $this->returnError('Could not request JapanExpo. for : ' . $link , 404); + + foreach($html->find('a._tile2') as $element) { + $item = new Item(); + $item->uri = $element->href; + $item->title = $element->find('span._title', 0)->plaintext; + $style = $element->find('img.rspvimgset', 0)->style; + preg_match('/url\(([^)]+)\)/', $style, $match); + $item->content = "
".$element->find('span.date', 0)->plaintext; + $this->items[] = $item; + } + + } + + public function getName(){ + return 'Japan Expo Actualités'; + } + + public function getURI(){ + return 'http://www.japan-expo-paris.com/fr/actualites'; + } + + public function getCacheDuration(){ + return 86400; // 1 day + } +} diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php index 19016cc6..72d21099 100755 --- a/bridges/LeBonCoinBridge.php +++ b/bridges/LeBonCoinBridge.php @@ -134,7 +134,7 @@ class LeBonCoinBridge extends BridgeAbstract{ public function collectData(array $param){ $html = ''; - $link = 'http://www.leboncoin.fr/annonces/offres/' . $param[r] . '/?f=a&th=1&q=' . $param[k]; + $link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . $param['k']; $html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404); $list = $html->find('.list-lbc', 0); diff --git a/bridges/ThePirateBayBridge.php b/bridges/ThePirateBayBridge.php index adb36419..3e55c605 100644 --- a/bridges/ThePirateBayBridge.php +++ b/bridges/ThePirateBayBridge.php @@ -5,9 +5,9 @@ class ThePirateBayBridge extends BridgeAbstract{ $this->maintainer = "mitsukarenai"; $this->name = "The Pirate Bay"; - $this->uri = "https://thepiratebay.vg/"; + $this->uri = "https://thepiratebay.se/"; $this->description = "Returns results for the keywords. You can put several list of keywords by separating them with a semicolon (e.g. \"one show;another show\")"; - $this->update = "2014-05-26"; + $this->update = "2015-01-09"; $this->parameters[] = '[ @@ -60,7 +60,7 @@ class ThePirateBayBridge extends BridgeAbstract{ $keywordsList = explode(";",$param['q']); foreach($keywordsList as $keywords){ - $html = file_get_html('https://thepiratebay.vg/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); + $html = file_get_html('https://thepiratebay.se/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404); if ($html->find('table#searchResult', 0) == FALSE) $this->returnError('No result for query '.$keywords, 404); @@ -68,7 +68,7 @@ class ThePirateBayBridge extends BridgeAbstract{ foreach($html->find('tr') as $element) { $item = new \Item(); - $item->uri = 'https://thepiratebay.vg/'.$element->find('a.detLink',0)->href; + $item->uri = 'https://thepiratebay.se/'.$element->find('a.detLink',0)->href; $item->id = $item->uri; $item->timestamp = parseDateTimestamp($element); $item->title = $element->find('a.detLink',0)->plaintext; @@ -86,7 +86,7 @@ class ThePirateBayBridge extends BridgeAbstract{ } public function getURI(){ - return 'https://thepiratebay.vg/'; + return 'https://thepiratebay.se/'; } public function getCacheDuration(){ diff --git a/bridges/TwitchApiBridge.php b/bridges/TwitchApiBridge.php index aaa0d3b6..c3dbdefb 100644 --- a/bridges/TwitchApiBridge.php +++ b/bridges/TwitchApiBridge.php @@ -13,7 +13,7 @@ class TwitchApiBridge extends BridgeAbstract{ $this->name = "Twitch API Bridge"; $this->uri = "http://www.twitch.tv"; $this->description = "Returns the newest broadcasts or highlights by channel name using the Twitch API (v3)"; - $this->update = "2015-07-14"; + $this->update = "2016-01-09"; $this->parameters["Get channel without limit"] = '[ @@ -31,7 +31,7 @@ class TwitchApiBridge extends BridgeAbstract{ "value" : "true" }, { - "name" : "Don\'t show broadcasts", + "name" : "Show highlights", "value" : "false" } ] @@ -58,7 +58,7 @@ class TwitchApiBridge extends BridgeAbstract{ "value" : "true" }, { - "name" : "Don\'t show broadcasts", + "name" : "Show highlights", "value" : "false" } ] diff --git a/caches/FileCache.php b/caches/FileCache.php index f2e0dbb7..c348fdfb 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -8,7 +8,7 @@ class FileCache extends CacheAbstract{ public function loadData(){ $this->isPrepareCache(); - $datas = json_decode(file_get_contents($this->getCacheFile()),true); + $datas = unserialize(file_get_contents($this->getCacheFile())); $items = array(); foreach($datas as $aData){ $item = new \Item(); @@ -24,7 +24,10 @@ class FileCache extends CacheAbstract{ public function saveData($datas){ $this->isPrepareCache(); - $writeStream = file_put_contents($this->getCacheFile(), json_encode($datas)); + //Re-encode datas to UTF-8 + //$datas = Cache::utf8_encode_deep($datas); + + $writeStream = file_put_contents($this->getCacheFile(), serialize($datas)); if(!$writeStream) { diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index f3797e29..74e78db6 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -36,6 +36,15 @@ class AtomFormat extends FormatAbstract{ // We prevent content from closing the CDATA too early. $entryContent = is_null($data->content) ? '' : 'sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>'; + // We generate a list of the enclosure links + $entryEnclosures = ""; + + foreach($data->enclosures as $enclosure) { + + $entryEnclosures .= ""; + + } + $entries .= << @@ -48,6 +57,7 @@ class AtomFormat extends FormatAbstract{ {$entryUri} {$entryTimestamp} {$entryContent} + {$entryEnclosures} EOD; diff --git a/lib/Cache.php b/lib/Cache.php index fa80bc04..a165148d 100644 --- a/lib/Cache.php +++ b/lib/Cache.php @@ -70,6 +70,26 @@ class Cache{ return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache); } + + static public function utf8_encode_deep(&$input) { + if (is_string($input)) { + $input = utf8_encode($input); + } else if (is_array($input)) { + foreach ($input as &$value) { + Cache::utf8_encode_deep($value); + } + + unset($value); + } else if (is_object($input)) { + $vars = array_keys(get_object_vars($input)); + + foreach ($vars as $var) { + Cache::utf8_encode_deep($input->$var); + } + } + } + + static public function purge() { $cacheTimeLimit = time() - 60*60*24 ; $cachePath = 'cache'; diff --git a/lib/HTMLUtils.php b/lib/HTMLUtils.php index 3838c35d..dce8b8f0 100644 --- a/lib/HTMLUtils.php +++ b/lib/HTMLUtils.php @@ -80,6 +80,11 @@ CARD; $additionalInfoString .= " pattern=\"".$inputEntry['pattern']."\""; } + if(isset($inputEntry['title'])) { + + $additionalInfoString .= " title=\"" .$inputEntry['title']."\""; + + } if(!isset($inputEntry['exampleValue'])) $inputEntry['exampleValue'] = ""; $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($inputEntry['identifier']); diff --git a/lib/Item.php b/lib/Item.php index 2e15ffc3..699ec3da 100644 --- a/lib/Item.php +++ b/lib/Item.php @@ -2,15 +2,19 @@ interface ItemInterface{} /** -* Object to store datas collect informations -* FIXME : not sur this logic is the good, I think recast all is necessary -*/ + * Object to store datas collect informations + * FIXME : not sur this logic is the good, I think recast all is necessary + */ class Item implements ItemInterface{ + + // FIXME : use the arrayInterface instead + public $enclosures = array(); + public function __set($name, $value){ $this->$name = $value; } public function __get($name){ - return isset($this->$name) ? $this->$name : null; + return (isset($this->$name) ? $this->$name : null); } }