module; // Parameters for module include(FLASHGAL_PATH . 'modules/' . $module['type']. '/module.inc.php'); // Vérification d'activation du plugin (page administration) OU activation de piclensWall if (isset($page['section'])) { $cat = array(); $pictures = array(); $forbidden = get_sql_condition_FandF( array ( 'forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id' ), 'AND' ); if (($page['section']) == 'categories') { // Accueil if(empty($page['category']) and $module['on_home']) { // Page accueil // actif sur page accueil // Categories de premier niveau $query = 'SELECT id,name,permalink FROM ' . CATEGORIES_TABLE .' WHERE id_uppercat is NULL'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { if (!(in_array($row['id'], explode(',', $user['forbidden_categories'])))) { array_push($cat, $row['id']); } } // Affichage sur l'accueil uniquement des categories selectionnees if ($module['on_home_global'] == 'selective') { $cats_selected = $module['cats'];//(!empty($module['cats']) ? unserialize($module['cats']) : array()); foreach($cat as $i => $wcat) { if (!in_array($wcat, $cats_selected)) unset($cat[$i]); } } // avec recursiite elseif ($module['recurs_cats'] == 'true') { // recuperation des sous-categories (tous niveaux) de la categorie en cours. $subcat= get_subcat_ids($cat); // Verification droits des sous-categories foreach($subcat as $sscat) { if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) array_push($cat, $sscat); } } $query = 'SELECT DISTINCT(img.id) AS IMGID, img.file AS IMGFILE, img.tn_ext, img.path, img.has_high, img.width AS IMGWIDTH, img.height AS IMGHEIGHT, img.name AS IMGNAME, img.comment AS IMGDESC, img.author AS IMGAUTHOR, img.path AS IMGPATH, cat.id AS CATID, cat.name AS CATNAME, cat.comment AS CATDESC, cat.dir AS CATDIR' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' WHERE ic.category_id IN ('.implode(',', $cat).')' // Verif droits (niveaux) de l'utilisateur sur les images .' AND img.level <='.$user['level'].' ' // Choix du critere de tri d'affichage .(isset($module_data['Order']) ? $module_data['Order'] : str_replace(' id', ' IMGID', $conf['order_by_inside_category'])) .''; } // Page category et actif sur categories elseif (isset($page['category']) and $module['on_cats']) { check_restrictions($page['category']['id']); // recherche de toutes les photos de la categorie (incluant les photos des sous-categories si necessaire) $selectionID = $page['category']['id']; array_push($cat, $selectionID); // Si recursivite activee if ($module['recurs_cats'] == 'true') { // recuperation des sous-categories (tous niveaux) de la categorie en cours. $subcat= get_subcat_ids(array($selectionID)); // Verification droits des sous-categories foreach($subcat as $sscat) { if (!(in_array($sscat, explode(',', $user['forbidden_categories'])))) array_push($cat, $sscat); } } $query = 'SELECT DISTINCT(img.id) AS IMGID, img.file AS IMGFILE, img.tn_ext, img.path, img.has_high, img.width AS IMGWIDTH, img.height AS IMGHEIGHT, img.name AS IMGNAME, img.comment AS IMGDESC, img.author AS IMGAUTHOR, img.path AS IMGPATH, cat.id AS CATID, cat.name AS CATNAME, cat.comment AS CATDESC, cat.dir AS CATDIR' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' WHERE ic.category_id IN ('.implode(',', $cat).')' // Verif droits (niveaux) de l'utilisateur sur les images .' AND img.level <='.$user['level'].' ' // Choix du critere de tri d'affichage .(isset($module_data['Order']) ? $module_data['Order'] : str_replace(' id', ' IMGID', $conf['order_by_inside_category'])) .''; } } if ($debug) echo $query; $flashgal_extdesc_hidden = ''; // Si au moins une image récupérée (une catégorie ou une image présente) if (count($cat)!=0) { $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) { // Prise en compte images et galeries en hidden if ( !(substr_count($row['IMGNAME'], $flashgal_extdesc_hidden)) && ((isset($row['CATNAME']) ? !(substr_count($row['CATNAME'], $flashgal_extdesc_hidden)) : true)) ) array_push($pictures, $row); } } // Fin requetes recherches photos $module['datas'] = (!empty($module['datas']) ? unserialize($module['datas']) : array('')); $module['ext_datas'] = (!empty($module['ext_datas']) ? unserialize($module['ext_datas']) : array('')); // Creation du fichier xml (flux rss) // Possibilite de ne pas ajouter l'entete xml (certains modules) if (!isset($module_data['no_xml_header']) or $module_data['no_xml_header'] == false ) { header("Content-Type: application/xml; charset=UTF-8"); } include_once(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/before_header.inc.php'); include_once(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/header.xml.php'); $prev_catid = ""; // Variable pour categorie precedente // Pour chacune des images, preparation du flux xml foreach ($pictures as $row) { // Alimentation des variables pour la constitution du flux xml foreach ($module_data['datas'] as $keydata => $valuedata) { if ($valuedata) // == true $picture[$keydata] = parse($module['datas'][$keydata], $row, $module['maxcomment']); else $picture[$keydata] = ''; } // Si module avec regroupement par categorie et categorie precedente != categorie actuelle (ATTENTION, le tri a du être trié par categories) if (isset($module_data['Cat_Regroup']) and $module_data['Cat_Regroup'] and $prev_catid != $row['CATID'] and $prev_catid !="") { include(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/after_imageNode.xml.php'); } // Si module avec regroupement par categorie et categorie precedente != categorie actuelle (ATTENTION, le tri a du être trié par categories) if (isset($module_data['Cat_Regroup']) and $module_data['Cat_Regroup'] and $prev_catid != $row['CATID']) { include(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/before_imageNode.xml.php'); } // Constitution du flux xml avec l'image en cours include(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/imageNode.xml.php'); // categorie precedente sauvegardee $prev_catid = $row['CATID']; } if (isset($module_data['Cat_Regroup']) and $module_data['Cat_Regroup'] and $prev_catid !="") { include(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/after_imageNode.xml.php'); } include_once(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/before_footer.inc.php'); include_once(FLASHGAL_PATH . 'modules/' . $module['type']. '/xml/footer.xml.php'); } unset_make_full_url(); function parse($data, $row, $nb_comment = 0) { // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés if (strpos($data, '%ID') === false) $nb_comment = 0; include (FLASHGAL_PATH.'include/config_param.inc.php'); $patterns = array(); $replacements = array(); foreach ($flashgal_parse as $key => $value) { array_push($patterns, $key); array_push($replacements, $value); } return str_replace($patterns, $replacements, $data); } // Return the last comments of an image id function get_comment($img_id, $nb_comment = 0) { $commentstring = ''; if ($nb_comment != 0) { $query = ' SELECT id,author,date,image_id,content FROM '.COMMENTS_TABLE.' WHERE image_id = '.$img_id.' AND validated = \'true\' ORDER BY date ASC LIMIT 0,'.$nb_comment.' ;'; $result = pwg_query( $query ); $first = true; while ($row = mysql_fetch_array($result)) { // Format : "Commentaire (Utilisateur - Date)" $commentstring .= ($first ? '' : " / \n") .trigger_event('render_comment_content',$row['content']) .' ('. trigger_event('render_comment_author', empty($row['author']) ? l10n('guest') : $row['author']) .' - ' .format_date( $row['date'], false) .")"; $first = false; } } return $commentstring; } ?>