Commit 2d11ff13 authored by Adrien Dorsaz's avatar Adrien Dorsaz

Merge branch 'dev' of github.com:ldleman/Leed

parents 7f2ea9ac 57462356
......@@ -124,46 +124,51 @@ AddType text/x-vcard vcf
</IfModule>
# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
# <IfModule filter_module>
# FilterDeclare COMPRESS
# There are two way to configure the filters, according to the Apache version.
# Apache >= 2.4
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
# FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
# FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
# Apache <= 2.2
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
# FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
# FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
# FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
# FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
# FilterChain COMPRESS
# FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
# </IfModule>
# There are two way to configure the filters, according to the Apache version.
<IfModule version.c>
<IfModule filter_module>
FilterDeclare COMPRESS
<IfVersion >= 2.4>
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$text/html'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$text/css'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$text/plain'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$text/xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$text/x-component'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/javascript'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/json'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/xhtml+xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/rss+xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/atom+xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/vnd.ms-fontobject'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$image/svg+xml'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$image/x-icon'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$application/x-font-ttf'"
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} ='$font/opentype'"
</IfVersion>
<IfVersion <= 2.2>
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
</IfVersion>
FilterChain COMPRESS
FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
</IfModule>
</IfModule>
<IfModule !mod_filter.c>
# Legacy versions of Apache
......
......@@ -17,7 +17,7 @@ class Event extends MysqlEntity{
'guid'=>'longstring',
'title'=>'string',
'creator'=>'string',
'content'=>'longstring',
'content'=>'extralongstring',
'description'=>'longstring',
'link'=>'longstring',
'unread'=>'integer',
......@@ -51,7 +51,7 @@ class Event extends MysqlEntity{
function getEventCountPerFolder(){
$events = array();
$results = $this->customQuery('SELECT COUNT('.MYSQL_PREFIX.$this->TABLE_NAME.'.id),'.MYSQL_PREFIX.'feed.folder FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.$this->TABLE_NAME.'.unread=1 GROUP BY '.MYSQL_PREFIX.'feed.folder');
$results = $this->customQuery('SELECT COUNT(`'.MYSQL_PREFIX.$this->TABLE_NAME.'`.`id`),`'.MYSQL_PREFIX.'feed`.`folder` FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'` INNER JOIN `'.MYSQL_PREFIX.'feed` ON (`'.MYSQL_PREFIX.'event`.`feed` = `'.MYSQL_PREFIX.'feed`.`id`) WHERE `'.MYSQL_PREFIX.$this->TABLE_NAME.'`.`unread`=1 GROUP BY `'.MYSQL_PREFIX.'feed`.`folder`');
while($item = mysql_fetch_array($results)){
$events[$item[1]] = $item[0];
}
......@@ -60,7 +60,7 @@ class Event extends MysqlEntity{
}
function getEventCountNotVerboseFeed(){
$results = $this->customQuery('SELECT COUNT(1) FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.$this->TABLE_NAME.'.unread=1 AND '.MYSQL_PREFIX.'feed.isverbose=0');
$results = $this->customQuery('SELECT COUNT(1) FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'` INNER JOIN `'.MYSQL_PREFIX.'feed` ON (`'.MYSQL_PREFIX.'event`.`feed` = `'.MYSQL_PREFIX.'feed`.`id`) WHERE `'.MYSQL_PREFIX.$this->TABLE_NAME.'`.`unread`=1 AND `'.MYSQL_PREFIX.'feed`.`isverbose`=0');
while($item = mysql_fetch_array($results)){
$nbitem = $item[0];
}
......@@ -71,7 +71,7 @@ class Event extends MysqlEntity{
function getEventsNotVerboseFeed($start=0,$limit=10000,$order,$columns='*'){
$eventManager = new Event();
$objects = array();
$results = $this->customQuery('SELECT '.$columns.' FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.isverbose = 0 ORDER BY '.$order.' LIMIT '.$start.','.$limit);
$results = $this->customQuery('SELECT '.$columns.' FROM `'.MYSQL_PREFIX.'event` INNER JOIN `'.MYSQL_PREFIX.'feed` ON (`'.MYSQL_PREFIX.'event`.`feed` = `'.MYSQL_PREFIX.'feed`.`id`) WHERE `'.MYSQL_PREFIX.'event`.`unread`=1 AND `'.MYSQL_PREFIX.'feed`.`isverbose` = 0 ORDER BY '.$order.' LIMIT '.$start.','.$limit);
if($results!=false){
while($item = mysql_fetch_array($results)){
$object = new Event();
......@@ -123,14 +123,20 @@ class Event extends MysqlEntity{
}
function getPubdateWithInstant($instant){
if (empty($this->pubdate)) return '';
$alpha = $instant - $this->pubdate;
if ($alpha < 86400 ){
$hour = floor($alpha/3600);
$alpha = ($hour!=0?$alpha-($hour*3600):$alpha);
$minuts = floor($alpha/60);
return 'il y a '.($hour!=0?$hour.'h et':'').' '.$minuts.'min';
if ($hour!=0) {
return _t('PUBDATE_WITHINSTANT_LOWERH24',array($hour,$minuts));
} else {
return _t('PUBDATE_WITHINSTANT_LOWERH1',array($minuts));
}
}else{
return 'le '.$this->getPubdate('d/m/Y à H:i:s');
$date=$this->getPubdate(_t('FORMAT_DATE_HOURS'));
return _t('PUBDATE_WITHINSTANT',array($date));
}
}
......
......@@ -8,7 +8,7 @@
class Feed extends MysqlEntity{
protected $id,$name,$url,$events=array(),$description,$website,$folder,$lastupdate,$isverbose;
protected $id,$name,$url,$events=array(),$description,$website,$folder,$lastupdate,$isverbose,$lastSyncInError;
protected $TABLE_NAME = 'feed';
protected $CLASS_NAME = 'Feed';
protected $object_fields =
......@@ -21,6 +21,7 @@ class Feed extends MysqlEntity{
'lastupdate'=>'string',
'folder'=>'integer',
'isverbose'=>'boolean',
'lastSyncInError'=>'boolean',
);
protected $object_fields_index =
......@@ -43,13 +44,14 @@ class Feed extends MysqlEntity{
function getInfos(){
$xml = @simplexml_load_file($this->url);
if($xml!=false){
$this->name = array_shift ($xml->xpath('channel/title'));
$this->description = array_shift ($xml->xpath('channel/description'));
$this->website = array_shift ($xml->xpath('channel/link'));
$n = $xml->xpath('channel/title'); $this->name = $n[0];
$d = $xml->xpath('channel/description'); $this->description = $d[0];
$w = $xml->xpath('channel/link'); $this->website = $w[0];
}
}
function getError() { return $this->error; }
function getLastSyncInError() { return $this->lastSyncInError; }
/*@TODO: fournir un extrait quand il 'y a pas de description. De même pour les médias.
@TODO: SimplePie remplace "é" par "&eacute;", il ne devrait pas le faire.
......@@ -77,8 +79,10 @@ class Feed extends MysqlEntity{
$feed->force_feed($forceFeed);
$feed->set_feed_url($this->url);
$feed->set_useragent('Mozilla/4.0 Leed (LightFeed Aggregator) '.VERSION_NAME.' by idleman http://projet.idleman.fr/leed');
$this->lastSyncInError = 0;
if (!$feed->init()) {
$this->error = $feed->error;
$this->lastSyncInError = 1;
$this->lastupdate = $_SERVER['REQUEST_TIME'];
$this->save();
return false;
......@@ -239,11 +243,14 @@ class Feed extends MysqlEntity{
function countUnreadEvents(){
$unreads = array();
$results = Feed::customQuery("SELECT COUNT(".MYSQL_PREFIX."event.id), ".MYSQL_PREFIX."event.feed FROM ".MYSQL_PREFIX."event WHERE ".MYSQL_PREFIX."event.unread = 1 GROUP BY ".MYSQL_PREFIX."event.feed") ;
$results = Feed::customQuery("SELECT COUNT(`".MYSQL_PREFIX."event`.`id`), `".MYSQL_PREFIX."event`.`feed` FROM `".MYSQL_PREFIX."event` WHERE `".MYSQL_PREFIX."event`.`unread` = 1 GROUP BY `".MYSQL_PREFIX."event`.`feed`") ;
if($results!=false){
$total = 0;
while($item = mysql_fetch_array($results)){
$unreads[$item[1]] = $item[0];
$total += $item[0];
}
$unreads['total'] = $total;
}
return $unreads;
}
......@@ -252,7 +259,7 @@ class Feed extends MysqlEntity{
$feedsFolderMap = array();
$feedsIdMap = array();
$results = Feed::customQuery("SELECT ".MYSQL_PREFIX."feed.name AS name, ".MYSQL_PREFIX."feed.id AS id, ".MYSQL_PREFIX."feed.url AS url, ".MYSQL_PREFIX."folder.id AS folder FROM ".MYSQL_PREFIX."feed INNER JOIN ".MYSQL_PREFIX."folder ON ( ".MYSQL_PREFIX."feed.folder = ".MYSQL_PREFIX."folder.id ) ORDER BY ".MYSQL_PREFIX."feed.name ;");
$results = Feed::customQuery("SELECT `".MYSQL_PREFIX."feed`.`name` AS name, `".MYSQL_PREFIX."feed`.`id` AS id, `".MYSQL_PREFIX."feed`.`url` AS url, `".MYSQL_PREFIX."folder`.`id` AS folder FROM `".MYSQL_PREFIX."feed` INNER JOIN `".MYSQL_PREFIX."folder` ON ( `".MYSQL_PREFIX."feed`.`folder` = `".MYSQL_PREFIX."folder`.`id` ) ORDER BY `".MYSQL_PREFIX."feed`.`name` ;");
if($results!=false){
while($item = mysql_fetch_array($results)){
$name = $item['name'];
......
......@@ -20,7 +20,7 @@ class Folder extends MysqlEntity{
);
function unreadCount(){
$results = $this->customQuery('SELECT COUNT('.MYSQL_PREFIX.'event.id) FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.folder = '.$this->getId());
$results = $this->customQuery('SELECT COUNT(`'.MYSQL_PREFIX.'event`.`id`) FROM `'.MYSQL_PREFIX.'event` INNER JOIN `'.MYSQL_PREFIX.'feed` ON (`'.MYSQL_PREFIX.'event`.`feed` = `'.MYSQL_PREFIX.'feed`.`id`) WHERE `'.MYSQL_PREFIX.'event`.`unread`=1 AND `'.MYSQL_PREFIX.'feed`.`folder` = '.$this->getId());
$number = mysql_fetch_array($results);
return $number[0];
}
......@@ -29,7 +29,7 @@ class Folder extends MysqlEntity{
function getEvents($start=0,$limit=10000,$order,$columns='*'){
$eventManager = new Event();
$objects = array();
$results = $this->customQuery('SELECT '.$columns.' FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.folder = '.$this->getId().' ORDER BY '.$order.' LIMIT '.$start.','.$limit);
$results = $this->customQuery('SELECT '.$columns.' FROM `'.MYSQL_PREFIX.'event` INNER JOIN `'.MYSQL_PREFIX.'feed` ON (`'.MYSQL_PREFIX.'event`.`feed` = `'.MYSQL_PREFIX.'feed`.`id`) WHERE `'.MYSQL_PREFIX.'event`.`unread`=1 AND `'.MYSQL_PREFIX.'feed`.`folder` = '.$this->getId().' ORDER BY '.$order.' LIMIT '.$start.','.$limit);
if($results!=false){
while($item = mysql_fetch_array($results)){
$object = new Event();
......
......@@ -44,7 +44,8 @@ class MysqlConnector
public function connect(){
$this->connection = mysql_connect(MYSQL_HOST,MYSQL_LOGIN,MYSQL_MDP);
// @TODO use PDO or mysqli
$this->connection = @mysql_connect(MYSQL_HOST,MYSQL_LOGIN,MYSQL_MDP);
mysql_query('SET NAMES utf8');
mysql_select_db(MYSQL_BDD,$this->connection);
}
......
......@@ -28,6 +28,9 @@ class MysqlEntity
case 'longstring':
$return = 'TEXT CHARACTER SET utf8 COLLATE utf8_general_ci';
break;
case 'extralongstring':
$return = 'MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci';
break;
case 'key':
$return = 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY';
break;
......@@ -92,7 +95,7 @@ class MysqlEntity
*/
public function destroy($debug=false)
{
$query = 'DROP TABLE IF EXISTS '.MYSQL_PREFIX.$this->TABLE_NAME.';';
$query = 'DROP TABLE IF EXISTS `'.MYSQL_PREFIX.$this->TABLE_NAME.'`;';
if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
$myQuery = $this->customQuery($query);
}
......@@ -106,7 +109,7 @@ class MysqlEntity
*/
public function truncate($debug=false)
{
$query = 'TRUNCATE TABLE '.MYSQL_PREFIX.$this->TABLE_NAME.';';
$query = 'TRUNCATE TABLE `'.MYSQL_PREFIX.$this->TABLE_NAME.'`;';
if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
$myQuery = $this->customQuery($query);
}
......@@ -354,7 +357,7 @@ class MysqlEntity
$whereClause .= '`'.$column.'`="'.$this->secure($value, $column).'"';
}
}
$query = 'SELECT COUNT(1) FROM '.MYSQL_PREFIX.$this->TABLE_NAME.$whereClause;
$query = 'SELECT COUNT(1) FROM `'.MYSQL_PREFIX.$this->TABLE_NAME.'`'.$whereClause;
if($this->debug)echo '<hr>'.$this->CLASS_NAME.' ('.__METHOD__ .') : Requete --> '.$query.'<br>'.mysql_error();
$myQuery = $this->customQuery($query);
$number = mysql_fetch_array($myQuery);
......@@ -437,7 +440,7 @@ class MysqlEntity
*/
public function tableExists() {
$table = MYSQL_PREFIX.$this->TABLE_NAME;
$table = '`'.MYSQL_PREFIX.$this->TABLE_NAME.'';
$result = $this->customQuery("SHOW TABLES LIKE '$table'");
$assoc = mysql_fetch_assoc($result);
return false===$assoc ? false : true;
......
......@@ -9,27 +9,27 @@
class Plugin{
const FOLDER = '/plugins';
protected $name,$author,$mail,$link,$licence,$path,$description,$version,$state,$type;
protected $name,$author,$address,$link,$licence,$path,$description,$version,$state,$type;
function __construct(){
}
public static function includeAll(){
global $i18n, $i18n_js;
global $i18n, $i18n_js, $language, $theme;
$pluginFiles = Plugin::getFiles(true);
if(is_array($pluginFiles)) {
foreach($pluginFiles as $pluginFile) {
// Chargement du fichier de Langue du plugin
$i18n->append(new Translation(dirname($pluginFile)));
$i18n->append(new Translation(dirname($pluginFile),$language));
// Inclusion du coeur de plugin
include $pluginFile;
// Gestion des css du plugin en fonction du thème actif
$cssTheme = glob(dirname($pluginFile).'/*/'.DEFAULT_THEME.'.css');
$cssTheme = glob(dirname($pluginFile).'/*/'.$theme.'.css');
$cssDefault = glob(dirname($pluginFile).'/*/default.css');
if(isset($cssTheme[0])){
$GLOBALS['hooks']['css_files'][] = Functions::relativePath(str_replace('\\','/',dirname(__FILE__)),str_replace('\\','/',$cssTheme[0]));
}else if(isset($cssDefault[0])){
$GLOBALS['hooks']['css_files'][] = Functions::relativePath(str_replace('\\','/',dirname(__FILE__)),str_replace('\\','/',$cssDefault[0]));
$GLOBALS['hooks']['css_files'][] = Functions::relativePath(str_replace('\\','/',dirname(__FILE__)),str_replace('\\','/',$cssDefault[0]));
}
}
}
......@@ -69,11 +69,17 @@ class Plugin{
$plugin = new Plugin();
$fileLines = file_get_contents($pluginFile);
if(preg_match("#@author\s(.+)\s\<#", $fileLines, $match))
$plugin->setAuthor(trim($match[1]));
if(preg_match_all("#@author\s(.+)\s\<(.*)\>#", $fileLines, $matches)) {
foreach($matches[1] as $match) {
$authors[] = trim($match);
}
$plugin->setAuthor($authors);
if(preg_match("#@author\s(.+)\s\<([a-z\@\.A-Z\s\-]+)\>#", $fileLines, $match))
$plugin->setMail(strtolower($match[2]));
foreach($matches[2] as $match) {
$address[] = strtolower($match);
}
$plugin->setAddress($address);
}
if(preg_match("#@name\s(.+)[\r\n]#", $fileLines, $match))
$plugin->setName($match[1]);
......@@ -142,15 +148,15 @@ class Plugin{
return $return;
}
public static function addLink($rel, $link) {
$GLOBALS['hooks']['head_link'][] = array("rel"=>$rel, "link"=>$link);
public static function addLink($rel, $link, $type='', $title='') {
$GLOBALS['hooks']['head_link'][] = array("rel"=>$rel, "link"=>$link, "type"=>$type, "title"=>$title);
}
public static function callLink(){
$return='';
if(isset($GLOBALS['hooks']['head_link'])) {
foreach($GLOBALS['hooks']['head_link'] as $head_link) {
$return .='<link rel="'.$head_link['rel'].'" href="'.$head_link['link'].'" />'."\n";
$return .='<link rel="'.$head_link['rel'].'" href="'.$head_link['link'].'" type="'.$head_link['type'].'" title="'.$head_link['title'].'" />'."\n";
}
}
return $return;
......@@ -258,9 +264,13 @@ class Plugin{
static function sortPlugin($a, $b){
if ($a->getName() == $b->getName())
return 0;
return ($a->getName() < $b->getName()) ? -1 : 1;
if ($a->getState() == $b->getState())
if ($a->getName() == $b->getName())
return 0;
else
return $a->getName() < $b->getName() ? -1 : 1;
else
return $a->getState() < $b->getState() ? -1 : 1;
}
......@@ -281,12 +291,12 @@ class Plugin{
return $this->author;
}
function getMail(){
return $this->mail;
function getAddress(){
return $this->address;
}
function setMail($mail){
$this->mail = $mail;
function setAddress($address){
$this->address = $address;
}
function getLicence(){
......
This diff is collapsed.
......@@ -663,7 +663,7 @@ class RainTPL{
if( in_array( "a", self::$path_replace_list ) ){
$exp = array_merge( $exp , array( '/<a(.*?)href=(?:")(http\:\/\/|https\:\/\/|javascript:|mailto:)([^"]+?)(?:")/i', '/<a(.*?)href="(.*?)"/', '/<a(.*?)href=(?:\@)([^"]+?)(?:\@)/i' ) );
$sub = array_merge( $sub , array( '<a$1href=@$2$3@', '<a$1href="' . self::$base_url . '$2"', '<a$1href="$2"' ) );
$sub = array_merge( $sub , array( '<a$1href="$2$3"', '<a$1href="' . self::$base_url . '$2"', '<a$1href="$2"' ) );
}
if( in_array( "input", self::$path_replace_list ) ){
......@@ -1068,4 +1068,4 @@ class RainTpl_SyntaxException extends RainTpl_Exception{
}
}
// -- end
\ No newline at end of file
// -- end
......@@ -47,18 +47,18 @@ class Update{
$jsonFiles = Update::getUpdateFile();
$alreadyPassed = array();
$notPassed = array();
if ($jsonFiles==''){
$jsonFiles[0] = array();
}
if ($jsonFiles=='') $jsonFiles[0] = array();
foreach($files as $file){
if(in_array(basename($file), $jsonFiles[0])){
$alreadyPassed [] = basename($file);
}else{
$notPassed [] = basename($file);
$found = false;
foreach($jsonFiles as $jsonfile){
if (isset($jsonfile[0])) {
if(in_array(basename($file), $jsonfile)) $found = true;
}
}
if (!$found) $notPassed [] = basename($file);
}
return $notPassed;
}
......
......@@ -46,9 +46,13 @@ class User extends MysqlEntity{
$result = false;
$userManager = new User();
$users = $userManager->populate('id');
$phpAuth = strtolower(@$_SERVER['PHP_AUTH_USER']);
if (empty($auth)) $auth = @$_COOKIE['leedStaySignedIn'];
foreach($users as $user){
if($user->getToken()==$auth) $result = $user;
if ($user->getToken()==$auth || strtolower($user->login)===$phpAuth){
$result = $user;
break;
}
}
return $result;
}
......
This diff is collapsed.
......@@ -7,27 +7,28 @@
*/
include ('common.php');
Plugin::callHook("index_pre_treatment", array(&$_));
$view = "article";
//recuperation de tous les flux
$allFeeds = $feedManager->getFeedsPerFolder();
$tpl->assign('allFeeds',$allFeeds);
$tpl->assign('scrollpage',$_['scroll']);
// récupération des variables pour l'affichage
$articleDisplayContent = $configurationManager->get('articleDisplayContent');
$articleView = $configurationManager->get('articleView');
$articlePerPages = $configurationManager->get('articlePerPages');
$articleDisplayLink = $configurationManager->get('articleDisplayLink');
$articleDisplayDate = $configurationManager->get('articleDisplayDate');
$articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
$articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
$articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
$articleDisplayMode = $configurationManager->get('articleDisplayMode');
$optionFeedIsVerbose = $configurationManager->get('optionFeedIsVerbose');
$tpl->assign('articleView',$articleView);
$tpl->assign('articleDisplayLink',$articleDisplayLink);
$tpl->assign('articleDisplayDate',$articleDisplayDate);
$tpl->assign('articleDisplayAuthor',$articleDisplayAuthor);
$tpl->assign('articleDisplayContent',$articleDisplayContent);
$tpl->assign('articleDisplayDate',$articleDisplayDate);
$tpl->assign('articleDisplayLink',$articleDisplayLink);
$tpl->assign('articleDisplayMode',$articleDisplayMode);
$hightlighted = $_['hightlighted'];
......@@ -35,37 +36,31 @@ $tpl->assign('hightlighted',$hightlighted);
$tpl->assign('time',$_SERVER['REQUEST_TIME']);
$target = MYSQL_PREFIX.'event.title,'.MYSQL_PREFIX.'event.unread,'.MYSQL_PREFIX.'event.favorite,'.MYSQL_PREFIX.'event.feed,';
if($articleDisplayContent && $articleView=='partial') $target .= MYSQL_PREFIX.'event.description,';
if($articleDisplayContent && $articleView!='partial') $target .= MYSQL_PREFIX.'event.content,';
if($articleDisplayLink) $target .= MYSQL_PREFIX.'event.link,';
if($articleDisplayDate) $target .= MYSQL_PREFIX.'event.pubdate,';
if($articleDisplayAuthor) $target .= MYSQL_PREFIX.'event.creator,';
$target .= MYSQL_PREFIX.'event.id';
$target = '`'.MYSQL_PREFIX.'event`.`title`,`'.MYSQL_PREFIX.'event`.`unread`,`'.MYSQL_PREFIX.'event`.`favorite`,`'.MYSQL_PREFIX.'event`.`feed`,';
if($articleDisplayMode=='summary') $target .= '`'.MYSQL_PREFIX.'event`.`description`,';
if($articleDisplayMode=='content') $target .= '`'.MYSQL_PREFIX.'event`.`content`,';
if($articleDisplayLink) $target .= '`'.MYSQL_PREFIX.'event`.`link`,';
if($articleDisplayDate) $target .= '`'.MYSQL_PREFIX.'event`.`pubdate`,';
if($articleDisplayAuthor) $target .= '`'.MYSQL_PREFIX.'event`.`creator`,';
$target .= '`'.MYSQL_PREFIX.'event`.`id`';
$startArticle = ($_['scroll']*$articlePerPages)-$_['nblus'];
if ($startArticle < 0) $startArticle=0;
$action = $_['action'];
$tpl->assign('action',$action);
switch($action){
/* AFFICHAGE DES EVENEMENTS D'UN FLUX EN PARTICULIER */
case 'selectedFeed':
$currentFeed = $feedManager->getById($_['feed']);
$allowedOrder = array('date'=>'pubdate DESC','older'=>'pubdate','unread'=>'unread DESC,pubdate DESC');
$order = (isset($_['order'])?$allowedOrder[$_['order']]:$allowedOrder['date']);
$order = (isset($_['order'])?$allowedOrder[$_['order']]:$allowedOrder['unread']);
$events = $currentFeed->getEvents($startArticle,$articlePerPages,$order,$target);
break;
/* AFFICHAGE DES EVENEMENTS D'UN FLUX EN PARTICULIER en mode non lus */
case 'selectedFeedNonLu':
$currentFeed = $feedManager->getById($_['feed']);
$filter = array('unread'=>1, 'feed'=>$currentFeed->getId());
$order = 'pubdate DESC';
$events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$startArticle.','.$articlePerPages);
break;
/* AFFICHAGE DES EVENEMENTS D'UN DOSSIER EN PARTICULIER */
case 'selectedFolder':
$currentFolder = $folderManager->getById($_['folder']);
if($articleDisplayFolderSort) {$order = MYSQL_PREFIX.'event.pubdate desc';} else {$order = MYSQL_PREFIX.'event.pubdate asc';}
if($articleDisplayFolderSort) {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` desc';} else {$order = '`'.MYSQL_PREFIX.'event`.`pubdate` asc';}
$events = $currentFolder->getEvents($startArticle,$articlePerPages,$order,$target);
break;
/* AFFICHAGE DES EVENEMENTS FAVORIS */
......
......@@ -7,7 +7,7 @@
*/
define('VERSION_NUMBER_CODE','1.6.1');
define('VERSION_NAME_CODE','Stable');
define('VERSION_NAME_CODE','dev');
/* ----------MAJ de la version du constant.php--------------------- */
if (is_writable('constant.php')) {
......@@ -37,22 +37,6 @@ session_start();
mb_internal_encoding('UTF-8'); // UTF8 pour fonctions mb_*
$start=microtime(true);
require_once('constant.php');
//@todo requis pour la MAJ 1.5 vers 1.6 mais pourra être supprimé.
if (!defined('LANGUAGE')) {
preg_match('#define\(\'LANGAGE\',\'([A-Za-z0-9.]+)\'\);?#',$content,$matches_language);
if (isset($matches_language[1]) && isset($matches_language[1])!='') {
// pour ceux qui viennent de la branche de dev avant update en LANGUAGE.
$content = preg_replace('#define\(\'LANGAGE\',\'([A-Za-z0-9.]+)\'\);?#','define(\'LANGUAGE\',\''.$matches_language[1].'\');', $content);
file_put_contents('constant.php', $content);
define('LANGUAGE', $matches_language[1]); // ancienne constante encore utilisée
} else {
// pour ceux qui viennent de la v1.5. la variable n'existait pas
$content = preg_replace('#\?\>#',"//Langue utilisée\ndefine('LANGUAGE','fr');\n?>", $content);
file_put_contents('constant.php', $content);
define('LANGUAGE', 'fr');
}
}
// fin MAJ 1.5 vers 1.6
require_once('RainTPL.php');
require_once('i18n.php');
class_exists('Plugin') or require_once('Plugin.class.php');
......@@ -88,14 +72,27 @@ $folderManager = new Folder();
$configurationManager = new Configuration();
$conf = $configurationManager->getAll();
$language = $configurationManager->get('language');
//@todo requis pour la MAJ mais pourra être supprimé.
if (empty($language)) {
// On tente de récupérer la valeur issue de 'constant.php'
if (defined('LANGUAGE')) $language = LANGUAGE;
elseif (defined('LANGAGE')) $language = LANGAGE; // ancien bug de nommage
else $language = Translation::DEFAULT_LANGUAGE;
$configurationManager->put('language', $language);
}
// Faut-il supprimer la variable /langu?age/ de 'constant.php'?
$theme = $configurationManager->get('theme');
//Instanciation du template
$tpl = new RainTPL();
//Definition des dossiers de template
raintpl::configure("base_url", null );
raintpl::configure("tpl_dir", './templates/'.DEFAULT_THEME.'/' );
raintpl::configure("tpl_dir", './templates/'.$theme.'/' );
raintpl::configure("cache_dir", "./cache/tmp/" );
i18n_init(LANGUAGE);
i18n_init($language, dirname(__FILE__).'/templates/'.$theme.'/');
if ($resultUpdate) die (_t('LEED_UPDATE_MESSAGE'));
$view = '';
......
......@@ -7,7 +7,7 @@
Contributors: Sbgodin (http://sbgodin.fr)
Simounet (contact@simounet.net)
Alef-Burzmali (thomas.fargeix@burzmali.com)
Cobalt74 (cobalt74@gmail.com)
Cobalt74 (http://www.cobestran.com)
Site: http://blog.idleman.fr
Twitter: none
Location: Nowhere
......
......@@ -77,6 +77,8 @@ class Translation {
$translations = array();
} else {
$translations = json_decode($content, true);
if (!empty($content) && empty($translations))
error_log("Error while loading '$fileName'");
}
return $translations;
}
......@@ -110,10 +112,13 @@ class Translation {
}
// Initialise le singleton, avec les langues possibles
function i18n_init($languages){
function i18n_init($languages, $location){
global $i18n,$i18n_js;
if (!isset($i18n)) {
// Charge d'abord les traductions de base
$i18n = new Translation(dirname(__FILE__), $languages);
// Charge ensuite la traduction demandée (celle du thème courant)
$i18n->append(new Translation($location, $languages));
$i18n_js = $i18n->getJson();
}
return $i18n->language;
......
......@@ -25,39 +25,39 @@ $tpl->assign('allFeeds',$allFeeds);
$tpl->assign('allFeedsPerFolder',$allFeeds['folderMap']);
//recuperation de tous les event nons lu par dossiers
$tpl->assign('allEvents',$eventManager->getEventCountPerFolder());
//utilisé pour récupérer le statut d'un feed dans le template (en erreur ou ok)
$feedState = new Feed();
$tpl->assign('feedState',$feedState);
$articleDisplayContent = $configurationManager->get('articleDisplayContent');
$articleView = $configurationManager->get('articleView');
$articlePerPages = $configurationManager->get('articlePerPages');
$articleDisplayLink = $configurationManager->get('articleDisplayLink');
$articleDisplayDate = $configurationManager->get('articleDisplayDate');
$articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
$articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
$articleDisplayDate = $configurationManager->get('articleDisplayDate');
$articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
$articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
$articleDisplayLink = $configurationManager->get('articleDisplayLink');
$articleDisplayMode = $configurationManager->get('articleDisplayMode');
$articlePerPages = $configurationManager->get('articlePerPages');
$displayOnlyUnreadFeedFolder = $configurationManager->get('displayOnlyUnreadFeedFolder');
if (!isset($displayOnlyUnreadFeedFolder)) $displayOnlyUnreadFeedFolder=false;
($displayOnlyUnreadFeedFolder=='true')?$displayOnlyUnreadFeedFolder_reverse='false':$displayOnlyUnreadFeedFolder_reverse='true';
$optionFeedIsVerbose = $configurationManager->get('optionFeedIsVerbose');