|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
Citation :Par contre, faudra vérifier ce que tu envois dans les champs de type date, il est utilisé pour une date c'est à dire YYYY-MM-JJ, si c'est pour une année seul, il t'enverra promener Ah oui t'a raison, la date ne s'affiche pas correctement dans mysql: OK j'ai pigé, c'est bon j'avais mis format date dans la table.
Posté le : 24/12/2014 20:31
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
OUAH La classe mon code fonctionne, 7 requête ouf c'était long. j'arrive pas à faire mon test grrrrrr 9a allait bien maids la ça y est ça me prend le choux, rien ne marche pour faire le test: La ça me renvoi tjrs déja présent dans la bdd
<?php
/**
* $Id: alloinfos.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
// Créer l'objet
$helper = new AlloHelper;
//Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.
$code = 192186;
$profile = 'small';
//Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.
try
{
// Envoi de la requête
$data = $helper->movie( $code, $profile );
//Convertir la durée en hh:mm:ss
$total = $data->runtime; //Nombre de secondes
$heure = intval(abs($total / 3600));
$total = $total - ($heure * 3600);
$minute = intval(abs($total / 60));
$total = $total - ($minute * 60);
$seconde = $total;
// Afficher les infos
echo "<div class='xoopstube_cadreblock'><b><font color=#ff7400>Code du film:</font></b> ", $data->code, "<br />n";
echo "<b><font color=#ff7400>Titre du film:</font></b> ", $data->title, "<br />n";
echo "<b><font color=#ff7400>pays:</font></b> ", $data->nationality[0]['$'], "<br />n";
echo "<b><font color=#ff7400>pays_id:</font></b> ", $data->nationality[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Année de production:</font></b> ", $data->productionYear, "<br />n";
echo "<b><font color=#ff7400>Durée:</font></b> $heure H : $minute min : $seconde sec <br />n";
echo "<b><font color=#ff7400>Date de sortie:</font></b> ", $data->release['releaseDate'], "<br />n";
echo "<b><font color=#ff7400>Realisateur:</font></b> ", $data->castingShort['directors'], "<br />n";
echo "<b><font color=#ff7400>Acteur:</font></b> ", $data->castingShort['actors'], "<br />n";
echo "<b><font color=#ff7400>Genre:</font></b> ", $data->genre[0]['$'], "<br />n";
echo "<b><font color=#ff7400>Genre_id:</font></b> ", $data->genre[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Synopsis:</font></b> ", $data->synopsisShort, "<br /></div>n";
// Afficher toutes les données
//print_r($data->getArray());
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
$code_film = $xtubemyts->addslashes(ltrim($data->code));
$title = $xtubemyts->addslashes(ltrim($data->title));
$pays_id = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$annee = $xtubemyts->addslashes(ltrim($data->productionYear));
$duree = $xtubemyts->addslashes(ltrim($data->runtime));
$date_sortie = $xtubemyts->addslashes(ltrim($data->release['releaseDate']));
$nom_realisateur = $xtubemyts->addslashes(ltrim($data->castingShort['directors']));
$synopsis = $xtubemyts->addslashes(ltrim($data->synopsisShort));
$nom_acteur = $xtubemyts->addslashes(ltrim($data->castingShort['actors']));
$nom_genre = $xtubemyts->addslashes(ltrim($data->genre[0]['$']));
$film_code = $xtubemyts->addslashes(ltrim($data->code));
$genre_id = $xtubemyts->addslashes(ltrim($data->genre[0]['code']));
$id_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$nom_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['$']));
// Enregistrement des infos dans la base si le code n'existe pas déja..
$result = $xoopsDB->query(
"SELECT COUNT(*) FROM FILM WHERE code_film = " . $code_film);
list($count) = $xoopsDB->fetchRow($result);
if ($result == 0) {
$sql = 'INSERT INTO FILM'
. ' (id_film, code_film, titre, pays_id, annee, duree, date_sortie, nom_realisateur, synopsis) ';
$sql .= " VALUES ('', $code_film, '$title', $pays_id, '$annee', $duree, '$date_sortie','$nom_realisateur', '$synopsis')";
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql2 = 'INSERT INTO ACTEUR'
. ' (id_acteur, nom_acteur) ';
$sql2 .= " VALUES ('', '$nom_acteur')";
if (!$result = $xoopsDB->query($sql2)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql3 = 'INSERT INTO GENRE'
. ' (id_genre, nom_genre) ';
$sql3 .= " VALUES ('', '$nom_genre')";
if (!$result = $xoopsDB->query($sql3)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql4 = 'INSERT INTO ACTEUR_FILM'
. ' (acteur_id, film_code) ';
$sql4 .= " VALUES ('', '$film_code')";
if (!$result = $xoopsDB->query($sql4)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql5 = 'INSERT INTO GENRE_FILM'
. ' (genre_id, film_id) ';
$sql5 .= " VALUES ('$genre_id', '')";
if (!$result = $xoopsDB->query($sql5)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql6 = 'INSERT INTO PAYS'
. ' (id_pays, nom_pays) ';
$sql6 .= " VALUES ('', '$nom_pays')";
if (!$result = $xoopsDB->query($sql6)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql7 = 'INSERT INTO REALISATEUR'
. ' (id_realisateur, nom_realisateur) ';
$sql7 .= " VALUES ('', '$nom_realisateur')";
if (!$result = $xoopsDB->query($sql7)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
else {
echo '<h4>' . _MD_XTUBE_INSERT_INFOS_OK . '</h4>';
}
}else
{
echo '<h4>' . _MD_XTUBE_CODE_ALREADY_IN_BDD . '</h4>';
}
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
Posté le : 25/12/2014 00:36
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
J'ai essayé plusieurs truc , mais ça le fait pas
Ma requête me renvoi count(*) 4 dans mysql,
J'ai essayer avec :
if (count($count) == 0) marche pas
if ($count == 0) marche pas
avec un as nbr_code me renvoi nbr_code 4
Pareil, soit erreur de syntaxe, soit toujours 0 soit tjrs >0
J'ai essayé au moins 20 truc différent y'a rien qui me renvoi le résultat que je veut.prise de tête.
j'abandonne, j'en ai marre
Posté le : 25/12/2014 02:04
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
Mais non j'abandonne pas et d'ailleur j'ai réussi en changeant ma méthode, mais par contre c'est pas xoopsien mais ça marche. Verdict final ou presque pour alloinfos.php:
<?php
/**
* $Id: alloinfos.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
// Créer l'objet
$helper = new AlloHelper;
//Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.
$code = 1;
$profile = 'small';
//Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.
try
{
// Envoi de la requête
$data = $helper->movie( $code, $profile );
//Convertir la durée en hh:mm:ss
$total = $data->runtime; //Nombre de secondes
$heure = intval(abs($total / 3600));
$total = $total - ($heure * 3600);
$minute = intval(abs($total / 60));
$total = $total - ($minute * 60);
$seconde = $total;
// Afficher les infos
echo "<div class='xoopstube_cadreblock'><b><font color=#ff7400>Code du film:</font></b> ", $data->code, "<br />n";
echo "<b><font color=#ff7400>Titre du film:</font></b> ", $data->title, "<br />n";
echo "<b><font color=#ff7400>pays:</font></b> ", $data->nationality[0]['$'], "<br />n";
echo "<b><font color=#ff7400>pays_id:</font></b> ", $data->nationality[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Année de production:</font></b> ", $data->productionYear, "<br />n";
echo "<b><font color=#ff7400>Durée:</font></b> $heure H : $minute min : $seconde sec <br />n";
echo "<b><font color=#ff7400>Date de sortie:</font></b> ", $data->release['releaseDate'], "<br />n";
echo "<b><font color=#ff7400>Realisateur:</font></b> ", $data->castingShort['directors'], "<br />n";
echo "<b><font color=#ff7400>Acteur:</font></b> ", $data->castingShort['actors'], "<br />n";
echo "<b><font color=#ff7400>Genre:</font></b> ", $data->genre[0]['$'], "<br />n";
echo "<b><font color=#ff7400>Genre_id:</font></b> ", $data->genre[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Synopsis:</font></b> ", $data->synopsisShort, "<br /></div>n";
// Afficher toutes les données
//print_r($data->getArray());
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
$code_film = $xtubemyts->addslashes(ltrim($data->code));
$title = $xtubemyts->addslashes(ltrim($data->title));
$pays_id = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$annee = $xtubemyts->addslashes(ltrim($data->productionYear));
$duree = $xtubemyts->addslashes(ltrim($data->runtime));
$date_sortie = $xtubemyts->addslashes(ltrim($data->release['releaseDate']));
$nom_realisateur = $xtubemyts->addslashes(ltrim($data->castingShort['directors']));
$synopsis = $xtubemyts->addslashes(ltrim($data->synopsisShort));
$nom_acteur = $xtubemyts->addslashes(ltrim($data->castingShort['actors']));
$nom_genre = $xtubemyts->addslashes(ltrim($data->genre[0]['$']));
$film_code = $xtubemyts->addslashes(ltrim($data->code));
$genre_id = $xtubemyts->addslashes(ltrim($data->genre[0]['code']));
$id_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$nom_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['$']));
// Enregistrement des infos dans la base si le code n'existe pas déja..
$film = array (
'TITRE' => $title,
'CODE_FILM' => $code_film,
'PAYS' => $nom_pays,
'ANNEE' => $annee,
'GENRE' => $nom_genre,
'DUREE' => $duree,
'DATE_SORTIE' => $date_sortie,
'ACTEUR' => $nom_acteur,
'REALISATEUR' => $nom_realisateur,
'SYNOPSIS' => $synopsis
);
require ('connect.php');
require ('lib.php');
$id_film = existe_table($film['CODE_FILM'], 'FILM', 'ID_FILM', 'CODE_FILM');
if ($id_film==0){
$sql = 'INSERT INTO FILM'
. ' (id_film, code_film, titre, pays_id, annee, duree, date_sortie, nom_realisateur, synopsis) ';
$sql .= " VALUES ('', $code_film, '$title', $pays_id, '$annee', $duree, '$date_sortie','$nom_realisateur', '$synopsis')";
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql2 = 'INSERT INTO ACTEUR'
. ' (id_acteur, nom_acteur) ';
$sql2 .= " VALUES ('', '$nom_acteur')";
if (!$result = $xoopsDB->query($sql2)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql3 = 'INSERT INTO GENRE'
. ' (id_genre, nom_genre) ';
$sql3 .= " VALUES ('', '$nom_genre')";
if (!$result = $xoopsDB->query($sql3)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql4 = 'INSERT INTO ACTEUR_FILM'
. ' (acteur_id, film_code) ';
$sql4 .= " VALUES ('', '$film_code')";
if (!$result = $xoopsDB->query($sql4)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql5 = 'INSERT INTO GENRE_FILM'
. ' (genre_id, film_id) ';
$sql5 .= " VALUES ('$genre_id', '')";
if (!$result = $xoopsDB->query($sql5)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql6 = 'INSERT INTO PAYS'
. ' (id_pays, nom_pays) ';
$sql6 .= " VALUES ('', '$nom_pays')";
if (!$result = $xoopsDB->query($sql6)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql7 = 'INSERT INTO REALISATEUR'
. ' (id_realisateur, nom_realisateur) ';
$sql7 .= " VALUES ('', '$nom_realisateur')";
if (!$result = $xoopsDB->query($sql7)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
else {
echo '<h4>' . _MD_XTUBE_INSERT_INFOS_OK . '</h4>';
}
}else
{
echo '<h4>' . _MD_XTUBE_CODE_ALREADY_IN_BDD . '</h4>';
}
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
Y'a certainement moyen de faire plus cours, mais faut pas trop m'en demander non plus un. Le principal, c'est déja que ça fonctionne, c'est déja un miracle que j'y soit arrivé. Dans le lib on trouve la fonction suivante:
function existe_table($element, $table, $id_primaire_table, $nom_champ_element) {
// vérifie l'existence de l'élément $element dans la table $table et renvoie son id
// si l'élément n'existe pas, retourne 0
global $mysql_link;
$element=trim($element);
$sql = "SELECT $id_primaire_table FROM $table WHERE $nom_champ_element LIKE '$element'";
$result = mysql_query($sql, $mysql_link);
if (mysql_num_rows($result)==0) {
$id_primaire_table = 0;
}
else {
$row = mysql_fetch_row($result);
$id_primaire_table = $row[0];
mysql_free_result($result);
}
return($id_primaire_table);
}
Posté le : 25/12/2014 02:56
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
Salut Cette fois, j'ai presque terminé, il me reste 1 problème à résoudre: J'ai donc fait une première page pour soumettre le titre et chercher tout les résultats correspondant:
<?php
/**
* $Id: allocine.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
global $xoopsModule, $xtubemyts, $xoopsModuleConfig;
$alloform = new XoopsthemeForm(_MD_XTUBE_ALLOFORM_SEARCHTITLE, 'alloform', 'allosearch.php');
$alloform->addElement(new XoopsFormText(_MD_XTUBE_ALLOFILM_TITLE, 'filmtitle', 70, 255), false);
$button_tray = new XoopsFormElementTray('', '');
$button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$alloform->addElement($button_tray);
$alloform->display();
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
avec superman par exemple, ce qui nous envois à la 2e page avec les résultats:
<?php
/**
* $Id: allosearch.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
global $xoopsModule, $xtubemyts, $xoopsModuleConfig;
// Construct the object
$helper = new AlloHelper;
echo '<h1>' . _MD_XTUBE_ALLOFORM_TITLE . '</h1>';
?>
<html><div class="xoopstube_cadreblock" style="overflow: auto; margin-left: 5%; margin-right: 5%;"></html>
<?php
$profile = 'small';
if (isset($_POST['submit'])) {
try {
// Envoi de la requête
$film = $_POST['filmtitle'];
$arrayMovie = $helper->search($film)->getArray();
$nombreResult = $arrayMovie['count'];
echo "<div class='xoopstube_descrblock' style='float: left; display: inline-block;'> $nombreResult résultat(s) de film(s) pour <font color=orange>$film</font></div><br /><br />";
foreach ($arrayMovie['movie'] as $key) {
if (isset($key['title']))
echo '<div class="xoopstube_descrblock" style="float: left; width: 190px; margin: 5px;margin-bottom: 20px; padding: 2px; font-size: 90%; text-align: center;"><span><img src="' . $key['poster'] . '" style="width: 190px; height: 260px; align: left;"></img></span>
<span><font style="color: orange;">' . $key['title'] . '</font><br />
<form action="alloinfos.php" method="POST">
<input type="hidden" value="'.$key['code'].'" name="filmcode">
<input type="submit" value="Selectionner">
</form></span></div>';
else
echo $key['originalTitle'] . "<br>";
}
?>
<html></div><div class="xoopstube_cadreblock" style="overflow: auto; margin-left: 5%; margin-right: 5%; margin-top: 10px;"></html>
<?php
$nombreResultSerie = $arrayMovie['results'][4]['$'];
echo "<div class='xoopstube_descrblock' style='float: left; display: inline-block;'> $nombreResultSerie résultat(s) de série(s) pour <font color=orange>$film</font></div><br /><br />";
foreach ($arrayMovie['tvseries'] as $key) {
if (isset($key['title']))
echo '<div class="xoopstube_descrblock" style="float: left; width: 190px; margin: 5px;margin-bottom: 20px; padding: 2px; font-size: 90%; text-align: center;"><span><img src="' . $key['poster'] . '" style="width: 190px; height: 260px; align: left;"></img></span>
<span><font style="color: orange;">' . $key['title'] . '</font><br />
<form action="alloinfos.php" method="POST">
<input type="hidden" value="'.$key['code'].'" name="filmcode">
<input type="submit" value="Selectionner">
</form></span></div>';
else
echo $key['originalTitle'] . "<br>";
}
}
catch (ErrorException $error) {
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
}
?>
<html></div></html>
<?php
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
Il suffit de cliquer sur la description qui nous intéresse pour envoyer le code film, ce qui nous renvoi à une nouvelle page qui contient le détail des infos et les enregistre dans la base de données si elles n'étaient pas déja présente. Si les infos existaient déja, un message le précise:
<?php
/**
* $Id: alloinfos.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
// Créer l'objet
$helper = new AlloHelper;
//Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.
$code = $_POST['filmcode'];
$profile = 'medium';
//Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.
try
{
// Envoi de la requête
$data = $helper->movie( $code, $profile );
//Convertir la durée en hh:mm:ss
$total = $data->runtime; //Nombre de secondes
$heure = intval(abs($total / 3600));
$total = $total - ($heure * 3600);
$minute = intval(abs($total / 60));
$total = $total - ($minute * 60);
$seconde = $total;
// Afficher les infos
echo "<div class='xoopstube_cadreblock'><img src=", $data->poster, " style='width: 190px; height: 260px; align: left;'></img><br />n";
echo "<b><font color=#ff7400>Code du film:</font></b> ", $data->code, "<br />n";
echo "<b><font color=#ff7400>Titre du film:</font></b> ", $data->title, "<br />n";
echo "<b><font color=#ff7400>pays:</font></b> ", $data->nationality[0]['$'], "<br />n";
echo "<b><font color=#ff7400>pays_id:</font></b> ", $data->nationality[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Année de production:</font></b> ", $data->productionYear, "<br />n";
echo "<b><font color=#ff7400>Durée:</font></b> $heure H $minute min $seconde sec <br />n";
echo "<b><font color=#ff7400>Date de sortie:</font></b> ", $data->release['releaseDate'], "<br />n";
echo "<b><font color=#ff7400>Realisateur:</font></b> ", $data->castingShort['directors'], "<br />n";
echo "<b><font color=#ff7400>Acteur:</font></b> ", $data->castingShort['actors'], "<br />n";
echo "<b><font color=#ff7400>Genre:</font></b> ", $data->genre[0]['$'], "<br />n";
echo "<b><font color=#ff7400>Genre_id:</font></b> ", $data->genre[0]['code'], "<br />n";
echo "<b><font color=#ff7400>Synopsis:</font></b> ", $data->synopsis, "</div><br />n";
// Afficher toutes les données
//print_r($data->getArray());
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
$code_film = $xtubemyts->addslashes(ltrim($data->code));
$url_img = $xtubemyts->addslashes(ltrim($data->poster));
$title = $xtubemyts->addslashes(ltrim($data->title));
$pays_id = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$annee = $xtubemyts->addslashes(ltrim($data->productionYear));
$duree = $xtubemyts->addslashes(ltrim($data->runtime));
$date_sortie = $xtubemyts->addslashes(ltrim($data->release['releaseDate']));
$nom_realisateur = $xtubemyts->addslashes(ltrim($data->castingShort['directors']));
$synopsis = $xtubemyts->addslashes(ltrim($data->synopsis));
$nom_acteur = $xtubemyts->addslashes(ltrim($data->castingShort['actors']));
$nom_genre = $xtubemyts->addslashes(ltrim($data->genre[0]['$']));
$film_code = $xtubemyts->addslashes(ltrim($data->code));
$genre_id = $xtubemyts->addslashes(ltrim($data->genre[0]['code']));
$id_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$nom_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['$']));
// Enregistrement des infos dans la base si le code n'existe pas déja..
$film = array (
'TITRE' => $title,
'CODE_FILM' => $code_film,
'PAYS' => $nom_pays,
'ANNEE' => $annee,
'GENRE' => $nom_genre,
'DUREE' => $duree,
'DATE_SORTIE' => $date_sortie,
'ACTEUR' => $nom_acteur,
'REALISATEUR' => $nom_realisateur,
'SYNOPSIS' => $synopsis
);
require ('connect.php');
require ('lib.php');
$id_film = existe_table($film['CODE_FILM'], 'FILM', 'ID_FILM', 'CODE_FILM');
if ($id_film==0){
$sql = 'INSERT INTO FILM'
. ' (id_film, code_film, url_img, titre, pays_id, annee, duree, date_sortie, nom_realisateur, synopsis) ';
$sql .= " VALUES ('', $code_film, '$url_img', '$title', $pays_id, '$annee', $duree, '$date_sortie','$nom_realisateur', '$synopsis')";
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql2 = 'INSERT INTO ACTEUR'
. ' (id_acteur, nom_acteur) ';
$sql2 .= " VALUES ('', '$nom_acteur')";
if (!$result = $xoopsDB->query($sql2)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql3 = 'INSERT INTO GENRE'
. ' (id_genre, nom_genre) ';
$sql3 .= " VALUES ('', '$nom_genre')";
if (!$result = $xoopsDB->query($sql3)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql4 = 'INSERT INTO ACTEUR_FILM'
. ' (acteur_id, film_code) ';
$sql4 .= " VALUES ('', '$film_code')";
if (!$result = $xoopsDB->query($sql4)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql5 = 'INSERT INTO GENRE_FILM'
. ' (genre_id, film_id) ';
$sql5 .= " VALUES ('$genre_id', '')";
if (!$result = $xoopsDB->query($sql5)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql6 = 'INSERT INTO PAYS'
. ' (id_pays, nom_pays) ';
$sql6 .= " VALUES ('', '$nom_pays')";
if (!$result = $xoopsDB->query($sql6)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$sql7 = 'INSERT INTO REALISATEUR'
. ' (id_realisateur, nom_realisateur) ';
$sql7 .= " VALUES ('', '$nom_realisateur')";
if (!$result = $xoopsDB->query($sql7)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
else {
echo '<h4>' . _MD_XTUBE_INSERT_INFOS_OK . '</h4>';
}
}else
{
echo '<h4>' . _MD_XTUBE_CODE_ALREADY_IN_BDD . '</h4>';
}
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
Donc maintenant que tout est en base de données, je vais ajouter un bouton "ajouter les infos au formulaire de soumission".(que les infos étaient déja ou non dans la base de données.) Je sais comment faire pour envoyer 1 infos en post mais pour envoyer tout un tas d'infos en appuyant sur 1 bouton, la je sais pas. Comment je dois procéder pour tout envoyer d'un coup? les réceptionner pas de problème par contre. Ensuite je veut que le formulaire de soumission (submit.php) soit entièrement prérempli. De cette façon, il reste possible de les modifier. Par contre cette méthode va faire que les infos vont être réenregistré une deuxième fois sous forme de description pour le lien en question. Mais j'ai pas trop le choix, vu mes connaissances. 1 exemple: Comment on prérempli ce genre de champ?:
$sform->addElement(new XoopsFormText(_MD_XTUBE_FILETITLE, 'title', 70, 255, $title), TRUE);
AH j'ai trouvé un exemple:
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid);
$video_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
$lid = $video_array['lid'] ? $video_array['lid'] : 0;
$cid = $video_array['cid'] ? $video_array['cid'] : 0;
$title = $video_array['title'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['title']) : '';
$vidid = $video_array['vidid'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['vidid']) : '';
$publisher = $video_array['publisher'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['publisher']) : '';
$screenshot = $video_array['screenshot'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['screenshot']) : '';
$descriptionb = $video_array['description'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['description']) : '';
$published = $video_array['published'] ? $video_array['published'] : 0;
$expired = $video_array['expired'] ? $video_array['expired'] : 0;
$updated = $video_array['updated'] ? $video_array['updated'] : 0;
$offline = $video_array['offline'] ? $video_array['offline'] : 0;
$vidsource = $video_array['vidsource'] ? $video_array['vidsource'] : 0;
$ipaddress = $video_array['ipaddress'] ? $video_array['ipaddress'] : 0;
$notifypub = $video_array['notifypub'] ? $video_array['notifypub'] : 0;
$vidrating = $video_array['vidrating'] ? $video_array['vidrating'] : 1;
$time = $video_array['time'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['time']) : '0:00:00';
$keywords = $video_array['keywords'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['keywords']) : '';
$item_tag = $video_array['item_tag'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['item_tag']) : '';
$picurl = $video_array['picurl'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['picurl']) : 'http://';
J'ai juste besoin de mettre mes variables à la fin de chaque ligne?
Posté le : 26/12/2014 22:15
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
salut finalement j'ai laissé de côté l'idée de mettre dabord les infos dans la base car il aura duplication, donc passage direct de allosearch.php au fichier submit.php(une copie appellé différement), c'est bien plus simple.par contre je perd la recherche par acteur ou réalisateur que je voulais faire.pas grave. j'ai aussi enlevé les séries du fichier allosearch car il faut les traiter séparément. donc c tout bon mais j'ai quand même un soucis que j'arrive pas à résoudre pour le moment. j'ai donc mis ma présentation faite avec les variables dans une variable mais au résultat j'ai des antislash que j'arrive pas à enlever même avec stripslash, je pige pas pourquoi. le bout de code ajouté a submit_film.php
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
// Créer l'objet
$helper = new AlloHelper;
//Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.
$code = $_POST['filmcode'];
$profile = 'medium';
//Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.
try
{
// Envoi de la requête
$data = $helper->movie( $code, $profile, $filter );
//Convertir la durée en hh:mm:ss
$total = $data->runtime; //Nombre de secondes
$heure = intval(abs($total / 3600));
$total = $total - ($heure * 3600);
$minute = intval(abs($total / 60));
$total = $total - ($minute * 60);
$seconde = $total;
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
$code_film = $xtubemyts->addslashes(ltrim($data->code));
$url_img = $xtubemyts->addslashes(ltrim($data->poster));
$titre = $xtubemyts->addslashes(ltrim($data->title));
$pays_id = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$annee = $xtubemyts->addslashes(ltrim($data->productionYear));
$duree = $xtubemyts->addslashes(ltrim($data->runtime));
$date_sortie = $xtubemyts->addslashes(ltrim($data->release['releaseDate']));
$nom_realisateur = $xtubemyts->addslashes(ltrim($data->castingShort['directors']));
$synopsis = $xtubemyts->addslashes(ltrim($data->synopsis));
$nom_acteur = $xtubemyts->addslashes(ltrim($data->castingShort['actors']));
$nom_genre = $xtubemyts->addslashes(ltrim($data->genre[0]['$']));
$film_code = $xtubemyts->addslashes(ltrim($data->code));
$genre_id = $xtubemyts->addslashes(ltrim($data->genre[0]['code']));
$id_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['code']));
$nom_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['$']));
$bande_a = $xtubemyts->addslashes(ltrim($data->trailerEmbed));
$descrip = '<center>'.$synopsis.'<br />Date de sortie '.$date_sortie.'<br />Réalisé par '.$nom_realisateur.'<br />Avec '.$nom_acteur.'<br />Genre '.$nom_genre.'<br />Nationalité '.$nom_pays.'<br />'.$data->trailerEmbed.'<br /><img src="'.$url_img.'"></img></center>';
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid);
$video_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
$lid = $video_array['lid'] ? $video_array['lid'] : 0;
$cid = $video_array['cid'] ? $video_array['cid'] : 0;
$title = $video_array['title'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['title']) : ''.$titre.' [FilmFR]';
$vidid = $video_array['vidid'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['vidid']) : '';
$publisher = $video_array['publisher'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['publisher']) : '';
$screenshot = $video_array['screenshot'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['screenshot']) : '';
$descriptionb = $video_array['description'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['description']) : ''.$descrip.'';
$published = $video_array['published'] ? $video_array['published'] : 0;
$expired = $video_array['expired'] ? $video_array['expired'] : 0;
$updated = $video_array['updated'] ? $video_array['updated'] : 0;
$offline = $video_array['offline'] ? $video_array['offline'] : 0;
$vidsource = $video_array['vidsource'] ? $video_array['vidsource'] : 0;
$ipaddress = $video_array['ipaddress'] ? $video_array['ipaddress'] : 0;
$notifypub = $video_array['notifypub'] ? $video_array['notifypub'] : 0;
$vidrating = $video_array['vidrating'] ? $video_array['vidrating'] : 1;
$time = $video_array['time'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['time']) : ''.$heure.':'.$minute.':'.$seconde.'';
$keywords = $video_array['keywords'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['keywords']) : '';
$item_tag = $video_array['item_tag'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['item_tag']) : '.$nom_genre.';
$picurl = $video_array['picurl'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['picurl']) : '';
$sform = new XoopsThemeForm(_MD_XTUBE_SUBMITCATHEAD, 'storyform', xoops_getenv('PHP_SELF'));
$sform->setExtra('enctype="multipart/form-data"');
si je met stripslahes à la place de addslashes, rien ne se passe, tjrs les antislash. le résultat:(j'ai réussi a faire afficher la ba mais il reste des antislash BAH c'est bon j'ai réussi, fallait juste reprendre les valeurs d'origine : $data->synopsis et plus d'antislash. bon je crois que c'est tout bon, maintenant, je vais essayer d'optimiser un peu et de mettre au norme xoops. Je règle les derniers détails et je posterai les sources si ça intéresse quelqu'un on sait jamais.
Posté le : 27/12/2014 16:03
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
salut voici les sources, mais il y a tjrs un soucis,j'expliquerais après: formulaire de soumission titre:
<?php
/**
* $Id: allocine.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
global $xoopsModule, $xtubemyts, $xoopsModuleConfig;
$cid = intval(xtube_cleanRequestVars($_REQUEST, 'cid', 0));
if (FALSE == xtube_checkgroups($cid, 'XTubeSubPerm')) {
redirect_header('index.php', 1, _MD_XTUBE_NOPERMISSIONTOPOST);
exit();
}
$alloform = new XoopsthemeForm(_MD_XTUBE_ALLOFORM_SEARCHTITLE, 'alloform', 'allosearch.php');
$alloform->addElement(new XoopsFormText(_MD_XTUBE_ALLOFILM_TITLE, 'filmtitle', 70, 255), false);
$button_tray = new XoopsFormElementTray('', '');
$button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$alloform->addElement($button_tray);
$alloform->display();
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
page de sélection film:
<?php
/**
* $Id: allosearch.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
global $xoopsModule, $xtubemyts, $xoopsModuleConfig;
echo '<h1>' . _MD_XTUBE_ALLOFORM_TITLE . '</h1>';
?>
<html><div class="xoopstube_cadreblock" style="overflow: auto; margin-left: 5%; margin-right: 5%;"></html>
<?php
$helper = new AlloHelper;
$profile = 'small';
if(isset($_POST['filmtitle'])) {
$queryString = $_POST['filmtitle'];
if(strlen($queryString) > 0) {
// Les différents arguments de recherche :
$page = 1;
$count = 10;
$sortMovies = false;
$filter = array("movie");
$arrayMovie = $helper->search($queryString, $page, $count, $sortMovies, $filter)->getArray();
if (isset($arrayMovie['movie'])) {
foreach ($arrayMovie['movie'] as $key) {
if (isset($key['title'])) {
echo "<div class='xoopstube_descrblock' style='float: left; width: 190px; margin: 5px;margin-bottom: 20px; padding: 2px; font-size: 90%; text-align: center;'><span><img src=",$key['poster']," style='width: 190px; height: 260px; align: left;'></img></span>
<span><font style='color: orange;'>" .$key['title']."</font><br />
<form action='submit_film.php' method='POST'>
<input type='hidden' value=".$key['code']." name='filmcode'>
<input type='submit' value='Selectionner'>
</form></span></div>";
}
else {
$titreOr = $key['originalTitle'];
echo '<li onClick="fill(''.$titreOr.'');">'.$titreOr.'</li>';
}
}
}
}
else {
echo 'ERROR: There was a problem with the query.';
}
}
?>
<html></div></html>
<?php
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
include XOOPS_ROOT_PATH . '/footer.php';
?>
fichier submit_film.php (le problème est ici).la partie qui nous interresse commence aprés la section //Show disclaimer jusqu'au champ titre.
<?php
/**
* $Id: submit.php
* Module: XoopsTube
*/
include 'header.php';
include XOOPS_ROOT_PATH . '/header.php';
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
$mytree = new XoopsTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid');
global $xoopsModule, $xtubemyts, $xoopsModuleConfig;
$xoopsTpl->assign(
'xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . xoopstube_url . '/xtubestyle.css" />'
);
$cid = intval(xtube_cleanRequestVars($_REQUEST, 'cid', 0));
$lid = intval(xtube_cleanRequestVars($_REQUEST, 'lid', 0));
if (FALSE == xtube_checkgroups($cid, 'XTubeSubPerm')) {
redirect_header('index.php', 1, _MD_XTUBE_NOPERMISSIONTOPOST);
exit();
}
if (TRUE == xtube_checkgroups($cid, 'XTubeSubPerm')) {
if (xtube_cleanRequestVars($_REQUEST, 'submit', 0)) {
if (FALSE == xtube_checkgroups($cid, 'XTubeSubPerm')) {
redirect_header('index.php', 1, _MD_XTUBE_NOPERMISSIONTOPOST);
exit();
}
$submitter = (is_object($xoopsUser) && !empty($xoopsUser)) ? $xoopsUser->getVar('uid') : 0;
$vidsource = xtube_cleanRequestVars($_REQUEST, 'vidsource', 0);
$offline = xtube_cleanRequestVars($_REQUEST, 'offline', 0);
$notifypub = xtube_cleanRequestVars($_REQUEST, 'notifypub', 0);
$approve = xtube_cleanRequestVars($_REQUEST, 'approve', 0);
$vidrating = xtube_cleanRequestVars($_REQUEST, 'vidrating', 0);
$vidid = $xtubemyts->addslashes(ltrim($_POST['vidid']));
$title = $xtubemyts->addslashes(ltrim($_REQUEST['title']));
$descriptionb = $xtubemyts->addslashes(ltrim($_REQUEST['descriptionb']));
$publisher = $xtubemyts->addslashes(trim($_REQUEST['publisher']));
$time = $xtubemyts->addslashes(ltrim($_REQUEST['time']));
$keywords = $xtubemyts->addslashes(trim($_REQUEST['keywords']));
$item_tag = $xtubemyts->addslashes(ltrim($_REQUEST['item_tag']));
$picurl = $xtubemyts->addslashes(ltrim($_REQUEST['picurl']));
$date = time();
$publishdate = 0;
$ipaddress = $_SERVER['REMOTE_ADDR'];
if ($lid == 0) {
$status = 0;
$publishdate = 0;
$message = _MD_XTUBE_THANKSFORINFO;
if (TRUE == xtube_checkgroups($cid, 'XTubeAutoApp')) {
$publishdate = time();
$status = 1;
$message = _MD_XTUBE_ISAPPROVED;
}
$sql = 'INSERT INTO ' . $xoopsDB->prefix('xoopstube_videos')
. ' (lid, cid, title, vidid, submitter, publisher, status, date, hits, rating, votes, comments, vidsource, published, expired, offline, description, ipaddress, notifypub, vidrating, time, keywords, item_tag, picurl) ';
$sql .= " VALUES ('', $cid, '$title', '$vidid', '$submitter', '$publisher', '$status', '$date', 0, 0, 0, 0, '$vidsource', '$publishdate', 0, '$offline', '$descriptionb', '$ipaddress', '$notifypub', '$vidrating', '$time', '$keywords', '$item_tag', '$picurl')";
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . ' : ' . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$newid = mysql_insert_id();
// Add item_tag to Tag-module
if ($lid == 0) {
$tagupdate = xtube_tagupdate($newid, $item_tag);
} else {
$tagupdate = xtube_tagupdate($lid, $item_tag);
}
// Notify of new link (anywhere) and new link in category
$notification_handler = &xoops_gethandler('notification');
$tags = array();
$tags['VIDEO_NAME'] = $title;
$tags['VIDEO_URL']
=
XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&lid='
. $newid;
$sql = 'SELECT title FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE cid=' . $cid;
$result = $xoopsDB->query($sql);
$row = $xoopsDB->fetchArray($result);
$tags['CATEGORY_NAME'] = $row['title'];
$tags['CATEGORY_URL']
=
XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
if (TRUE == xtube_checkgroups($cid, 'XTubeAutoApp')) {
$notification_handler->triggerEvent('global', 0, 'new_video', $tags);
$notification_handler->triggerEvent('category', $cid, 'new_video', $tags);
redirect_header('index.php', 2, _MD_XTUBE_ISAPPROVED);
} else {
$tags['WAITINGFILES_URL']
= XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/newvideos.php';
$notification_handler->triggerEvent('global', 0, 'video_submit', $tags);
$notification_handler->triggerEvent('category', $cid, 'video_submit', $tags);
if ($notifypub) {
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notification_handler->subscribe('video', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
}
redirect_header('index.php', 2, _MD_XTUBE_THANKSFORINFO);
}
} else {
if (TRUE == xtube_checkgroups($cid, 'XTubeAutoApp') || $approve == 1) {
$updated = time();
$sql = "UPDATE " . $xoopsDB->prefix('xoopstube_videos')
. " SET cid=$cid, title='$title', vidid='$vidid', publisher='$publisher', updated='$updated', offline='$offline', description='$descriptionb', ipaddress='$ipaddress', notifypub='$notifypub', vidrating='$vidrating', time='$time', keywords='$keywords', item_tag='$item_tag', picurl='$picurl' WHERE lid ="
. $lid;
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
$notification_handler = &xoops_gethandler('notification');
$tags = array();
$tags['VIDEO_NAME'] = $title;
$tags['VIDEO_URL']
=
XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid
. '&lid=' . $lid;
$sql
=
"SELECT title FROM " . $xoopsDB->prefix('xoopstube_cat') . " WHERE cid=" . $cid;
$result = $xoopsDB->query($sql);
$row = $xoopsDB->fetchArray($result);
$tags['CATEGORY_NAME'] = $row['title'];
$tags['CATEGORY_URL']
=
XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
$notification_handler->triggerEvent('global', 0, 'new_video', $tags);
$notification_handler->triggerEvent('category', $cid, 'new_video', $tags);
$_message = _MD_XTUBE_ISAPPROVED;
} else {
$submitter_array = $xoopsDB->fetchArray(
$xoopsDB->query(
'SELECT submitter FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid)
)
);
$modifysubmitter = $xoopsUser->uid();
$requestid = $modifysubmitter;
$requestdate = time();
$updated = xtube_cleanRequestVars($_REQUEST, 'up_dated', time());
if ($modifysubmitter == $submitter_array['submitter']) {
$sql = 'INSERT INTO ' . $xoopsDB->prefix('xoopstube_mod')
. ' (requestid, lid, cid, title, vidid, publisher, vidsource, description, modifysubmitter, requestdate, time, keywords, item_tag, picurl)';
$sql .= " VALUES ('', $lid, $cid, '$title', '$vidid', '$publisher', '$vidsource', '$descriptionb', '$modifysubmitter', '$requestdate', '$time', '$keywords', '$item_tag', '$picurl')";
if (!$result = $xoopsDB->query($sql)) {
$_error = $xoopsDB->error() . " : " . $xoopsDB->errno();
XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
}
} else {
redirect_header('index.php', 2, _MD_XTUBE_MODIFYNOTALLOWED);
}
$tags = array();
$tags['MODIFYREPORTS_URL']
=
XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listModReq';
$notification_handler = &xoops_gethandler('notification');
$notification_handler->triggerEvent('global', 0, 'video_modify', $tags);
$tags['WAITINGFILES_URL']
= XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewvideos';
$notification_handler->triggerEvent('global', 0, 'video_submit', $tags);
$notification_handler->triggerEvent('category', $cid, 'video_submit', $tags);
if ($notifypub) {
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notification_handler->subscribe('video', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
}
$_message = _MD_XTUBE_THANKSFORINFO;
}
redirect_header('index.php', 2, $_message);
}
} else {
global $xoopsModuleConfig;
$approve = xtube_cleanRequestVars($_REQUEST, 'approve', 0);
// Show disclaimer
if ($xoopsModuleConfig['showdisclaimer'] && !isset($_GET['agree']) && $approve == 0) {
echo '<br /><div style="text-align: center;">' . xtube_imageheader() . '</div><br />';
echo '<h4>' . _MD_XTUBE_DISCLAIMERAGREEMENT . '</h4>';
echo '<div>' . $xtubemyts->displayTarea($xoopsModuleConfig['disclaimer'], 1, 1, 1, 1, 1) . '</div>';
echo '<form action="submit.php" method="post">';
echo '<div style="text-align: center;">' . _MD_XTUBE_DOYOUAGREE . '</b><br /><br />';
echo'<input type="button" onclick="location='submit.php?agree=1'" class="formButton" value="'
. _MD_XTUBE_AGREE . '" alt="' . _MD_XTUBE_AGREE . '" />';
echo ' ';
echo'<input type="button" onclick="location='index.php'" class="formButton" value="' . _CANCEL . '" alt="'
. _CANCEL . '" />';
echo '</div></form>';
include XOOPS_ROOT_PATH . '/footer.php';
exit();
}
echo '<br /><div style="text-align: center;">' . xtube_imageheader() . '</div><br />';
echo '<div>' . _MD_XTUBE_SUB_SNEWMNAMEDESC . '</div>';
// echo "<div class='xoopstube_singletitle'>" . _MD_XTUBE_SUBMITCATHEAD . "</div>n";
//récupération infos allociné et autocompletion
require_once XOOPS_ROOT_PATH . '/api-allocine/api-allocine-helper.php';
// Créer l'objet
$helper = new AlloHelper;
//Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.
$code = $_POST['filmcode'];
$profile = 'medium';
//Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.
if(isset($_POST['filmcode'])) {
try
{
// Envoi de la requête
$data = $helper->movie( $code, $profile, $filter );
//print_r($data->getArray());
//Convertir la durée en hh:mm:ss
$total = $data->runtime; //Nombre de secondes
$heure = intval(abs($total / 3600));
$total = $total - ($heure * 3600);
$minute = intval(abs($total / 60));
$total = $total - ($minute * 60);
$seconde = $total;
//Convertir la date en jj.mm.aa
$date = $data->release['releaseDate'];
function datefr($date) {
$split = preg_split("#-#",$date);
$annee = $split[0];
$mois = $split[1];
$jour = $split[2];
return "$jour"."-"."$mois"."-"."$annee";
}
$date = $data->release['releaseDate'];; // Date format américain
// $date=date("Y-m-d"); // Ou date du jour
}
catch( ErrorException $error )
{
// En cas d'erreur
echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
}
$url_img = $xtubemyts->addslashes(ltrim($data->poster));
$titre = $xtubemyts->addslashes(ltrim($data->title));
$annee = $xtubemyts->addslashes(ltrim($data->productionYear));
$duree = $xtubemyts->addslashes(ltrim($data->runtime));
$date_sortie = $xtubemyts->addslashes(ltrim($data->release['releaseDate']));
$nom_realisateur = $xtubemyts->addslashes(ltrim($data->castingShort['directors']));
$synopsis = $xtubemyts->addslashes(ltrim($data->synopsis));
$nom_acteur = $xtubemyts->addslashes(ltrim($data->castingShort['actors']));
$nom_pays = $xtubemyts->addslashes(ltrim($data->nationality[0]['$']));
$bande_a = $xtubemyts->addslashes(ltrim($data->trailerEmbed));
$nom_genre = $data->genre[0]['$'];
$descrip = '' . $data->synopsis .'<br /><br />Date de sortie ' . datefr($date) . '('.$heure.':'.$minute.':'.$seconde.')<br />Réalisé par ' . $nom_realisateur . '<br />Avec ' . $nom_acteur . '<br />Genre ' . $nom_genre . '<br />Nationalité ' . $nom_pays . '<br /><img src="' . $data->poster . '" style="width: 190px; height: 260px;"></img><br />' . $data->trailerEmbed . '';
}
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid);
$video_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
$lid = $video_array['lid'] ? $video_array['lid'] : 0;
$cid = $video_array['cid'] ? $video_array['cid'] : 2;
$title = $video_array['title'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['title']) : ''.$titre.' [FilmFR]';
$vidid = $video_array['vidid'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['vidid']) : '';
$publisher = $video_array['publisher'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['publisher']) : '';
$screenshot = $video_array['screenshot'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['screenshot']) : '';
$descriptionb = $video_array['description'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['description']) : ''.$descrip.'';
$published = $video_array['published'] ? $video_array['published'] : 0;
$expired = $video_array['expired'] ? $video_array['expired'] : 0;
$updated = $video_array['updated'] ? $video_array['updated'] : 0;
$offline = $video_array['offline'] ? $video_array['offline'] : 0;
$vidsource = $video_array['vidsource'] ? $video_array['vidsource'] : 0;
$ipaddress = $video_array['ipaddress'] ? $video_array['ipaddress'] : 0;
$notifypub = $video_array['notifypub'] ? $video_array['notifypub'] : 0;
$vidrating = $video_array['vidrating'] ? $video_array['vidrating'] : 1;
$time = $video_array['time'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['time']) : ''.$heure.'h'.$minute.'min';
$keywords = $video_array['keywords'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['keywords']) : '';
$item_tag = $video_array['item_tag'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['item_tag']) : ''.$nom_genre.'';
$picurl = $video_array['picurl'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['picurl']) : '';
$sform = new XoopsThemeForm(_MD_XTUBE_SUBMITCATHEAD, 'storyform', xoops_getenv('PHP_SELF'));
$sform->setExtra('enctype="multipart/form-data"');
xoopstube_noindexnofollow();
// Video title form
$sform->addElement(new XoopsFormText(_MD_XTUBE_FILETITLE, 'title', 70, 255, $title), TRUE);
// Video source form
$vidsource_array = array(
0 => _MD_XTUBE_YOUTUBE,
1 => _MD_XTUBE_METACAFE,
2 => _MD_XTUBE_IFILM,
4 => _MD_XTUBE_VIDDLER,
100 => _MD_XTUBE_GOOGLEVIDEO,
101 => _MD_XTUBE_MYSPAVETV,
102 => _MD_XTUBE_DAILYMOTION,
103 => _MD_XTUBE_BLIPTV,
104 => _MD_XTUBE_CLIPFISH,
105 => _MD_XTUBE_LIVELEAK,
106 => _MD_XTUBE_MAKTOOB,
107 => _MD_XTUBE_VEOH,
108 => _MD_XTUBE_VIMEO,
109 => _MD_XTUBE_RUTUBE,
110 => _MD_XTUBE_STAGEVU,
111 => _MD_XTUBE_NETU,
112 => _MD_XTUBE_MAILRU,
113 => _MD_XTUBE_EXASHARE,
114 => _MD_XTUBE_VK,
115 => _MD_XTUBE_VIDEOMEGA,
116 => _MD_XTUBE_SPEEDVIDEO,
117 => _MD_XTUBE_WAT,
118 => _MD_XTUBE_KIWI,
119 => _MD_XTUBE_VODLOCKER,
);
$vidsource_select = new XoopsFormSelect(_MD_XTUBE_VIDSOURCE, 'vidsource', $vidsource);
$vidsource_select->addOptionArray($vidsource_array);
$sform->addElement($vidsource_select, FALSE);
// Video code form
$videocode = new XoopsFormText(_MD_XTUBE_DLVIDID, 'vidid', 70, 512, $vidid);
$videocode->setDescription('<br /><small>' . _MD_XTUBE_VIDEO_DLVIDIDDSC . '</small>');
$sform->addElement($videocode, TRUE);
$sform->addElement(new XoopsFormLabel('', _MD_XTUBE_VIDEO_DLVIDID_NOTE));
// Picture url form
$picurl = new XoopsFormText(_MD_XTUBE_VIDEO_PICURL, 'picurl', 70, 255, $picurl);
$picurl->setDescription('<br /><span style="font-weight: normal;">' . _MD_XTUBE_VIDEO_PICURLNOTE . '</span>');
$sform->addElement($picurl, FALSE);
// Video publisher form
$sform->addElement(new XoopsFormText(_MD_XTUBE_VIDEO_PUBLISHER, 'publisher', 70, 255, $publisher), TRUE);
// Category tree
$mytree = new XoopsTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid');
$submitcats = array();
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' ORDER BY title';
$result = $xoopsDB->query($sql);
while ($myrow = $xoopsDB->fetchArray($result)) {
if (TRUE == xtube_checkgroups($myrow['cid'], 'XTubeSubPerm')) {
$submitcats[$myrow['cid']] = $myrow['title'];
}
}
// Video time form
$timeform = new XoopsFormText(_MD_XTUBE_TIME, 'time', 7, 7, $time);
$timeform->setDescription('<small>(h:mm:ss)</small>');
$sform->addElement($timeform, FALSE);
// Video category form
ob_start();
$mytree->makeMySelBox('title', 'title', $cid, 0);
$sform->addElement(new XoopsFormLabel(_MD_XTUBE_CATEGORYC, ob_get_contents()));
ob_end_clean();
// Video description form
// $editor = xtube_getWysiwygForm( _MD_XTUBE_DESCRIPTIONC, 'descriptionb', $descriptionb, 10, 50, '');
// $sform -> addElement( $editor, true );
$optionsTrayNote = new XoopsFormElementTray(_MD_XTUBE_DESCRIPTIONC, '<br />');
if (class_exists('XoopsFormEditor')) {
$options['name'] = 'descriptionb';
$options['value'] = $descriptionb;
$options['rows'] = 7;
$options['cols'] = 100;
$options['width'] = '100%';
$options['height'] = '200px';
$editor = new XoopsFormEditor('', $xoopsModuleConfig['form_optionsuser'], $options, $nohtml = FALSE, $onfailure = 'textarea');
$optionsTrayNote->addElement($editor);
} else {
$editor = new XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%');
$optionsTrayNote->addElement($editor);
}
$sform->addElement($optionsTrayNote, FALSE);
if ($xoopsModuleConfig['usercantag'] == 1) {
// Insert tags if Tag-module is installed
if (xtube_tag_module_included()) {
include_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
$text_tags = new XoopsFormTag('item_tag', 70, 255, $video_array['item_tag'], 0);
$sform->addElement($text_tags);
}
} else {
$sform->addElement(new XoopsFormHidden('item_tag', $video_array['item_tag']));
}
$submitter2 = (is_object($xoopsUser) && !empty($xoopsUser)) ? $xoopsUser->getVar('uid') : 0;
if ($submitter2 > 0) {
$option_tray = new XoopsFormElementTray(_MD_XTUBE_OPTIONS, '<br />');
if (!$approve) {
$notify_checkbox = new XoopsFormCheckBox('', 'notifypub');
$notify_checkbox->addOption(1, _MD_XTUBE_NOTIFYAPPROVE);
$option_tray->addElement($notify_checkbox);
} else {
$sform->addElement(new XoopsFormHidden('notifypub', 0));
}
}
if (TRUE == xtube_checkgroups($cid, 'XTubeAppPerm') && $lid > 0) {
$approve_checkbox = new XoopsFormCheckBox('', 'approve', $approve);
$approve_checkbox->addOption(1, _MD_XTUBE_APPROVE);
$option_tray->addElement($approve_checkbox);
} else {
if (TRUE == xtube_checkgroups($cid, 'XTubeAutoApp')) {
$sform->addElement(new XoopsFormHidden('approve', 1));
} else {
$sform->addElement(new XoopsFormHidden('approve', 0));
}
}
$sform->addElement($option_tray);
$button_tray = new XoopsFormElementTray('', '');
$button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$button_tray->addElement(new XoopsFormHidden('lid', $lid));
$sform->addElement($button_tray);
$sform->display();
include XOOPS_ROOT_PATH . '/footer.php';
}
} else {
redirect_header('index.php', 2, _MD_XTUBE_NOPERMISSIONTOPOST);
exit();
}
?>
Le résultat, c'est le formulaire submit_film.php prérempli avec les infos du film, reste juste à mettre le lien de la vidéo, l'auteur et dans mon cas, une image car j'ai choisi un format wallpaper(largeur +grand que hauteur.J'utilise l'image allociné dans la description. Le problème que j'ai c'est que seulement la moitier des films testé passe avec succés. Pour les autres ,j'ai une erreur dont je ne comprend pas l'origine. En mode debug ,j'ai ceci:
Fatal error: Cannot access private property AlloHelper::$_lastError in api-allocine/AlloData.class.php on line 354
dans allodata cela correspond à cette fonction:
public function error($message = null, $code = 0)
{
if ($message !== null)
{
$error = new ErrorException($message, $code);
AlloHelper::$_lastError = $error;
if ($this->throwExceptions)
throw $error;
}
return AlloHelper::$_lastError;
}
Vous pouvez m'aider svp
Posté le : 29/12/2014 10:50
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Admin Frxoops
Inscrit: 04/03/2011 09:10
De Lot
|
Dans la class "AlloHelper" la variable "$_lastError" est protégé (d'où le message) Donc non appelable de l'extérieur, suffit de changer 'protected' en 'public'
Posté le : 29/12/2014 11:08
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Régulier
Inscrit: 10/09/2007 11:51
|
Merci si il s'agit de $_lasterror on a ceci dans la class:
private static $_lastError;
je doit changer private static en public?
Posté le : 29/12/2014 12:21
|
|
|
Re: Utiliser l'api allociné dans xoopstube |
|
Admin Frxoops
Inscrit: 04/03/2011 09:10
De Lot
|
on vire 'private' et on met 'public'
Posté le : 29/12/2014 12:22
|
|
Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.
|