Ignore:
Timestamp:
Jul 22, 2009, 12:34:42 AM (15 years ago)
Author:
tiico
Message:

Some corrections
Add EN translation (only for the core, not for modules)
Add comment options (%ID)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Flash_Gallery/generate-xml.php

    r3531 r3663  
    233233        foreach ($pictures as $row)
    234234        {
    235 //      echo "prev=".$prev_catid;
    236 //      echo "catid=".$row['CATID'];
    237235                // Alimentation des variables pour la constitution du flux xml
    238236                foreach ($module_data['datas'] as $keydata => $valuedata)
    239237                {
    240238                        if ($valuedata) // == true
    241                                 $picture[$keydata] =  parse($module['datas'][$keydata], $row);
     239                                $picture[$keydata] =  parse($module['datas'][$keydata], $row, $module['maxcomment']);
    242240                        else
    243241                                $picture[$keydata] = '';
     
    274272unset_make_full_url();
    275273
    276 function parse($data, $row)
    277 {
     274function parse($data, $row, $nb_comment = 0)
     275{
     276        // Eviter de charger les commentaires (appels base) si ils ne sont pas affichés
     277        if (strpos($data, '%ID') === false)
     278                $nb_comment = 0;
     279
    278280        include (FLASHGAL_PATH.'include/config_param.inc.php');
    279281
     
    282284        foreach ($flashgal_parse as $key => $value)
    283285        {
    284 //              echo "key=".$key."  value=".$value."\n";
    285286                array_push($patterns, $key);
    286287                array_push($replacements, $value);
     
    288289
    289290        return str_replace($patterns, $replacements, $data);
    290 //      echo "output=".$output;
    291 //      return $output;
     291}
     292
     293// Return the last comments of an image id
     294function get_comment($img_id, $nb_comment = 0)
     295{
     296        $commentstring = '';
     297
     298        if ($nb_comment != 0)
     299        {
     300                $query = '
     301                SELECT id,author,date,image_id,content
     302                  FROM '.COMMENTS_TABLE.'
     303                  WHERE image_id = '.$img_id.'
     304                        AND validated = \'true\'
     305                  ORDER BY date ASC
     306                  LIMIT 0,'.$nb_comment.'
     307                ;';
     308                $result = pwg_query( $query );
     309                $first = true;
     310
     311                while ($row = mysql_fetch_array($result))
     312                {
     313               
     314                // Format : "Commentaire (Utilisateur - Date)"
     315                        $commentstring .= ($first ?  '' : " / \n")
     316                                        .trigger_event('render_comment_content',$row['content'])
     317                                        .' ('. trigger_event('render_comment_author',
     318                                                                empty($row['author'])
     319                                                                ? l10n('guest')
     320                                                                : $row['author'])
     321                                        .' - '
     322                                        .format_date( $row['date'], false)
     323                                        .")";
     324                                       
     325                        $first = false;
     326
     327                }
     328        }
     329        return $commentstring; 
    292330}
    293331
Note: See TracChangeset for help on using the changeset viewer.