source: extensions/piclens/generate_rss.php @ 3894

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

Fix Bug 0001130
Possibility to add $confpiclens_videoext_thumb. Extensions in this array are display as thumb (content not show). Use to select videos file to show.

File size: 27.5 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                                        if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
464                                        {
465                                                $path=get_thumbnail_location($row);
466                                                $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
467                                        }
468                                        else    // Plugin secureimage desactive
469                                        {
470                                                $thumbnail_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));
471                                        }
472                                }       
473
474                                switch ($piclens_normal)
475                                {
476                                        case 1 : // miniature
477                                                if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
478                                                {
479                                                        $path=get_thumbnail_location($row);
480                                                        $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
481                                                }
482                                                else    // Plugin secureimage desactive
483                                                {
484                                                        $content_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));;
485                                                }
486                                                break;
487                                        case 2 : // normal
488                                                $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
489                                                break;
490                                        case 3 : 
491                                                 $content_url =  (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) 
492                                                                                                                                          : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path']))
493                                                                                 );
494                                                 break;
495                                        default : // normal
496                                                $content_url =  (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path']));
497                                                break;
498                                }
499                        }
500                       
501                        // link on picture.php page
502                        set_make_full_url();
503                        if ( isset($row['category_id']) & isset($row['catname']) ) 
504                        {
505                                $url = duplicate_picture_url(
506                                array(
507                                'image_id' => $row['id'],
508                                'image_file' => $row['file'],
509                                'category' => array(
510                                                                'id' => $row['category_id'],
511                                                                'name' => $row['catname'],
512                                                                'permalink' => ''
513                                                          )
514                                ),
515                                array('start')
516                                );
517                        }
518                        else
519                        {
520                                $url = duplicate_picture_url(
521                                  array(
522                                        'image_id' => $row['id'],
523                                        'image_file' => $row['file']
524                                  ),
525                                  array('start')
526                                );
527                        }       
528                        unset_make_full_url();
529
530                        // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor
531                        if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) 
532                                $url = 'http://' . substr($url, 8);
533                       
534                        // Show rss item for a picture
535                        echo "<item>\n";
536
537
538               
539            echo "<title><![CDATA["
540                  .parse($obj->my_config['piclens_rss_name'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
541                  ."]]></title>\n";
542
543            // not media:description for normal piclens to show description
544            echo '<description><![CDATA['
545                .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
546                .']]> </description>';
547
548            echo '<media:description type="html"><![CDATA['
549                .parse($obj->my_config['piclens_rss_desc'], $row, $plugins_ExtendedDesc, $obj->my_config['piclens_maxcomment_nb'])
550                .']]> </media:description>';
551
552               
553/*                     
554                        //  Extended description for the comment and category name
555                        if ($plugins_ExtendedDesc)      // Extended description compatibility
556                        {
557                                if (isset($row['catname']))
558                                        $row['catname'] = trigger_event('render_element_description',$row['catname']); 
559                                if (isset($row['comment']))
560                                        $row['comment'] = trigger_event('render_element_description',$row['comment']);
561                        }
562
563                       
564                        // Titre de l'image dans Piclens                       
565                        switch($obj->my_config['piclens_name_image'])
566                        {
567                                case 2 :
568                                                // format nom fichier
569                                        echo "<title><![CDATA["
570                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
571                                                  . $row['file'] . "]]></title>\n";
572                                        break;
573                                case 3 :
574                                        // format nom de la photo
575                                        if (isset($row['name']))
576                                                echo "<title><![CDATA["
577                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
578                                                .$row['name']."]]></title>\n";
579                                        else
580                                                echo "<title><![CDATA["
581                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
582                                                . $row['file'] . "]]></title>\n";
583                                        break;
584                                default :
585                                                // format nom fichier : taille
586                                        echo "<title><![CDATA["
587                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
588                                        . get_thumbnail_title($row) . "]]></title>\n";
589                                        break;
590                        }
591
592                        // Description (nom de vignette) present
593                        switch($obj->my_config['piclens_name_desc'])
594                        {
595                                case 2 :
596                                        if (isset($row['name']))
597                                                echo '<media:description type="html"><![CDATA['.$row['name'].']]> </media:description>';
598                                        break;
599                                case 3 :
600                                        if (isset($row['comment']))
601                                                    {
602                                                        if ($plugins_ExtendedDesc)      // Extended description compatibility
603                                                        {
604                                                            $desc=trigger_event('render_element_description',$row['comment']);
605                                                            echo '<media:description type="html"><![CDATA['.$desc.']]> </media:description>';
606                                                        }
607                                                        else
608                                                            echo '<media:description type="html"><![CDATA['.$row['comment'].']]> </media:description>';                                     
609                                                    }
610                                        break;
611                                default :
612                                        break;
613                        }
614*/           
615                        echo "\n";
616                       
617                        // link
618                        echo "<link>" . $url . "</link>\n";
619
620                        echo "<guid isPermaLink=\"false\">\"" . $row['id'] . "\"</guid>\n";
621                       
622
623                        echo "<media:thumbnail url=\"" . $thumbnail_url . "\" />\n";
624
625                        $extension = explode(".", $row['file']); 
626                        $extension = $extension[sizeof($extension)-1];
627
628                        // Fichiers video  (Charlies content)
629            if ((in_array($extension, array_merge($video_ext_piclens,$videos_ext_other) )))
630            {
631                if ($obj->my_config['piclens_video']) // activation des videos
632                {
633                    if ((in_array($extension, $video_ext_piclens)))
634                    {
635                        //video supported by cooliris
636                        echo "<media:content type=\"video/x-flv\" url=\"".$content_url."\"/>\n";
637                    } 
638                    else
639                    {
640                        //video not supported by cooliris: thumbnail is displayed
641                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
642                    }
643                }
644                else // deactivation of videos
645                {
646                  echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
647                }
648            } 
649                        // Fichiers video  (PY Gvideo)
650                        elseif ((in_array($extension, $py_addext))) 
651                        {
652                                if ($obj->my_config['piclens_video'])   // activation des videos
653                                {
654                                        // Si impossibilite de lire le fichier!
655                                        if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path'])))
656                                        {
657                                                echo "<media:content url=\"" . $thumbnail_url . "\" />\n";                                     
658                                        }
659                                        else
660                                        {
661                                                $sp = explode("/", $idvideo);
662                                                switch ($extension)
663                                                {
664                                                        case "dm" :
665                                                                echo "<<media:content url=\"http://www.dailymotion.com/swf/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
666                                                                break;
667                                                        case "ytube":
668                                                                echo "<media:content url=\"http://youtube.com/v/".$sp[0].".swf\" type=\"application/x-shockwave-flash\" />\n";
669                                                                break;
670                                                        case "wideo":
671                                                                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";
672                                                                break;
673                                                        case "gvideo":
674                                                                echo "<<media:content url=\"http://video.google.com/googleplayer.swf?docid=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
675                                                                break;
676                                                        case "vimeo":
677                                                                echo "<<media:content url=\"http://vimeo.com/moogaloop.swf?clip_id=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
678                                                                break;
679                                                        case "wat":
680                                                                echo "<media:content url=\"http://www.wat.tv/swf2/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
681                                                                break;
682                                                }
683                                        }
684                                }
685                                else
686                                {
687                                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
688                                }
689                        }
690                        // Images (standard)
691                        else
692                                echo "<media:content url=\"" . $content_url . "\" />\n";
693
694                        echo "</item>\n";
695                        echo "\n";
696                }
697                echo "</channel>\n";
698                echo "</rss>";
699        }
700       
701}
702
703// parse the configuration to complete with the correct informations
704function parse($data, $row, $plugins_ExtendedDesc = false, $nb_comment = 0)
705{
706
707        // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés
708        if (strpos($data, '%ID') === false)
709                $nb_comment = 0;
710
711        include (PICLENS_PATH.'include/config_param.inc.php');
712
713        $patterns = array();
714        $replacements = array();
715        foreach ($piclens_parse as $key => $value)
716        {
717                array_push($patterns, $key); 
718                array_push($replacements, $value);
719        }
720
721        return str_replace($patterns, $replacements, $data);
722}
723
724// Return the last comments of an image id
725function get_comment($img_id, $nb_comment = 0)
726{
727        $commentstring = '';
728
729        if ($nb_comment != 0)
730        {
731                $query = '
732                SELECT id,author,date,image_id,content
733                  FROM '.COMMENTS_TABLE.'
734                  WHERE image_id = '.$img_id.'
735                        AND validated = \'true\'
736                  ORDER BY date ASC
737                  LIMIT 0,'.$nb_comment.'
738                ;';
739                $result = pwg_query( $query );
740                $first = true;
741
742                while ($row = mysql_fetch_array($result))
743                {
744               
745                // Format : "Commentaire (Utilisateur - Date)"
746                        $commentstring .= ($first ?  '' : " / \n")
747//                                      .trigger_event('render_comment_content',$row['content'])
748                                        .empty($row['content']) ? '': $row['content']
749//                                      .' ('. trigger_event('render_comment_author',
750                                        .(empty($row['author'])
751                                                                ? l10n('guest')
752                                                                : $row['author'])
753                                        .' - '
754                                        .format_date( $row['date'], false)
755                                        .")";
756                                       
757                        $first = false;
758
759                }
760        }
761        return $commentstring; 
762}
763
764?>
Note: See TracBrowser for help on using the repository browser.