source: extensions/piclens/generate_rss.php @ 3614

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

Modify parameters format for name and descriptions in rss feed (use preformated parameters like Flash_Gallery)
Increase length for config zone in tpl

File size: 23.0 KB
Line 
1<?php
2/*
3 * Plugin Name: CoolIris-Piclens
4 * Version: 0.3.4
5 * Description: Cooliris/Piclens activation
6 * Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=234
7 * Author: Tiico
8 * Author URI:
9 * */
10/********* Fichier generate_rss.php  *********/
11
12$debug = false;
13
14if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
15
16include (PICLENS_INC_PATH.'config_extendeddesc.inc.php');       // Parametres pour extended description.
17
18// recuperation du parametre pour le mode no recursif (forçage de la non recursivite)
19if (isset($_GET['norecurs'])) 
20{
21        $obj->my_config['piclens_recursive'] = false;
22}
23
24
25// extensions video
26$py_addext = array("gvideo", "dm", "ytube", "wideo", "vimeo", "flv");
27$video_ext_piclens = array("flv");
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');   
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                elseif (($page['section']) == 'categories')
181                {
182                        // Accueil
183                        if(empty($page['category'])) 
184                        {
185                                // Page accueil
186                                // Vérification d'activation du plugin (page administration)
187                                // ou flux pour piclenswall et configuration specifique
188                                if ($obj->my_config['piclens_gallerie_active'] || $piclenswallfeed)
189                                {
190                                        // Categories de premier niveau
191                                        $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE
192                                        .' WHERE id_uppercat is NULL';
193                                       
194                                        $result = pwg_query($query);
195
196                                        while ($row = mysql_fetch_assoc($result))
197                                        {
198                                                if (!(in_array($row['id'], explode(',', $user['forbidden_categories']))))
199                                                {
200                                                                        array_push($cat, $row['id']);
201                                                               
202                                                }
203                                        }
204                                        // Type = avec recursiite
205                                        // Si parametrage specifique pour le mur 3D,  recursivite sur les categories
206                                        if (($piclenswallfeed) || (( $obj->my_config['piclens_gallerie_type'])-1))
207                                        {
208                                                // recuperation des sous-categories (tous niveaux) de la categorie en cours.
209                                                $subcat= get_subcat_ids($cat);
210                       
211                                                // Verification droits des sous-categories
212                                                foreach($subcat as $sscat)
213                                                {
214                                                        if (!(in_array($sscat, explode(',', $user['forbidden_categories']))))
215                                                                        array_push($cat, $sscat);
216                                                }
217                                        }
218
219                                        // selection uniquement des categories a afficher (si flux pour le mur ET parametre mur = specifique)
220                                        if ($piclenswallfeed)
221                                        {
222                                                foreach($cat as $i => $wcat)
223                                                {
224                                                        if (!in_array($wcat, $piclenswall_cat))
225                                                                unset($cat[$i]);
226                                                }
227                                        }
228
229                                        $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
230                                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
231                                                          img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
232                                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
233                                        .' FROM ' . IMAGES_TABLE.' AS img'
234                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
235                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
236                                        .' WHERE ic.category_id IN ('.implode(',', $cat).')'
237                                        .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
238                                        .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
239                                        // Verif droits (niveaux) de l'utilisateur sur les images
240                                        .' AND img.level <='.$user['level'].' '
241                                        // Choix du critere de tri d'affichage
242                                        .$order_list[ $obj->my_config['piclens_order'] ]
243                                        .$order_sort[ $obj->my_config['piclens_sort'] ];
244                                       
245                                       
246                                }
247                        }
248                       
249                        // Page category
250                        elseif (isset($page['category']))
251                        {
252                                check_restrictions($page['category']['id']);
253               
254                                // Flux pour le mur 3D et mur en mode "specifique"
255                                if ($piclenswallfeed)
256                                {
257                                        $selectionID = $page['category']['id'];
258                                        //  categorie parametre pour etre affichee dans le mur
259                                        if (in_array($selectionID, $piclenswall_cat))
260                                                array_push($cat, $selectionID);
261
262                                        // recuperation des sous-categories (tous niveaux) de la categorie en cours.
263                                        $subcat= get_subcat_ids(array($selectionID));
264
265                                        // Verification ajout des sous-categories qui peuvent être affichees (parametrees dans mur 3D) et des drois des sous categories
266                                        foreach($subcat as $sscat)
267                                        {
268                                                if ((in_array($sscat, $piclenswall_cat)) && (!(in_array($sscat, explode(',', $user['forbidden_categories'])))))
269                                                        array_push($cat, $sscat);
270                                        }
271
272                                }
273                                // Piclens (et mur 3D avec meme parametrage que piclens) : paramétrage "commun"
274                                else
275                                {               
276                                        //  recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire)
277                                        $selectionID = $page['category']['id'];
278
279                                        array_push($cat, $selectionID);
280
281                                        // Si recursivite activee
282                                        if ($obj->my_config['piclens_recursive'])
283                                        {
284                                                // recuperation des sous-categories (tous niveaux) de la categorie en cours.
285                                                $subcat= get_subcat_ids(array($selectionID));
286
287                                                // Verification droits des sous-categories
288                                                foreach($subcat as $sscat)
289                                                {
290                                                        if (!(in_array($sscat, explode(',', $user['forbidden_categories']))))
291                                                                array_push($cat, $sscat);
292                                                }
293                                       
294                                        }
295                                }
296                                       
297                                $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
298                                                  img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
299                                                  img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
300                                                  cat.visible, cat.uppercats, cat.permalink, cat.dir '
301                                .' FROM ' . IMAGES_TABLE.' AS img'
302                                .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
303                                .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
304                                .' WHERE ic.category_id IN ('.implode(',', $cat).')'
305                                .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
306                                .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
307                                // Verif droits (niveaux) de l'utilisateur sur les images
308                                .' AND img.level <='.$user['level'].' '
309                                // Choix du critere de tri d'affichage
310                                .$order_list[ $obj->my_config['piclens_order_cat'] ]
311                                .$order_sort[ $obj->my_config['piclens_sort_cat'] ];
312
313                                }
314                }
315                       
316                if ($debug)     echo $query;
317               
318                        // Si au moins une image récupérée (une catégorie ou une image présente)
319                if (count($cat)!=0)
320                {
321                        $result = pwg_query($query);
322                        while ($row = mysql_fetch_assoc($result))
323                        {
324                                // Plugin Extended Description present et active
325                                // suppression des categories et images pour lesquelles un <!--hidden--> est present
326                                if (!$plugins_ExtendedDesc
327                                        OR ($plugins_ExtendedDesc 
328                                                && !(substr_count($row['name'],  $piclens_extdesc_hidden)) 
329                                                && ((isset($row['catname']) ? !(substr_count($row['catname'],  $piclens_extdesc_hidden)) : true))
330                                                ))
331                                        array_push($pictures, $row);
332                        }
333                }
334                // Fin requetes recherches photos
335
336               
337                // Creation du fichier xml (flux rss)
338                // It's a rss file
339                header("Content-Type: application/xml; charset=UTF-8");
340                echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
341                echo "\n";
342                echo '<rss version="2.0" '."\n"
343                         .'xmlns:media="http://search.yahoo.com/mrss/" '."\n"
344                         .'xmlns:atom="http://www.w3.org/2005/Atom">';
345                echo "\n";
346                echo '<channel>';
347                echo "\n";
348
349                //      <!--    <title>test Page</title> -->
350                echo '<link>'.$obj->root_site_piclens.'</link>';
351                echo "\n";
352                echo '<description>Flux RSS pour cooliris</description>';
353                echo "\n";
354                echo '<language>fr</language>';
355                echo "\n";
356
357                // Version du plugin Piclens
358                $db_plugins = get_db_plugins('', 'piclens'); 
359                if (!empty($db_plugins)) 
360                        $piclens_version = $db_plugins[0]['version']; 
361                else
362                        $piclens_version = 'N/A'; 
363
364                echo '<generator>Piwigo Cooliris Plugin v.'.$piclens_version.'</generator>';
365                echo "\n";
366
367                // Icone de la gallerie dans le flux RSS
368//              echo '<logo url="'.get_root_url().'template-common/favicon.ico"></logo>';
369                echo "\n";
370                echo '<atom:icon>'.$obj->root_site_piclens.'template-common/favicon.ico</atom:icon>';
371                echo "\n";
372//   <atom:link href="http://mywebsite.com/photos.rss" rel="self" type="application/rss+xml" />
373
374                // Pour chacune des images, preparation du flux xml
375                foreach ($pictures as $row)
376                {
377                        // Mode de l'image parametre
378                        $piclens_normal = $obj->my_config['piclens_normal'];
379
380                        // si parametrage high et high absente ou utilisateur non habilite, affichage version normale
381                        if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high']))
382                                $piclens_normal = 2; // Normal uniquement pour l'image en cours
383
384                        // Get thumbnail url
385                        if ($plugins_SecureImage)       // SecureImage installe et actif
386                        {
387                                $link_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id'];
388
389                                $thumbnail_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']
390                                .$thumb_secure[$obj->my_config['piclens_thumb'] ];
391                                $content_url = $obj->root_site_piclens.'plugins/secureImages/getFile.php?image_id='.$row['id']
392                                .$normal_secure[$piclens_normal ];
393                        }
394                        else    // SecureImage non installe ou non actif
395                        {
396                                $link_url = $obj->root_site_piclens.$row['path'];
397                               
398                                if ( ($obj->my_config['piclens_thumb']) == 2)   // Normal
399                                        $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
400                                else
401                                {
402                                        if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
403                                        {
404                                                $path=get_thumbnail_location($row);
405                                                $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
406                                        }
407                                        else    // Plugin secureimage desactive
408                                        {
409                                                $thumbnail_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));
410                                        }
411                                }       
412
413                                switch ($piclens_normal)
414                                {
415                                        case 1 : // miniature
416                                                if ($plugins_SecureImage_only)  // Plugin secureimage active mais configuration compatibilite piclens-secureimage desactivee
417                                                {
418                                                        $path=get_thumbnail_location($row);
419                                                        $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
420                                                }
421                                                else    // Plugin secureimage desactive
422                                                {
423                                                        $content_url = embellish_url($obj->root_site_piclens.get_thumbnail_location($row));;
424                                                }
425                                                break;
426                                        case 2 : // normal
427                                                $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
428                                                break;
429                                        case 3 : 
430                                                 $content_url =  (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path']) 
431                                                                                                                                          : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path']))
432                                                                                 );
433                                                 break;
434                                        default : // normal
435                                                $content_url =  (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path']));
436                                                break;
437                                }
438                        }
439                       
440                        // link on picture.php page
441                        set_make_full_url();
442                        if ( isset($row['category_id']) & isset($row['catname']) ) 
443                        {
444                                $url = duplicate_picture_url(
445                                array(
446                                'image_id' => $row['id'],
447                                'image_file' => $row['file'],
448                                'category' => array(
449                                                                'id' => $row['category_id'],
450                                                                'name' => $row['catname'],
451                                                                'permalink' => ''
452                                                          )
453                                ),
454                                array('start')
455                                );
456                        }
457                        else
458                        {
459                                $url = duplicate_picture_url(
460                                  array(
461                                        'image_id' => $row['id'],
462                                        'image_file' => $row['file']
463                                  ),
464                                  array('start')
465                                );
466                        }       
467                        unset_make_full_url();
468
469                        // HTTPS Patch : If needed NO_https can easily be set in your config_local thru LocalFiles Editor
470                        if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) 
471                                $url = 'http://' . substr($url, 8);
472                       
473                        // Show rss item for a picture
474                        echo "<item>\n";
475
476
477               
478            echo "<title><![CDATA["
479                  .parse($obj->my_config['piclens_rss_name'], $row)
480                  ."]]></title>\n";
481
482
483            echo '<media:description type="html"><![CDATA['
484                .parse($obj->my_config['piclens_rss_desc'], $row)
485                .']]> </media:description>';
486                 
487/*                     
488                        //  Extended description for the comment and category name
489                        if ($plugins_ExtendedDesc)      // Extended description compatibility
490                        {
491                                if (isset($row['catname']))
492                                        $row['catname'] = trigger_event('render_element_description',$row['catname']); 
493                                if (isset($row['comment']))
494                                        $row['comment'] = trigger_event('render_element_description',$row['comment']);
495                        }
496
497                       
498                        // Titre de l'image dans Piclens                       
499                        switch($obj->my_config['piclens_name_image'])
500                        {
501                                case 2 :
502                                                // format nom fichier
503                                        echo "<title><![CDATA["
504                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
505                                                  . $row['file'] . "]]></title>\n";
506                                        break;
507                                case 3 :
508                                        // format nom de la photo
509                                        if (isset($row['name']))
510                                                echo "<title><![CDATA["
511                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
512                                                .$row['name']."]]></title>\n";
513                                        else
514                                                echo "<title><![CDATA["
515                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
516                                                . $row['file'] . "]]></title>\n";
517                                        break;
518                                default :
519                                                // format nom fichier : taille
520                                        echo "<title><![CDATA["
521                                                  .(($obj->my_config['piclens_cat_view'] && isset ($row['catname'])) ? $row['catname']." - " : "")
522                                        . get_thumbnail_title($row) . "]]></title>\n";
523                                        break;
524                        }
525
526                        // Description (nom de vignette) present
527                        switch($obj->my_config['piclens_name_desc'])
528                        {
529                                case 2 :
530                                        if (isset($row['name']))
531                                                echo '<media:description type="html"><![CDATA['.$row['name'].']]> </media:description>';
532                                        break;
533                                case 3 :
534                                        if (isset($row['comment']))
535                                                echo '<media:description type="html"><![CDATA['.$row['comment'].']]> </media:description>';                                     
536                                        break;
537                                default :
538                                        break;
539                        }
540*/           
541                        echo "\n";
542                       
543                        // link
544                        echo "<link>" . $url . "</link>\n";
545
546//                      echo "<guid>" . $row['id'] . "\</guid>\n";                             
547                        echo "<guid isPermaLink=\"false\">\"" . $row['id'] . "\"</guid>\n";
548                       
549
550                        echo "<media:thumbnail url=\"" . $thumbnail_url . "\" />\n";
551
552                        $extension = explode(".", $row['file']); 
553                        $extension = $extension[sizeof($extension)-1];
554
555                        // Fichiers video  (Charlies content)
556                        if ((in_array($extension, $video_ext_piclens))) 
557                        {
558                                if ($obj->my_config['piclens_video'])   // activation des videos
559                                {
560                                        switch ($extension)
561                                        {
562                                                case "flv":
563                                                        echo "<media:content type=\"video/x-flv\" url=\"".$content_url."\"/>\n";
564                                                        break;
565                                        }
566                                }
567                                else
568                                {
569                                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
570                                }
571                        }
572                        // Fichiers video  (PY Gvideo)
573                        elseif ((in_array($extension, $py_addext))) 
574                        {
575                                if ($obj->my_config['piclens_video'])   // activation des videos
576                                {
577                                        // Si impossibilite de lire le fichier!
578                                        if( false == ($idvideo = file_get_contents(PHPWG_ROOT_PATH.$row['path'])))
579                                        {
580                                                echo "<media:content url=\"" . $thumbnail_url . "\" />\n";                                     
581                                        }
582                                        else
583                                        {
584                                                $sp = explode("/", $idvideo);
585                                                switch ($extension)
586                                                {
587                                                        case "dm" :
588                                                                echo "<enclosure url=\"http://www.dailymotion.com/swf/".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
589                                                                break;
590                                                        case "ytube":
591                                                                echo "<enclosure url=\"http://youtube.com/v/".$sp[0].".swf\" type=\"application/x-shockwave-flash\" />\n";
592                                                                break;
593                                                        case "wideo":
594                                                                echo "<enclosure url=\"http://www.kewego.com/swf/p3/epix.swf?language_code=fr&amp;playerKey=0df9b773a15b&amp;skinKey=7109c4112f57&amp;sig=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
595                                                                break;
596                                                        case "gvideo":
597                                                                echo "<enclosure url=\"http://video.google.com/googleplayer.swf?docid=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
598                                                                break;
599                                                        case "vimeo":
600                                                                echo "<enclosure url=\"http://vimeo.com/moogaloop.swf?clip_id=".$sp[0]."\" type=\"application/x-shockwave-flash\" />\n";
601                                                                break;
602                                                }
603                                        }
604                                }
605                                else
606                                {
607                                        echo "<media:content url=\"" . $thumbnail_url . "\" />\n";
608                                }
609                        }
610                        // Images (standard)
611                        else
612                                echo "<media:content url=\"" . $content_url . "\" />\n";
613
614                        echo "</item>\n";
615                        echo "\n";
616                }
617                echo "</channel>\n";
618                echo "</rss>";
619        }
620       
621}
622
623
624function parse($data, $row)
625{
626        include (PICLENS_PATH.'include/config_param.inc.php');
627
628        $patterns = array();
629        $replacements = array();
630        foreach ($piclens_parse as $key => $value)
631        {
632                array_push($patterns, $key); 
633                array_push($replacements, $value);
634        }
635
636        return str_replace($patterns, $replacements, $data);
637}
638
639
640
641?>
Note: See TracBrowser for help on using the repository browser.