vendor/theatre/core/src/Repository/DvdsRepository.php line 746

Open in your IDE?
  1. <?php
  2. namespace TheatreCore\Repository;
  3. use TheatreCore\Classes\Images\Images;
  4. use TheatreCore\Entity\Dvdformats;
  5. use TheatreCore\Entity\Dvds;
  6. use TheatreCore\Entity\Dvdtechnos;
  7. use TheatreCore\Entity\Dvdzones;
  8. use TheatreCore\Entity\Multimedias;
  9. use TheatreCore\Traits\TheatreTrait;
  10. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  11. use Doctrine\Persistence\ManagerRegistry;
  12. use Doctrine\ORM\Query;
  13. /**
  14.  * DvdsRepository
  15.  *
  16.  * This class was generated by the Doctrine ORM. Add your own custom
  17.  * repository methods below.
  18.  */
  19. class DvdsRepository extends ServiceEntityRepository
  20. {
  21.     use TheatreTrait {
  22.         getRelationsArray as protected getRelationsArrayTrait;
  23.         getLinkedObject as protected getLinkedObjectTrait;
  24.     }
  25.     // les relations
  26.     public $array_types = array('moviedirector''author''director''intervenant''comedien''tournage''spectacle''multimedia''production''editeur');
  27.     private $em;
  28.     public $__table;
  29.     public $__table_object;
  30.     public $__idtable;
  31.     public function __construct(ManagerRegistry $registryImages $images)
  32.     {
  33.         parent::__construct($registryDvds::class);
  34.         $this->__table $this->getClassMetadata()->getTableName();
  35.         $this->__table_object $this->getClassMetadata()->name;
  36.         $this->images $images;
  37.         $this->__idtable $this->getClassMetadata()->getSingleIdentifierFieldName();
  38. //        $this->__table = 'persons';
  39. //        $this->__table_object = '\\App\\Entity\\Persons';
  40.     }
  41.     //  {{{ findData()
  42.     /** Recherche des dvds
  43.      *
  44.      * Permet de rechercher des dvds en fonction de certains critères :
  45.      * la première lettre, un bout du nom, le type de multimedia, si il est en ligne ou pas
  46.      *
  47.      * @access  public
  48.      * @see     Theatre::find()
  49.      */
  50.     public function findData($publish null$keywords null$idobject null$object null)
  51.     {
  52.         // requete perso
  53.         $query null;
  54.         $con $this->getEntityManager();
  55.         $query $con->getRepository(Dvds::class)->createQueryBuilder('e');
  56.         if ($this->getCount()) {
  57.             $query->select('COUNT(e.iddvd)');
  58.             $this->setCount(false);
  59.             return $query;
  60.         }
  61.         // parametre
  62. //        if(isset($_REQUEST['iddvd']) && !empty($_REQUEST['iddvd'])) {
  63. //            $iddvd = $_REQUEST['iddvd'];
  64. //        }
  65. //
  66. //        if(isset($_REQUEST['keywords']) && $_REQUEST['keywords']!='nom' && !empty($_REQUEST['keywords'])) {
  67. //            $keywords = $_REQUEST['keywords'];
  68. //        }
  69. //
  70. //        if(isset($_REQUEST['publish']) && !empty($_REQUEST['publish'])) {
  71. //            $publish = $_REQUEST['publish'];
  72. //        }
  73. //
  74. //        //recherche stricte par id
  75. //        if(!empty($iddvd)) {
  76. //            $this->whereAdd($this->__table.'.'.$this->__idtable.'='.((int)$iddvd));
  77. //        }
  78. //
  79. //        // mots cles
  80. //        if (!empty($keywords)) {
  81. //            $this->whereAdd($this->__table.'.title LIKE \'%'.$this->escape($keywords).'%\'');
  82. //        }
  83. //
  84. //        // selectionne les fiches hors ligne
  85. //        if (!empty($publish) && $publish=='no') {
  86. //            $this->whereAdd($this->__table.'.publish=0');
  87. //        }
  88.         // on lance la recherche
  89.         $this->specialQuery($query);
  90.     }
  91.     // }}}
  92.     //  {{{ setToArray()
  93.     /** Liste des multimedias dans un tableau associatif
  94.      *
  95.      * Tableau associatif notament utilisé pour lister les informations sur les multimedias
  96.      * Utile pour générer les tableaux HTML de listes de multimedias
  97.      *
  98.      * @access  public
  99.      * @return  array
  100.      * @see     findData()
  101.      */
  102.     public function setToArray($spec true)
  103.     {
  104.         if ($spec == true) {
  105.             $this->findData();
  106.         }
  107.         $values = array();
  108.         $color null;
  109.         $nb 0;
  110.         while ($this->fetch()) {
  111.             // valeurs de l'enregistrement
  112.             $values[$nb] = $this->getInfosDvd();
  113.             // couleur de ligne alternative
  114.             $color $this->colorAlternate($color);
  115.             $values[$nb]['colorline'] = $color;
  116.             $values[$nb]['id'] = $this->iddvd;
  117.             $nb++;
  118.         }
  119.         return $values;
  120.     }
  121.     // }}}
  122.     //  {{{ orderByDefaut()
  123.     /** Classement par défaut
  124.      *
  125.      * Défini le tri par défaut pour les requêtes de type SELECT
  126.      *
  127.      * @access public
  128.      * @return string
  129.      */
  130.     public function orderByDefaut($order null)
  131.     {
  132.         // tri par défaut
  133.         if (empty($order)) {
  134.             $order 'iddvd';
  135.         }
  136.         return $order;
  137.     }
  138.     // }}}
  139.     //  {{{ getInfosDvd()
  140.     /** Informations sur un dvd
  141.      *
  142.      * @access public
  143.      * @param int $iddvd numero de la fiche DVD
  144.      * @return array  les infos sous forme de tableau
  145.      */
  146.     public function getInfosDvd($iddvd null$params_data = array(), $params_display = array())
  147.     {
  148.         $conn $this->getEntityManager();
  149.         $infos = array();
  150.         ////////////// infos de la table
  151.         if (!isset($this->iddvd) || empty($this->iddvd)) {
  152.             if (!empty($iddvd)) {
  153.                 if (!$infos $this->get($iddvd)) {
  154.                     return array();
  155.                 }
  156.             }
  157.         } else {
  158.             $infos $this->createQueryBuilder('e')
  159.                 ->select('e')
  160.                 ->andWhere('e.iddvd = :iddvd')
  161.                 ->setParameter('iddvd'$iddvd)
  162.                 ->getQuery()
  163.                 ->getSingleResult(Query::HYDRATE_ARRAY);
  164.             /*$infos = array(
  165.                 'iddvd' => $this->iddvd,
  166.                 'title' => $this->title,
  167.                 'time_movie' => $this->time_movie,
  168.             );*/
  169.         }
  170.         // retourne toutes les infos liées
  171.         if (!empty($params_data['all'])) {
  172.             $recordedDvd $this->createQueryBuilder('e')
  173.                 ->where('e.iddvd = :iddvd')
  174.                 ->setParameter('iddvd'$iddvd)
  175.                 ->getQuery()
  176.                 ->getSingleResult();
  177.             $recordedIdDvdzone $recordedDvd->getIddvdzone()->getIddvdzone();
  178.             $recordedIdDvdformat $recordedDvd->getIddvdformat()->getIddvdformat();
  179.             $recordedIdDvdtechno $recordedDvd->getIddvdtechno()->getIddvdtechno();
  180.             // les infos zone, techno, format...
  181.             foreach (array('zone''techno''format') as $t) {
  182.                 if (!empty(${'recordedIdDvd' $t})) {
  183.                     $infos['iddvd' $t] = ${'recordedIdDvd' $t};
  184.                 }
  185.                 if (!empty($infos['iddvd' $t])) {
  186.                     //$f = getDvd.$t;
  187.                     $infos[$t] = $conn->getRepository('TheatreCore\Entity\Dvd' $t 's')->{'getDvd' $t}($infos['iddvd' $t]);
  188.                 }
  189.             }
  190.             // les ralations
  191.             foreach ($this->array_types as $t) {
  192.                 $infos['dvd_' $t] = $this->noPunct($this->getLinkedObjectTrait($this->getRelationsArray('dvd_' $t), $iddvd'dvd_' $t'dvds'));
  193.             }
  194.             // voir si VOD
  195.             if (!empty($infos['dvd_multimedia'])) {
  196.                 foreach ($infos['dvd_multimedia'] as $km => $vm) {
  197.                     if (!empty($vm['price'])) {
  198.                         $infos['vod'] = $vm;
  199.                         break;
  200.                     }
  201.                 }
  202.             }
  203.             if (!empty($params_display['vignette_format'])) {
  204.                 $infos['vignette'] = $this->getVignetteDvd($iddvd$params_display['vignette_format']);
  205.             } else {
  206.                 $infos['vignette'] = $this->getVignetteDvd($iddvd);
  207.             }
  208.         }
  209.         // récupèrer le détail des éléments multimedias associés
  210.         if (!empty($params_data['multimedias']) && !empty($infos['dvd_multimedia'])) {
  211.             $multimedias $conn->getRepository(Multimedias::class);
  212.             foreach ($infos['dvd_multimedia'] as $m) {
  213.                 $ids_multimedia[] = $m['idmultimedia'];
  214.                 $infos['multimedias'][$m['idmultimedia']] = $multimedias->getInfosMultimedia($m['idmultimedia']);
  215.             }
  216.             $infos['multimedias'] = $multimedias->getListMultimedias(array(
  217.                 'where' => array(array('multimedias''idmultimedia'$ids_multimedia)),
  218.                 'dbg' => array('rech''Vidéos liées au DVD'),
  219.             ));
  220.         }
  221.         if (!empty($infos['comments'])) {
  222.             $infos['description'] = $this->wikiTransform($infos['comments']);
  223.         }
  224.         if (!empty($infos['date_shooting']) && $infos['date_shooting'] != '0000-00-00 00:00:00') {
  225.             $infos['date_shooting_str'] = $this->getFormeDate($infos['date_shooting'], "%B %Y"true);
  226.         }
  227.         if (!empty($infos['place_shooting']) || !empty($infos['dvd_tournage'])) {
  228.             $infos['place_shooting_exist'] = true;
  229.         }
  230.         return $infos;
  231.     }
  232.     // }}}
  233.     //  {{{ getItemsList()
  234.     /** Liste des items pour les champs relationnels
  235.      *
  236.      * Retourne un tableau associatif contenant la liste des items d'une relation
  237.      *
  238.      * @access  public
  239.      * @param string $type Ce qu'on recherche
  240.      * @param string $idtext L'id de l'objet
  241.      * @return  array
  242.      */
  243.     public function getItemsList($iddvd$type)
  244.     {
  245.         // fausse relation
  246.         if ($type == 'add_from_spectacle') {
  247.             return array();
  248.         }
  249.         $type_search str_replace('dvd_'''$type);
  250.         if (in_array($type_search$this->array_types)) {
  251.             return $this->getLinkedObject($this->getRelationsArray($type), $iddvd$type'dvds');
  252.         } else {
  253.             return 'Aucune fonction de recherche pour le type <strong>' $type '</strong> dans la méthode !';
  254.         }
  255.     }
  256.     // }}}
  257.     //  {{{ getRelationsArray()
  258.     /** Tableau des relations
  259.      *
  260.      * @access  public
  261.      * @param string|int $type le type de champ
  262.      */
  263.     public function getRelationsArray($type null)
  264.     {
  265.         // récupérer les relations communes
  266.         $array_types $this->getRelationsArrayTrait('all');
  267.         $persons = array(
  268.             26 => array('moviedirector''Réalisateur(s)'),
  269.             21 => array('author''Auteur(s)'),
  270.             => array('director''Metteur(s) en scène'),
  271.             => array('comedien''Acteur(s)'),
  272.             25 => array('intervenant''Intervenant(s)'),
  273.         );
  274.         $array_types = array(
  275.             'dvd_spectacle' => array(
  276.                 'type_join' => 'multiple',
  277.                 'dest_table' => 'spectacles',
  278.                 'fields' => array('idspectacle''title''url_clean'),
  279.                 'join_table' => 'dvd_spectacle',
  280.                 'hide_relation' => true,
  281.                 'silent_delete_relation' => true,
  282.                 'description' => 'Spectacle(s) associé(s) à ce DVD',
  283.             ),
  284.             'dvd_multimedia' => array(
  285.                 'type_join' => 'multiple',
  286.                 'dest_table' => 'multimedias',
  287.                 'fields' => array('idmultimedia''sujet_titre''url_clean''status''price'),
  288.                 'join_table' => 'dvd_multimedia',
  289.                 'hide_relation' => true,
  290.                 'silent_delete_relation' => true,
  291.                 'description' => 'Multimédia(s) associé(s) à ce DVD',
  292.             ),
  293.             'dvd_tournage' => array(
  294.                 'type_join' => 'multiple',
  295.                 'dest_table' => 'contacts',
  296.                 'fields' => array('idcontact''organisation''firstname''lastname''url_clean'),
  297.                 'join_table' => 'dvd_contact',
  298.                 'where' => ' AND j2.idrole=27'// idrole sur la table dvd_contact
  299.                 'hide_relation' => true,
  300.                 'silent_delete_relation' => true,
  301.                 'description' => 'Lieu(x) de tournage associé(s) à ce DVD',
  302.             ),
  303.             'dvd_editeur' => array(
  304.                 'type_join' => 'multiple',
  305.                 'dest_table' => 'contacts',
  306.                 'fields' => array('idcontact''organisation''firstname''lastname''url_clean'),
  307.                 'join_table' => 'dvd_contact',
  308.                 'where' => ' AND j2.idrole=28'// idrole sur la table dvd_contact
  309.                 'hide_relation' => true,
  310.                 'silent_delete_relation' => true,
  311.                 'description' => 'Editeur(x) associé(s) à ce DVD',
  312.             ),
  313.             'dvd_production' => array(
  314.                 'type_join' => 'multiple',
  315.                 'dest_table' => 'contacts',
  316.                 'fields' => array('idcontact''organisation''firstname''lastname''url_clean'),
  317.                 'join_table' => 'dvd_contact',
  318.                 'where' => ' AND j2.idrole=17'// idrole sur la table dvd_contact
  319.                 'hide_relation' => true,
  320.                 'silent_delete_relation' => true,
  321.                 'description' => 'Production',
  322.             )
  323.         );
  324.         foreach ($persons as $k => $v) {
  325.             $array_types['dvd_' $v[0]] = array(
  326.                 'type_join' => 'multiple',
  327.                 'dest_table' => 'persons',
  328.                 'fields' => array('idperson''lastname''firstname''url_clean''valid'),
  329.                 'where' => ' AND j2.idrole=' $k// idrole sur la table dvd_person
  330.                 'join_table' => 'dvd_person',
  331.                 'hide_relation' => true,
  332.                 'silent_delete_relation' => true,
  333.                 'description' => $v[1] . ' associé(s) à ce DVD',
  334.             );
  335.         }
  336.         if (!empty($array_types[$type])) {
  337.             $array_types[$type]['type'] = $type;
  338.             return $array_types[$type];
  339.         } else {
  340.             return $array_types;
  341.         }
  342.     }
  343.     // }}}
  344.     //  {{{ getDvdformats()
  345.     /** Récupérer les formats DVD
  346.      *
  347.      * @access public
  348.      * @return array  les infos sous forme de tableau
  349.      */
  350.     public function getDvdformats()
  351.     {
  352.         return $this->getEntityManager()->getRepository(Dvdformats::class)->getDvdformats();
  353.     }
  354.     // }}}
  355.     //  {{{ getDvdzones()
  356.     /** Récupérer les zones
  357.      *
  358.      * @access public
  359.      * @return array  les infos sous forme de tableau
  360.      */
  361.     public function getDvdzones($select_list true)
  362.     {
  363.         return $this->getEntityManager()->getRepository(Dvdzones::class)->getDvdzones($select_list);
  364.     }
  365.     // }}}
  366.     //  {{{ getDvdtechnos()
  367.     /** Récupérer les technos DVD
  368.      *
  369.      * @access public
  370.      * @return array  les infos sous forme de tableau
  371.      */
  372.     public function getDvdtechnos($select_list true)
  373.     {
  374.         return $this->getEntityManager()->getRepository(Dvdtechnos::class)->getDvdtechnos($select_list);
  375.     }
  376.     // }}}
  377.     //  {{{ getVignetteDvd()
  378.     /** Récupére la vignette d'un DVD ou la crée si besoin
  379.      *
  380.      * @access   public
  381.      * param     int iddvd identifiant du dvd
  382.      * @return   string
  383.      */
  384.     public function getVignetteDvd($iddvd null$format = array())
  385.     {
  386.         if (empty($iddvd)) {
  387.             $iddvd $this->iddvd;
  388.         }
  389.         // par default : image normal 70px x 70px qualite 75
  390.         if (!empty($format)) {
  391.             $set_format $format;
  392.         } else {
  393.             $set_format = array('width' => $_ENV['VIGN_DVD_WIDTH'], 'height' => $_ENV['VIGN_DVD_HEIGHT'], 'direction' => 'thumb');
  394.         }
  395.         // generation par la classe Images
  396.         if (!isset($this->images)) {
  397.             $this->images = new Images();
  398.         }
  399.         $this->images->setVignetteFormat($set_format);
  400.         return $this->images->getVignetteObject($iddvd'dvds''class_pochette_dvd');
  401.     }
  402.     // }}}
  403.     //  {{{ getDvdsFromMultimedia()
  404.     /** Récupére les DVDs à partir d'un document multimedia
  405.      *
  406.      * @access   public
  407.      * @param int $idmultimedia Identifiant de la vidéo
  408.      * @param int $count_only compter seulement le nb de vidéo liées
  409.      * @return   array|int
  410.      */
  411.     public function getDvdsFromMultimedia($idmultimedia$count_only false)
  412.     {
  413.         $sql 'SELECT';
  414.         if ($count_only) {
  415.             $sql ' COUNT(*) ';
  416.         } else {
  417.             $sql .= ' * ';
  418.         }
  419.         $sql .= '
  420.             FROM dvd_multimedia dm, dvds d
  421.             WHERE dm.`iddvd`=d.`iddvd`
  422.             AND dm.`idmultimedia`=' . (int)$idmultimedia '
  423.             AND d.`publish`=1';
  424.         $list_dvds $this->db->queryAll($sql);
  425.         return $list_dvds;
  426.     }
  427.     // }}}
  428.     //  {{{ getSQLDvds()
  429.     /** Générer la requete standard pour des dvds
  430.      *
  431.      * $params = array(
  432.      *  'select' => champs en plus pour le select,
  433.      *  'from' => champs en plus pour le from,
  434.      *  'where' => paramètres en plus le where,
  435.      *  'order' => classement des résultats,
  436.      *  'limit' => limiter le nb de résultats array(debut,fin), (all pour pas de limit)
  437.      * )
  438.      * $special = array(
  439.      *  'select_by_text_or_adaptation' => text et adaptation,
  440.      *  'prochains' => true = date dans le future, un entier = fait un between
  441.      *  'anciens' =>
  442.      *  'join' => jointure gauche sur contacts et schedules
  443.      * )
  444.      *
  445.      *
  446.      * @access   public
  447.      * @param array $params Les paramètres pour la requete
  448.      * @param array $special Les paramètres supplémentaires
  449.      * @param bool $debug afficher la requête TODO
  450.      * @return   string
  451.      */
  452.     public function getSQLDvds($query = array(), $debug false)
  453.     {
  454.         // on prepare les tableaux
  455.         foreach (array('select''from''where''order''group''limit') as $t) {
  456.             if (!empty($query[$t])) {
  457.                 if (!is_array($query[$t])) {
  458.                     $query[$t][] = $query[$t];
  459.                 } else {
  460.                     $query[$t] = $query[$t];
  461.                 }
  462.             } else {
  463.                 $query[$t] = array();
  464.             }
  465.         }
  466.         // champs par défaut
  467.         if (empty($query['count_only'])) {
  468.             $this->addSQLParams('select'$query, array(
  469.                 array('dvds' => '*')
  470.             ));
  471.         } else {
  472.             $this->addSQLParams('from'$query, array(
  473.                 'dvds',
  474.             ));
  475.         }
  476.         // publié ou pas
  477.         if (empty($query['publish']) && $_ENV['CHECK_IF_ONLINE']) {
  478.             $this->addSQLParams('where'$query, array(
  479.                 array('dvds''publish'1)
  480.             ));
  481.         } elseif (!empty($query['publish'])) {
  482.             $this->addSQLParams('where'$query, array(
  483.                 array('dvds''publish'$query['publish'])
  484.             ));
  485.         }
  486.         // recherche par liaison via dvd_multimedia
  487.         if (!empty($query['special']['idmultimedias'])) {
  488.             $this->addSQLParams('from'$query, array(
  489.                 'dvd_multimedia',
  490.             ));
  491.             // jointure entre les 3 tables
  492.             $this->addSQLParams('join'$query, array(
  493.                 'dvds.`iddvd`' => 'dvd_multimedia.`iddvd`',
  494.             ));
  495.             $this->addSQLParams('where'$query, array(
  496.                 array('dvd_multimedia''idmultimedia'$query['special']['idmultimedias']),
  497.             ));
  498.         }
  499.         // recherche par VOD
  500.         if (!empty($query['special']['vods'])) {
  501.             $this->addSQLParams('from'$query, array(
  502.                 'dvd_multimedia',
  503.                 'dvd_spectacle',
  504.                 'multimedias',
  505.             ));
  506.             // jointure entre les 3 tables
  507.             $this->addSQLParams('join'$query, array(
  508.                 'dvds.`iddvd`' => 'dvd_multimedia.`iddvd`',
  509.                 'multimedias.`idmultimedia`' => 'dvd_multimedia.`idmultimedia`',
  510.             ));
  511.             // jointure entre les 3 tables
  512.             $this->addSQLParams('join'$query, array(
  513.                 'dvds.`iddvd`' => 'dvd_spectacle.`iddvd`',
  514.             ));
  515.             $this->addSQLParams('where'$query, array(
  516.                 array('multimedias''status'5),
  517.                 array('multimedias''publish'1),
  518.             ));
  519.         }
  520.         // recherche par liaison via dvd_person
  521.         if (!empty($query['special']['idpersons'])) {
  522.             $this->addSQLParams('from'$query, array(
  523.                 'dvd_person',
  524.             ));
  525.             // jointure entre les 3 tables
  526.             $this->addSQLParams('join'$query, array(
  527.                 'dvds.`iddvd`' => 'dvd_person.`iddvd`',
  528.             ));
  529.             $this->addSQLParams('where'$query, array(
  530.                 array('dvd_person''idperson'$query['special']['idpersons']),
  531.             ));
  532.             // ajouter le role
  533.             if (!empty($query['special']['idrole_person'])) {
  534.                 $this->addSQLParams('where'$query, array(
  535.                     array('dvd_person''idrole'$query['special']['idrole_person']),
  536.                 ));
  537.             }
  538.         }
  539.         // recherche par liaison via dvd_contact
  540.         if (!empty($query['special']['idcontacts'])) {
  541.             $this->addSQLParams('from'$query, array(
  542.                 'dvd_contact',
  543.             ));
  544.             // jointure entre les 3 tables
  545.             $this->addSQLParams('join'$query, array(
  546.                 'dvds.`iddvd`' => 'dvd_contact.`iddvd`',
  547.             ));
  548.             $this->addSQLParams('where'$query, array(
  549.                 array('dvd_contact''idcontact'$query['special']['idcontacts']),
  550.             ));
  551.             // ajouter le role
  552.             if (!empty($query['special']['idrole_contact'])) {
  553.                 $this->addSQLParams('where'$query, array(
  554.                     array('dvd_contact''idrole'$query['special']['idrole_contact']),
  555.                 ));
  556.             }
  557.         }
  558.         // recherche par liaison via dvd_spectacle
  559.         if (!empty($query['special']['idspectacles'])) {
  560.             $this->addSQLParams('from'$query, array(
  561.                 'dvd_spectacle',
  562.             ));
  563.             // jointure entre les 3 tables
  564.             $this->addSQLParams('join'$query, array(
  565.                 'dvds.`iddvd`' => 'dvd_spectacle.`iddvd`',
  566.             ));
  567.             $this->addSQLParams('where'$query, array(
  568.                 array('dvd_spectacle''idspectacle'$query['special']['idspectacles']),
  569.             ));
  570.         }
  571.         return $this->getSQLObject($query);
  572.     }
  573.     // }}}
  574.     //  {{{ getListDvds()
  575.     /** Retourne des listes de dvds
  576.      *
  577.      * Retourne des listes de dvd au format "standard""
  578.      *
  579.      * @access   public
  580.      * @param array $params_sql paramètre pour la requete SQL
  581.      * @param array $format_vignette de la vignette si pas standard
  582.      * @param array $params_display paramètre pour l'affichage
  583.      * @return   array
  584.      */
  585.     public function getListDvds($params_sql null$format_vignette = array(), $params_display = array())
  586.     {
  587.         // si pas de tableau
  588.         if (!isset($params_sql['special'])) {
  589.             $params_sql['special'] = array();
  590.         }
  591.         if (!isset($params_sql['params'])) {
  592.             $params_sql['params'] = array();
  593.         }
  594.         // construction de la requête avec le passage de paramètres
  595.         $sql $this->getSQLDvds($params_sql);
  596.         // vignettes
  597.         if (empty($format_vignette['vignette_format'])) {
  598.             $format_vignette['vignette_format'] = array('width' => $_ENV['VIGN_DVD_WIDTH'], 'height' => $_ENV['VIGN_DVD_HEIGHT'], 'direction' => 'thumb');
  599.         }
  600.         // paramètre de debug
  601.         $dbg = (empty($params_sql['dbg'])) ? array() : $dbg $params_sql['dbg'];
  602.         // executer la requete
  603.         $this->query($sql$dbg);
  604.         $videos = array();
  605.         // donnée entières ?
  606.         if (empty($params_display['alldata'])) {
  607.             $params_display['alldata'] = false;
  608.         }
  609.         // debug
  610.         $start_boucle microtime(true);
  611.         $dvds = array();
  612.         $datas $this->query($sql);
  613.         // on boucle
  614.         foreach ($datas as $data) {
  615.             $this->loadResult($data);
  616.             // le total
  617.             if (!empty($params_sql['count_only'])) {
  618.                 return $this->total;
  619.             }
  620.             $iddvd $this->iddvd;
  621.             if (!empty($params_sql['fields'])) {
  622.                 foreach ($params_sql['fields'] as $f) {
  623.                     $dvds[$iddvd][$f] = $this->$f;
  624.                 }
  625.             } else {
  626.                 $dvds[$iddvd] = $this->getInfosDvd($iddvd, array('all' => true), $format_vignette);
  627.                 if (empty($dvds[$iddvd]['comments'])) {
  628.                     $dvds[$iddvd]['description'] = $this->wikiTransform($this->comments);
  629.                 }
  630. //                $dvds[$iddvd]['description_courte'] = $this->cutSentence(strip_tags($dvds[$iddvd]['description']),45,true);
  631.                 $dvds[$iddvd]['dateinsert'] = $this->dateinsert;
  632.             }
  633.         }
  634.         // debug de la boucle
  635. //        if($this->isTraceMode('list_object')) {
  636. //            $this->setTraceInfos(array(
  637. //                'execution_time_boucle' => microtime(true) - $start_boucle,
  638. //                'nb_occurence' => count($dvds),
  639. //                'dbg' => $dbg,
  640. //            ));
  641. //        }
  642.         $this->free();
  643.         return $dvds;
  644.     }
  645.     // }}}
  646.     //  {{{ getObjectTitle()
  647.     /** Infos de l'item recherché
  648.      *
  649.      * Affichage standard du titre de l'objet
  650.      *
  651.      * @access public
  652.      * @param int $idobject Identifiant de l'item
  653.      * @param array $infos_object Informations pour construire le titre
  654.      * @param array $params Paramétres supplémentaires
  655.      * @return string
  656.      */
  657.     public function getObjectTitle($idobject null$infos_object = array(), $params = array())
  658.     {
  659.         $title '';
  660.         if (!$idobject) {
  661.             $idobject $this->iddvd;
  662.         }
  663.         // champs
  664.         $fields = array('iddvd''title''url_clean');
  665.         if (!empty($infos_object)) {
  666.             foreach ($fields as $k => $v) {
  667.                 if (array_key_exists($v$infos_object)) {
  668.                     $$v $infos_object[$v];
  669.                 }
  670.             }
  671.         } else {
  672.             //charger les infos que si necessaire
  673.             if (empty($this->title)) {
  674. //                $this->selectAdd();
  675. //                $this->selectAdd(join($fields, ','));
  676.                 $datas $this->get($idobject);
  677.             }
  678.             $this->loadResult($datas);
  679. //            foreach($fields as $k=>$v) {
  680. //                if(isset($this->$v) && $this->$v!='') {
  681. //                    $$v = trim($this->$v);
  682. //                }
  683. //            }
  684.         }
  685.         return $title;
  686.     }
  687.     // }}}
  688.     //  {{{ getListSearch()
  689.     /** Liste des dvds
  690.      *
  691.      * Pour les champs Ajax de relations et les recherches diverses
  692.      *
  693.      * @access  public
  694.      * @param string $lettres Pour la recherche alphabetique
  695.      * @param string $type Pour le type recherche (editeurs, revues...)
  696.      * @param string $keywords Recherche par mots cles
  697.      * @return  array
  698.      */
  699.     public function getListSearch($lettre$type null$keywords null)
  700.     {
  701.         $sql 'SELECT ' $this->__idtable ', title
  702.                  FROM ' $this->__table '
  703.                  WHERE 1 ';
  704.         // selection par ordre alpha
  705.         if (!empty($lettre) && $lettre != 'tous') {
  706.             $sql_where[] = array('LOWER(LEFT(LTRIM(title),1))=\'' $this->escape($lettre) . '\'');
  707.         }
  708.         // recherche avec un mot cle
  709.         $list $this->splitKeywords($keywords);
  710.         if ($list) {
  711.             if (!empty($list[$this->IDSTR])) {
  712.                 // mots clés
  713.                 foreach ($list[$this->IDSTR] as $s) {
  714.                     $sql_more_name[] = 'title LIKE \'%' $s '%\'';
  715.                 }
  716.                 $sql_where[] = array('(' join(' OR '$sql_more_name) . ')');
  717.             }
  718.             if (!empty($list[$this->IDNUM])) {
  719.                 // recherche par numéro d'id pour les mots clés numériques
  720.                 $sql_where[] = array('iddvd IN (' implode(','$list[$this->IDNUM]) . ')''OR');
  721.             }
  722.         }
  723.         foreach ($sql_where as $k => $v) {
  724.             if (!empty($v[1])) {
  725.                 $sql .= ' ' $v[1] . ' ' $v[0];
  726.             } else {
  727.                 $sql .= ' AND ' $v[0];
  728.             }
  729.         }
  730.         $sql .= ' ORDER BY title';
  731.         $this->query($sql);
  732.         $r = array();
  733.         while ($this->fetch()) {
  734.             $r[$this->iddvd] = $this->title;
  735.             // si trouvé par id, on l'affiche en fin de titre
  736.             if (!empty($list[$this->IDNUM]) && in_array($this->iddvd$list[$this->IDNUM])) {
  737.                 $r[$this->iddvd] .= ' - n°' $this->iddvd;
  738.             }
  739.         }
  740.         $this->free();
  741.         return $r;
  742.     }
  743.     // }}}
  744.     //  {{{ countDvds()
  745.     /** Nombre de DVD
  746.      *
  747.      * Compter le nb de DVD
  748.      *
  749.      * @access  public
  750.      * @return  int
  751.      */
  752.     public function countDvds($object null$idobject null)
  753.     {
  754.         if (!empty($object) && !empty($idobject)) {
  755.             $object substr($object0, -1);
  756.             $sql_count '
  757.                 SELECT COUNT(DISTINCT(d.`' $this->__idtable '`)) as total
  758.                 FROM ' $this->__table ' d, dvd_' $object ' do
  759.                 WHERE d.`publish`=1
  760.                 AND do.`iddvd`= d.`iddvd`
  761.                 AND do.`id' $object '`=' . (int)$idobject;
  762.         } else {
  763.             $sql_count '
  764.                 SELECT COUNT(DISTINCT(' $this->__idtable ')) as total
  765.                 FROM ' $this->__table '
  766.                 WHERE publish=1';
  767.         }
  768.         $total $this->queryOne($sql_count);
  769.         if ($total) {
  770.             return $total;
  771.         } else {
  772.             return null;
  773.         }
  774.     }
  775.     // }}}
  776. }