mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-15 13:45:04 -05:00
begin implement metadata
This commit is contained in:
parent
4362417495
commit
a175bebc40
@ -147,6 +147,21 @@ class Poche
|
||||
$content = Tools::getPageContent($url);
|
||||
$title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled');
|
||||
$body = $content['rss']['channel']['item']['description'];
|
||||
// TODO : convert date
|
||||
if ($content['rss']['channel']['item']['updated'] == '') { // ATOM
|
||||
if ($content['rss']['channel']['item']['pubDate'] == '') { // RSS
|
||||
if($content['rss']['channel']['item']['dc:date'] == '') { // other
|
||||
$date = '';}
|
||||
else {$date = $content['rss']['channel']['item']['dc:date'];}
|
||||
}
|
||||
else {$date = $content['rss']['channel']['item']['pubDate'];}
|
||||
}
|
||||
else {
|
||||
$date = $content['rss']['channel']['item']['updated'];
|
||||
}
|
||||
|
||||
$author = ($content['rss']['channel']['item']['author'] != '') ? $content['rss']['channel']['item']['author'] : _('Unknown author');
|
||||
$language = ($content['rss']['channel']['item']['language'] != '') ? $content['rss']['channel']['item']['language'] : '';
|
||||
|
||||
// clean content from prevent xss attack
|
||||
$purifier = $this->_getPurifier();
|
||||
|
@ -424,4 +424,84 @@ final class Tools
|
||||
return str_replace('+', '', $token);
|
||||
}
|
||||
|
||||
// Part of Text_LanguageDetect
|
||||
|
||||
/**
|
||||
* Maps ISO 639-1 2-letter language codes to the language names
|
||||
* in the language database
|
||||
*
|
||||
* Not all languages have a 2 letter code, so some are missing
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
public static $code2ToName = array(
|
||||
'ar' => 'arabic',
|
||||
'az' => 'azeri',
|
||||
'bg' => 'bulgarian',
|
||||
'bn' => 'bengali',
|
||||
'cs' => 'czech',
|
||||
'cy' => 'welsh',
|
||||
'da' => 'danish',
|
||||
'de' => 'german',
|
||||
'en' => 'english',
|
||||
'es' => 'spanish',
|
||||
'et' => 'estonian',
|
||||
'fa' => 'farsi',
|
||||
'fi' => 'finnish',
|
||||
'fr' => 'french',
|
||||
'ha' => 'hausa',
|
||||
'hi' => 'hindi',
|
||||
'hr' => 'croatian',
|
||||
'hu' => 'hungarian',
|
||||
'id' => 'indonesian',
|
||||
'is' => 'icelandic',
|
||||
'it' => 'italian',
|
||||
'kk' => 'kazakh',
|
||||
'ky' => 'kyrgyz',
|
||||
'la' => 'latin',
|
||||
'lt' => 'lithuanian',
|
||||
'lv' => 'latvian',
|
||||
'mk' => 'macedonian',
|
||||
'mn' => 'mongolian',
|
||||
'ne' => 'nepali',
|
||||
'nl' => 'dutch',
|
||||
'no' => 'norwegian',
|
||||
'pl' => 'polish',
|
||||
'ps' => 'pashto',
|
||||
'pt' => 'portuguese',
|
||||
'ro' => 'romanian',
|
||||
'ru' => 'russian',
|
||||
'sk' => 'slovak',
|
||||
'sl' => 'slovene',
|
||||
'so' => 'somali',
|
||||
'sq' => 'albanian',
|
||||
'sr' => 'serbian',
|
||||
'sv' => 'swedish',
|
||||
'sw' => 'swahili',
|
||||
'tl' => 'tagalog',
|
||||
'tr' => 'turkish',
|
||||
'uk' => 'ukrainian',
|
||||
'ur' => 'urdu',
|
||||
'uz' => 'uzbek',
|
||||
'vi' => 'vietnamese',
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the language name for the given 2-letter ISO 639-1 code.
|
||||
*
|
||||
* @param string $code Two-letter language code (e.g. "sv")
|
||||
*
|
||||
* @return string English language name like "swedish"
|
||||
*/
|
||||
|
||||
public static function code2ToName($code)
|
||||
{
|
||||
$lang = strtolower($code);
|
||||
if (!isset(self::$code2ToName[$code])) {
|
||||
return null;
|
||||
}
|
||||
return self::$code2ToName[$code];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user