source: extensions/piclens/generate_rss.php @ 3649

Last change on this file since 3649 was 3649, checked in by tiico, 15 years ago

Personnalize the icon in the cooliris feed (on the wall)
Unstall the plugin will suppress the configuration on the database

File size: 25.9 KB
Line 
1<?php
2/*
3 * Plugin Name: CoolIris-Piclens
4 * File :  generate_rss.php 
5 */
6
7$debug = false;
8
9if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
10
11include (PICLENS_INC_PATH.'config_extendeddesc.inc.php');       // Parametres pour extended description.
12
13// recuperation du parametre pour le mode no recursif (forçage de la non recursivite)
14if (isset($_GET['norecurs'])) 
15{
16        $obj->my_config['piclens_recursive'] = false;
17}
18
19
20// extensions video
21$py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo");
22$video_ext_piclens = array("flv");
23
24// Vérification présence et activation plugin SecureImages ET si actif, vérification d'activation de compatibilité
25$plugins_SecureImage_only = (get_db_plugins('active','secureImages') ? true : false );
26$plugins_SecureImage = ($plugins_SecureImage_only && ($obj->my_config['piclens_secureimage']) ? true : false );
27// Verification presence et activation plugin ExtendedDescription
28$plugins_ExtendedDesc = (get_db_plugins('active','ExtendedDescription') && ($obj->my_config['piclens_extendeddesc']) ? true : false );
29
30
31// Vérification d'activation du plugin (page administration) OU activation de piclensWall
32if ($obj->my_config['piclens_active'] OR $obj->my_config['piclens_wall'] OR (!$obj->my_config['piclens_wall'] AND get_db_plugins('active','PWG_Stuffs')))
33{
34        //-------------------------------------------------------------- initialization
35
36        // Mode des miniatures et des images normales dans piclens (avec et sans plugin secureimage)
37        $thumb_secure = array('', '&amp;thumb=1', '');  // correspondant a 1-->'miniature' et 2-->'normal'
38        $normal_secure = array('', '&amp;thumb=1', '', '&amp;highdef=1');       // correspondant a 1-->'miniature' et 2-->'normal' et 3 --> High
39        $order_list = array('', $conf['order_by_inside_category'], 'ORDER BY date_creation', 'ORDER BY date_available', 'ORDER BY average_rate', 'ORDER BY hit', 'ORDER BY file', 'ORDER BY id', 'ORDER BY RAND()', 'ORDER BY category_id', 'ORDER BY category_id, rank ');     
40        $order_sort = array('', '', ' ASC', ' DESC');
41
42        // Extensions a prendre en compte
43        $tn_ext_is_null = false;
44        $type_ext = $obj->my_config['included_file_types'];
45        foreach($type_ext as $i => $value)
46        {
47                if ($value == '!NULL!') $tn_ext_is_null = true;
48                $type_ext[$i] = '"'.($value == '!NULL!' ? 'NULL' : $value).'"';
49        }
50
51        // Categories a prendre en compte pour le mur
52        $piclenswall_cat = (isset($obj->my_config['piclens_wall_categories']) ? $obj->my_config['piclens_wall_categories'] : array());
53
54        // Seulement sur une page type 'categorie'
55        if (isset($page['section']))
56        {
57                $cat = array();
58                $pictures = array();
59
60                $forbidden = get_sql_condition_FandF(
61                          array
62                                (
63                                  'forbidden_categories' => 'category_id',
64                                  'visible_categories' => 'category_id',
65                                  'visible_images' => 'id'
66                                ),
67                          'AND'
68                  );
69
70                // Images recentes
71                if (($page['section']) == 'recent_pics')
72                {
73                    if ( !isset($page['super_order_by']) )
74                    {
75                      $conf['order_by'] = str_replace(
76                        'ORDER BY ',
77                        'ORDER BY date_available DESC,',
78                        $conf['order_by']
79                        );
80                    }                   
81                        // $cat need to bo not null...
82                        array_push($cat, "1");
83
84                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
85                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
86                                          img.level '
87                                        .' FROM ' . IMAGES_TABLE.' AS img'
88                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
89                                        .' WHERE
90                                                img.date_available >= SUBDATE(
91                                                CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY) '
92                                                .$forbidden
93                                                .' '.$conf['order_by'].';';
94                }
95                // Plus vues
96                elseif ($page['section'] == 'recent_cats')
97                {
98                        // $cat need to bo not null...
99                        array_push($cat, "1");
100
101                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
102                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
103                                          img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
104                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
105                                        .' FROM ' . IMAGES_TABLE.' AS img'
106                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
107                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
108                                        .' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON cat.id = cat_id and user_id = '.$user['id']
109                                        .' WHERE date_last >= SUBDATE(
110                                                CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
111                                                )
112                                                '.get_sql_condition_FandF
113                                                        (
114                                                                array('visible_categories' => 'id',),
115                                                        'AND'
116                                                        ).'
117                                                ;';
118                }
119               
120                // Plus vues
121                elseif ($page['section'] == 'most_visited')
122                {
123                        // $cat need to bo not null...
124                        array_push($cat, "1");
125                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
126                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
127                                          img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
128                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
129                                        .' FROM ' . IMAGES_TABLE.' AS img'
130                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
131                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
132                                        .' WHERE img.hit > 0 '
133                                    .$forbidden
134                                        .' ORDER BY hit DESC, file ASC'
135                                        .' LIMIT 0, '.$conf['top_number'].';';
136               
137                }
138                // mieux notees
139                elseif ($page['section'] == 'best_rated')
140                {
141                        // $cat need to bo not null...
142                        array_push($cat, "1");
143
144                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
145                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
146                                          img.level '
147                                        .' FROM ' . IMAGES_TABLE.' AS img'
148                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
149                                        .' WHERE img.average_rate IS NOT NULL '
150                                        .$forbidden
151                                        .' ORDER BY average_rate DESC, id ASC'
152                                        .' LIMIT 0, '.$conf['top_number'].';';
153                }
154                elseif ($page['section'] == 'favorites')
155                {
156                        check_user_favorites();
157                        // $cat need to bo not null...
158                        array_push($cat, "1");
159
160                        $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
161                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
162                                          img.level,  '
163                                        .' FROM '.FAVORITES_TABLE.' AS fav '
164                                        .' INNER JOIN '.IMAGES_TABLE.' AS img ON fav.image_id = img.id'
165                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
166                                        .' WHERE user_id = '.$user['id']
167                                        .' '.get_sql_condition_FandF
168                                                (
169                                                        array('visible_images' => 'id'),
170                                                        'AND'
171                                                )
172                                        .' '.$conf['order_by'].';';
173                }
174
175                // Gestion des tags
176                elseif (($page['section']) == 'tags')
177                {
178//                      $row = get_image_ids_for_tags($page['tags_id']);
179                        // $cat need to bo not null...
180                        array_push($cat, "1");
181                        $query = 'SELECT DISTINCT(tag.image_id) , img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
182                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
183                                          img.level , ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
184                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
185                                        .' FROM '.IMAGE_TAG_TABLE.' AS tag '."\n"
186                                        .' INNER JOIN '.IMAGES_TABLE.' AS img ON tag.image_id = img.id'
187                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
188                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
189                                        .' WHERE tag.tag_id IN ('.implode(',', $page['tag_ids']).') '
190                                    .$forbidden
191                                        .' '.$conf['order_by'].';';
192                }
193               
194               
195                elseif (($page['section']) == 'categories')
196                {
197                        // Accueil
198                        if(empty($page['category'])) 
199                        {
200                                // Page accueil
201                                // Vérification d'activation du plugin (page administration)
202                                // ou flux pour piclenswall et configuration specifique
203                                if ($obj->my_config['piclens_gallerie_active'] || $piclenswallfeed)
204                                {
205                                        // Categories de premier niveau
206                                        $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE
207                                        .' WHERE id_uppercat is NULL';
208                                       
209                                        $result = pwg_query($query);
210
211                                        while ($row = mysql_fetch_assoc($result))
212                                        {
213                                                if (!(in_array($row['id'], explode(',', $user['forbidden_categories']))))
214                                                {
215                                                                        array_push($cat, $row['id']);
216                                                               
217                                                }
218                                        }
219                                        // Type = avec recursiite
220                                        // Si parametrage specifique pour le mur 3D,  recursivite sur les categories
221                                        if (($piclenswallfeed) || (( $obj->my_config['piclens_gallerie_type'])-1))
222                                        {
223                                                // recuperation des sous-categories (tous niveaux) de la categorie en cours.
224                                                $subcat= get_subcat_ids($cat);
225                       
226                                                // Verification droits des sous-categories
227                                                foreach($subcat as $sscat)
228                                                {
229                                                        if (!(in_array($sscat, explode(',', $user['forbidden_categories']))))
230                                                                        array_push($cat, $sscat);
231                                                }
232                                        }
233
234                                        // selection uniquement des categories a afficher (si flux pour le mur ET parametre mur = specifique)
235                                        if ($piclenswallfeed)
236                                        {
237                                                foreach($cat as $i => $wcat)
238                                                {
239                                                        if (!in_array($wcat, $piclenswall_cat))
240                                                                unset($cat[$i]);
241                                                }
242                                        }
243
244                                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
245                                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
246                                                          img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
247                                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
248                                        .' FROM ' . IMAGES_TABLE.' AS img'
249                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
250                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
251                                        .' WHERE ic.category_id IN ('.implode(',', $cat).')'
252                                        .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
253                                        .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
254                                        // Verif droits (niveaux) de l'utilisateur sur les images
255                                        .' AND img.level <='.$user['level'].' '
256                                        // Choix du critere de tri d'affichage
257                                        .$order_list[ $obj->my_config['piclens_order'] ]
258                                        .$order_sort[ $obj->my_config['piclens_sort'] ];
259                                       
260                                       
261                                }
262                        }
263                       
264                        // Page category
265                        elseif (isset($page['category']))
266                        {
267                                check_restrictions($page['category']['id']);
268               
269                                // Flux pour le mur 3D et mur en mode "specifique"
270                                if ($piclenswallfeed)
271                                {
272                                        $selectionID = $page['category']['id'];
273                                        //  categorie parametre pour etre affichee dans le mur
274                                        if (in_array($selectionID, $piclenswall_cat))
275                                                array_push($cat, $selectionID);
276
277                                        // recuperation des sous-categories (tous niveaux) de la categorie en cours.
278                                        $subcat= get_subcat_ids(array($selectionID));
279
280                                        // Verification ajout des sous-categories qui peuvent être affichees (parametrees dans mur 3D) et des drois des sous categories
281                                        foreach($subcat as $sscat)
282                                        {
283                                                if ((in_array($sscat, $piclenswall_cat)) && (!(in_array($sscat, explode(',', $user['forbidden_categories'])))))
284                                                        array_push($cat, $sscat);
285                                        }
286
287                                }
288                                // Piclens (et mur 3D avec meme parametrage que piclens) : paramétrage "commun"
289                                else
290                                {               
291                                        //  recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire)
292                                        $selectionID = $page['category']['id'];
293
294                                        array_push($cat, $selectionID);
295
296                                        // Si recursivite activee
297                                        if ($obj->my_config['piclens_recursive'])
298                                        {
299                                                // recuperation des sous-categories (tous niveaux) de la categorie en cours.
300                                                $subcat= get_subcat_ids(array($selectionID));
301
302                                                // Verification droits des sous-categories
303                                                foreach($subcat as $sscat)
304                                                {
305                                                        if (!(in_array($sscat, explode(',', $user['forbidden_categories']))))
306                                                                array_push($cat, $sscat);
307                                                }
308                                       
309                                        }
310                                }
311                                       
312                                $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
313                                                  img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
314                                                  img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
315                                                  cat.visible, cat.uppercats, cat.permalink, cat.dir '
316                                .' FROM ' . IMAGES_TABLE.' AS img'
317                                .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
318                                .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
319                                .' WHERE ic.category_id IN ('.implode(',', $cat).')'
320                                .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
321                                .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
322                                // Verif droits (niveaux) de l'utilisateur sur les images
323                                .' AND img.level <='.$user['level'].' '
324                                // Choix du critere de tri d'affichage
325                                .$order_list[ $obj->my_config['piclens_order_cat'] ]
326                                .$order_sort[ $obj->my_config['piclens_sort_cat'] ];
327
328                                }
329                }
330                       
331                if ($debug)     echo $query;
332               
333                        // Si au moins une image récupérée (une catégorie ou une image présente)
334                if (count($cat)!=0)
335                {
336                        $result = pwg_query($query);
337                       
338                        while ($row = mysql_fetch_assoc($result))
339                        {
340                                // Plugin Extended Description present et active
341                                // suppression des categories et images pour lesquelles un <!--hidden--> est present
342                                if (!$plugins_ExtendedDesc
343                                        OR ($plugins_ExtendedDesc 
344                                                && !(substr_count($row['name'],  $piclens_extdesc_hidden)) 
345                                                && ((isset($row['catname']) ? !(substr_count($row['catname'],  $piclens_extdesc_hidden)) : true))
346                                                ))
347                                {
348                                        // Suppression des doublons (même path)
349                                        if ($obj->my_config['piclens_exclude_double'])
350                                        {
351                                                $double = false;
352                                                foreach ($pictures as $key => $values)
353                                                        // même path
354                                                        if ($row['path'] == $values['path'])
355                                                                $double=true;
356
357                                                // pas de double trouvé
358                                                if (!$double)
359                                                        array_push($pictures, $row);
360                                        }
361                                        else
362                                                array_push($pictures, $row);
363                                }
364                        }
365                }
366                // Fin requetes recherches photos
367
368
369                // Creation du fichier xml (flux rss)
370                // It's a rss file
371                header("Content-Type: application/xml; charset=UTF-8");
372                echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
373                echo "\n";
374                echo '<rss version="2.0" '."\n"
375                         .'xmlns:media="http://search.yahoo.com/mrss/" '."\n"
376                         .'xmlns:atom="http://www.w3.org/2005/Atom">';
377                echo "\n";
378                echo '<channel>';
379                echo "\n";
380
381       
382       
383                //      <!--    <title>test Page</title> -->
384                echo '<link>'.$obj->root_site_piclens.'</link>';
385                echo "\n";
386                echo '<description>Flux RSS pour cooliris</description>';
387                echo "\n";
388                echo '<language>fr</language>';
389                echo "\n";
390
391                // Version du plugin Piclens
392                $db_plugins = get_db_plugins('', 'piclens'); 
393                if (!empty($db_plugins)) 
394                        $piclens_version = $db_plugins[0]['version']; 
395                else
396                        $piclens_version = 'N/A'; 
397
398                echo '<generator>Piwigo Cooliris Plugin v.'.$piclens_version.'</generator>';
399                echo "\n";
400
401                // Icone de la gallerie dans le flux RSS
402                echo "\n";
403                echo '<atom:icon>'
404                .(strlen($obj->my_config['piclens_rss_icon'])
405                                    ? $obj->my_config['piclens_rss_icon']
406                                    : $obj->root_site_piclens.'template-common/favicon.ico')
407                .'</atom:icon>';
408                echo "\n";
409
410
411                // Pour chacune des images, preparation du flux xml
412                foreach ($pictures as $row)
413                {
414                        // Mode de l'image parametre
415                        $piclens_normal = $obj->my_config['piclens_normal'];
416
417                        // si parametrage high et high absente ou utilisateur non habilite, affichage version normale
418                        if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high']))
419                                $piclens_normal = 2; // Normal uniquement pour l'image en cours
420
421                        // Get thumbnail url
422                        if ($plugins_SecureImage)       // SecureImage installe et actif
423                        {
424                                $link_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'];
425
426                                $thumbnail_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']
427                                .$thumb_secure[$obj->my_config['piclens_thumb'] ];
428                                $content_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']
429                                .$normal_secure[$piclens_normal ];
430                        }
431                        else    // SecureImage non installe ou non actif
432                        {
433                                $link_url = $obj->root_site_piclens.$row['path'];
434                               
435                                if ( ($obj->my_config['piclens_thumb']) == 2)   // Normal
436                                        $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
437                                else
438                                {
439                                        if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
440                                        {
441                                                $path=get_thumbnail_location($row);
442                                                $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
443                                        }
444                                        else    // Plugin secureimage desactive
445                                        {
446                                                $thumbnail_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));
447                                        }
448                                }       
449
450                                switch ($piclens_normal)
451                                {
452                                        case 1 : // miniature
453                                                if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
454                                                {
455                                                        $path=get_thumbnail_location($row);
456                                                        $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
457                                                }
458                                                else    // Plugin secureimage desactive
459                                                {
460                                                        $content_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));;
461                                                }
462                                                break;
463                                        case 2 : // normal
464                                                $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
465                                                break;
466                                        case 3 : 
467                                                 $content_url =  (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) 
468                                                                                                                                          : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path']))
469                                                                                 );
470                                                 break;
471                                        default : // normal
472                                                $content_url =  (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path']));
473                                                break;
474                                }
475                        }
476                       
477                        // link on picture.php page
478                        set_make_full_url();
479                        if ( isset($row['category_id']) & isset($row['catname']) ) 
480                        {
481                                $url = duplicate_picture_url(
482                                array(
483                                'image_id' => $row['id'],
484                                'image_file' => $row['file'],
485                                'category' => array(
486                                                                'id' => $row['category_id'],
487                                                                'name' => $row['catname'],
488                                                                'permalink' => ''
489                                                          )
490                                ),
491                                array('start')
492                                );
493                        }
494                        else
495                        {
496                                $url = duplicate_picture_url(
497                                  array(
498                                        'image_id' => $row['id'],
499                                        'image_file' => $row['file']
500                                  ),
501                                  array('start')
502                                );
503                        }       
504                        unset_make_full_url();
505
506                        // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor
507                        if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) 
508                                $url = 'http://' . substr($url, 8);
509                       
510                        // Show rss item for a picture
511                        echo "<item>\n";
512
513
514               
515            echo "<title><![CDATA["
516                  .parse($obj->my_config['piclens_rss_name'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
517                  ."]]></title>\n";
518
519            // not media:description for normal piclens to show description
520            echo '<description><![CDATA['
521                .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
522                .']]> </description>';
523
524            echo '<media:description type="html"><![CDATA['
525                .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
526                .']]> </media:description>';
527
528               
529/*                     
530                        //  Extended description for the comment and category name
531                        if ($plugins_ExtendedDesc)      // Extended description compatibility
532                        {
533                                if (isset($row['catname']))
534                                        $row['catname'] = trigger_event('render_element_description',$row['catname']); 
535                                if (isset($row['comment']))
536                                        $row['comment'] = trigger_event('render_element_description',$row['comment']);
537                        }
538
539                       
540                        // Titre de l'image dans Piclens                       
541                        switch($obj->my_config['piclens_name_image'])
542                        {
543                                case 2 :
544                                                // format nom fichier
545                                        echo "<title><![CDATA["
546                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
547                                                  . $row['file'] . "]]></title>\n";
548                                        break;
549                                case 3 :
550                                        // format nom de la photo
551                                        if (isset($row['name']))
552                                                echo "<title><![CDATA["
553                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
554                                                .$row['name']."]]></title>\n";
555                                        else
556                                                echo "<title><![CDATA["
557                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
558                                                . $row['file'] . "]]></title>\n";
559                                        break;
560                                default :
561                                                // format nom fichier : taille
562                                        echo "<title><![CDATA["
563                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
564                                        . get_thumbnail_title($row) . "]]></title>\n";
565                                        break;
566                        }
567
568                        // Description (nom de vignette) present
569                        switch($obj->my_config['piclens_name_desc'])
570                        {
571                                case 2 :
572                                        if (isset($row['name']))
573                                                echo '<media:description type="html"><![CDATA['.$row['name'].']]> </media:description>';
574                                        break;
575                                case 3 :
576                                        if (isset($row['comment']))
577                                                    {
578                                                        if ($plugins_ExtendedDesc)      // Extended description compatibility
579                                                        {
580                                                            $desc=trigger_event('render_element_description',$row['comment']);
581                                                            echo '<media:description type="html"><![CDATA['.$desc.']]> </media:description>';
582                                                        }
583                                                        else
584                                                            echo '<media:description type="html"><![CDATA['.$row['comment'].']]> </media:description>';                                     
585                                                    }
586                                        break;
587                                default :
588                                        break;
589                        }
590*/           
591                        echo "\n";
592                       
593                        // link
594                        echo "<link>" . $url . "</link>\n";
595
596                        echo "<guid isPermaLink=\"false\">\"" . $row['id'] . "\"</guid>\n";
597                       
598
599                        echo "<media:thumbnail url=\"" . $thumbnail_url . "\" />\n";
600
601                        $extension = explode(".", $row['file']); 
602                        $extension = $extension[sizeof($extension)-1];
603
604                        // Fichiers video  (Charlies content)
605                        if ((in_array($extension, $video_ext_piclens))) 
606                        {
607                                if ($obj->my_config['piclens_video'])   // activation des videos
608                                {
609                                        switch ($extension)
610                                        {
611                                                case "flv":
612                                                        echo "<media:content type=\"video/x-flv\" url=\"".$content_url."\"/>\n";
613                                                        break;
614                                        }
615                                }
616                                else
617                                {
618                                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
619                                }
620                        }
621                        // Fichiers video  (PY Gvideo)
622                        elseif ((in_array($extension, $py_addext))) 
623                        {
624                                if ($obj->my_config['piclens_video'])   // activation des videos
625                                {
626                                        // Si impossibilite de lire le fichier!
627                                        if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path'])))
628                                        {
629                                                echo "<media:content url=\"" . $thumbnail_url . "\" />\n";                                     
630                                        }
631                                        else
632                                        {
633                                                $sp = explode("/", $idvideo);
634                                                switch ($extension)
635                                                {
636                                                        case "dm" :
637                                                                echo "<enclosure url=\"http://www.dailymotion.com/swf/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
638                                                                break;
639                                                        case "ytube":
640                                                                echo "<enclosure url=\"http://youtube.com/v/".$sp[0].".swf\" type=\"application/x-shockwave-flash\" />\n";
641                                                                break;
642                                                        case "wideo":
643                                                                echo "<enclosure url=\"http://www.kewego.com/swf/p3/epix.swf?language_code=fr&amp;playerKey=0df9b773a15b&amp;skinKey=7109c4112f57&amp;sig=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
644                                                                break;
645                                                        case "gvideo":
646                                                                echo "<enclosure url=\"http://video.google.com/googleplayer.swf?docid=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
647                                                                break;
648                                                        case "vimeo":
649                                                                echo "<enclosure url=\"http://vimeo.com/moogaloop.swf?clip_id=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
650                                                                break;
651                                                }
652                                        }
653                                }
654                                else
655                                {
656                                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
657                                }
658                        }
659                        // Images (standard)
660                        else
661                                echo "<media:content url=\"" . $content_url . "\" />\n";
662
663                        echo "</item>\n";
664                        echo "\n";
665                }
666                echo "</channel>\n";
667                echo "</rss>";
668        }
669       
670}
671
672// parse the configuration to complete with the correct informations
673function parse($data, $row, $plugins_ExtendedDesc = false, $nb_comment = 0)
674{
675
676        // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés
677        if (strpos($data, '%ID') === false)
678                $nb_comment = 0;
679
680        include (PICLENS_PATH.'include/config_param.inc.php');
681
682        $patterns = array();
683        $replacements = array();
684        foreach ($piclens_parse as $key => $value)
685        {
686                array_push($patterns, $key); 
687                array_push($replacements, $value);
688        }
689
690        return str_replace($patterns, $replacements, $data);
691}
692
693// Return the last comments of an image id
694function get_comment($img_id, $nb_comment = 0)
695{
696        $commentstring = '';
697
698        if ($nb_comment != 0)
699        {
700                $query = '
701                SELECT id,author,date,image_id,content
702                  FROM '.COMMENTS_TABLE.'
703                  WHERE image_id = '.$img_id.'
704                        AND validated = \'true\'
705                  ORDER BY date ASC
706                  LIMIT 0,'.$nb_comment.'
707                ;';
708                $result = pwg_query( $query );
709                $first = true;
710
711                while ($row = mysql_fetch_array($result))
712                {
713               
714                // Format : "Commentaire (Utilisateur - Date)"
715                        $commentstring .= ($first ?  '' : " / \n")
716                                        .trigger_event('render_comment_content',$row['content'])
717                                        .' ('. trigger_event('render_comment_author',
718                                                                empty($row['author'])
719                                                                ? l10n('guest')
720                                                                : $row['author'])
721                                        .' - '
722                                        .format_date( $row['date'], false)
723                                        .")";
724                                       
725                        $first = false;
726
727                }
728        }
729        return $commentstring; 
730}
731
732?>
Note: See TracBrowser for help on using the repository browser.