source: extensions/piclens/generate_rss.php @ 3901

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

fix bug 1166

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