source: branches/rsr.v5.1.1/web/app/data/modules/data_playlists.php @ 6

Last change on this file since 6 was 1, checked in by dj3c1t, 13 years ago

import initial

File size: 3.2 KB
Line 
1<?php
2
3  class data_playlists extends data
4  {
5
6    function pl_last_downloads($n = null)
7    { return $this->dp_playlist
8      ( " ORDER BY #--download_urls.date_publication DESC"
9       .(isset($n) ? " LIMIT ".$n : "")
10      );
11    }
12
13    function pl_rand_downloads($n = null)
14    { return $this->dp_playlist
15      ( " ORDER BY RAND()"
16       .(isset($n) ? " LIMIT ".$n : "")
17      );
18    }
19
20    function pl_artiste_downloads($id_artiste, $album = null)
21    { return $this->dp_playlist
22      (  (isset($album) ? " AND #--downloads.id_album=".$album : "")
23        ." AND #--artistes.id=".$id_artiste
24        ." ORDER BY #--downloads.ordre ASC"
25       .(isset($n) ? " LIMIT ".$n : "")
26      );
27    }
28
29    function dp_playlist($_sql)
30    { $playlist = array();
31      try
32      { $sql =
33         "SELECT *"
34        .", YEAR(date_updated) as year_updated"
35        .", IF(MONTH(date_updated) > 9, MONTH(date_updated), CONCAT('0', MONTH(date_updated))) as month_updated"
36        .", IF(DAYOFMONTH(date_updated) > 9, DAYOFMONTH(date_updated), CONCAT('0', DAYOFMONTH(date_updated))) as day_updated"
37        ." FROM ( SELECT"
38        ."  distinct(#--download_urls.id_download)"
39        .", #--download_urls.id as id_download_url"
40        .", #--download_urls.url"
41        .", #--downloads.nom as titre"
42        .", #--downloads.style"
43        .", #--formats.content_type"
44        .", #--artistes.nom as auteur"
45        .", #--artistes.id as id_auteur"
46        .", #--licences.id as id_licence"
47        .", #--licences.nom as licence"
48        .", #--licences.lien as licence_url"
49        .", #--downloads.date_creation as date_created"
50        .", #--download_urls.date_publication as date_updated"
51        ." FROM"
52        ."  #--download_urls"
53        .", #--formats"
54        .", #--downloads"
55        .", #--artistes"
56        .", #--licences"
57        ." WHERE #--download_urls.id_format=#--formats.id"
58        ." AND #--download_urls.id_download=#--downloads.id"
59        ." AND #--downloads.id_artiste=#--artistes.id"
60        ." AND #--downloads.id_licence=#--licences.id"
61        ." AND actif=1"
62        .$_sql
63        .") t";
64        $rst = $this->sql->query($sql);
65        while($v_rst = $this->sql->fetch_assoc($rst))
66        { $playlist[$v_rst["id_download"]] = $v_rst;
67          $playlist[$v_rst["id_download"]]["urls"] = array();
68          $u_query =
69           "SELECT #--download_urls.*, #--formats.nom as format"
70          ." FROM #--download_urls, #--formats"
71          ." WHERE id_download=".$v_rst["id_download"]
72          ." AND #--download_urls.id_format=#--formats.id";
73          $u_rst = $this->sql->query($u_query);
74          while($v_u_rst = $this->sql->fetch_assoc($u_rst))
75          { $playlist[$v_rst["id_download"]]["urls"][$v_u_rst["id"]] = $v_u_rst;
76            $playlist[$v_rst["id_download"]]["compteur"] += $v_u_rst["compteur"];
77            if($v_u_rst["format"] === "mp3")
78            { $playlist[$v_rst["id_download"]]["mp3_id_url"] = $v_u_rst["id"];
79              $playlist[$v_rst["id_download"]]["mp3_url"] = $v_u_rst["url"];
80            }
81          }
82          $this->sql->free_result($u_rst);
83        }
84      }
85      catch(Exception $_e) { $playlist = false; }
86      return $playlist;
87    }
88
89  }
90
91?>
Note: See TracBrowser for help on using the repository browser.