예제 #1
0
 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::setup($input, $output);
     $id = $input->getArgument('id');
     $user = $this->u->getArrayInfosFromUtilisateur($id);
     $pageName = 'Utilisateur:' . $user['prenom'] . ' ' . $user['nom'];
     $output->writeln('<info>Exporting "' . $pageName . '"…</info>');
     $content = '';
     $this->loginAsAdmin();
     $this->deletePage($pageName);
     //Login as user
     $this->login($user['prenom'] . ' ' . $user['nom']);
     $oldPath = 'http://www.archi-wiki.org/images/avatar/' . $id . '/original.jpg';
     $headers = get_headers($oldPath, 1);
     if ($headers[0] == 'HTTP/1.1 200 OK') {
         $filename = 'Avatar ' . $user['prenom'] . ' ' . $user['nom'] . '.jpg';
         $params = array('filename' => $filename, 'token' => $this->api->getToken('edit'), 'url' => $oldPath);
         if ($input->getOption('force')) {
             $params['ignorewarnings'] = true;
         }
         $output->writeln('<info>Exporting "File:' . $filename . '"…</info>');
         $this->api->postRequest(new Api\SimpleRequest('upload', $params, array()));
     } else {
         $filename = '';
     }
     $this->savePage($pageName, '{{Infobox utilisateur
         |site=' . $user['urlSiteWeb'] . '
         |avatar=' . $filename . '
         }}', "Profil importé depuis Archi-Wiki");
 }
 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::setup($input, $output);
     $id = $input->getArgument('id');
     $origPageName = $this->s->getSourceLibelle($id);
     $pageName = 'Source:' . $origPageName;
     $output->writeln('<info>Exporting "' . $pageName . '"…</info>');
     $html = $this->convertHtml($this->s->afficheDescriptionSource($id));
     $html = $this->replaceSubtitles($html);
     $this->loginAsAdmin();
     $this->deletePage($pageName);
     //Login as bot
     $this->login('aw2mw bot');
     $oldPath = 'http://www.archi-wiki.org/images/logosSources/' . $id . '_original.jpg';
     $headers = get_headers($oldPath, 1);
     if ($headers[0] == 'HTTP/1.1 200 OK') {
         $filename = 'Source ' . $origPageName . '.jpg';
         $params = array('filename' => $filename, 'token' => $this->api->getToken('edit'), 'url' => $oldPath);
         if ($input->getOption('force')) {
             $params['ignorewarnings'] = true;
         }
         $output->writeln('<info>Exporting "File:' . $filename . '"…</info>');
         $this->api->postRequest(new Api\SimpleRequest('upload', $params, array()));
         $html = '[[File:' . $filename . '|thumb]]' . PHP_EOL . $html;
     }
     $this->savePage($pageName, $html, 'Source importée depuis Archi-Wiki');
 }
예제 #3
0
 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::setup($input, $output);
     $id = $input->getArgument('id');
     $reqImages = "\n            SELECT hi1.idImage,  hi1.idHistoriqueImage,  hi1.nom, hi1.auteur,\n                hi1.description,  hi1.dateUpload,  hi1.dateCliche, hi1.idUtilisateur,\n                hi1.licence, hi1.tags\n            FROM _evenementImage ei\n            LEFT JOIN historiqueImage hi1 ON hi1.idImage = ei.idImage\n            LEFT JOIN historiqueImage hi2 ON hi2.idImage = hi1.idImage\n            WHERE hi1.idImage = '" . mysql_real_escape_string($id) . "'\n            GROUP BY hi1.idImage ,  hi1.idHistoriqueImage\n            HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage)\n            ORDER BY ei.position, hi1.idHistoriqueImage\n            ";
     $resImages = $this->i->connexionBdd->requete($reqImages);
     $image = mysql_fetch_assoc($resImages);
     $origImage = mysql_fetch_assoc($this->i->connexionBdd->requete("SELECT idUtilisateur, dateUpload\n                FROM historiqueImage\n                WHERE idImage = '" . mysql_real_escape_string($id) . "'"));
     $user = $this->u->getArrayInfosFromUtilisateur($origImage['idUtilisateur']);
     if ($user) {
         $this->login($user['prenom'] . ' ' . $user['nom']);
     } else {
         $after2008 = new \DateTime($origImage['dateUpload']) > new \DateTime('2008-04-01');
         if ($after2008) {
             $this->login('aw2mw bot');
         } else {
             $this->login('Fabien Romary');
         }
     }
     $filename = $this->getImageName($image['idImage']);
     $imagePage = $this->services->newPageGetter()->getFromTitle('File:' . $filename);
     $output->writeln('<info>Exporting "File:' . $filename . '"…</info>');
     if ($imagePage->getPageIdentifier()->getId() == 0 || $input->getOption('force')) {
         $oldPath = 'http://www.archi-wiki.org/photos--' . $image['dateUpload'] . '-' . $image['idHistoriqueImage'] . '-originaux.jpg';
         $params = array('filename' => $filename, 'token' => $this->api->getToken('edit'), 'url' => $oldPath);
         if ($input->getOption('force')) {
             $params['ignorewarnings'] = true;
         }
         $this->api->postRequest(new Api\SimpleRequest('upload', $params, array()));
     }
     if (empty($image['auteur'])) {
         if ($user) {
             $image['auteur'] = '[[Utilisateur:' . $user['prenom'] . ' ' . $user['nom'] . '|' . $user['prenom'] . ' ' . $user['nom'] . ']]';
         } else {
             if ($after2008) {
                 $image['auteur'] = '';
             } else {
                 $image['auteur'] = '[[Utilisateur:Fabien Romary|Fabien Romary]]';
             }
         }
     }
     if ($image['dateCliche'] == '0000-00-00') {
         $image['dateCliche'] = '';
     }
     if (substr($image['dateCliche'], 5) == '00-00') {
         $image['dateCliche'] = substr($image['dateCliche'], 0, 4);
     }
     $licence = $this->i->getLicence($image['idImage']);
     $this->login('aw2mw bot');
     $description = $this->convertHtml($this->bbCode->convertToDisplay(array('text' => $image['description'])));
     $this->savePage('File:' . $filename, '{{Infobox image
         |description=' . $description . '
         |date=' . $image['dateCliche'] . '
         |auteur=' . $image['auteur'] . '
         |licence = {{Modèle:' . $licence['name'] . '}}
         |tags = ' . $image['tags'] . '
         }}', "Description de l'image importée depuis Archi-Wiki");
 }
    /**
     * Execute command
     *
     * @param InputInterface  $input  Input
     * @param OutputInterface $output Output
     *
     * @return void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::setup($input, $output);
        global $config;
        $config = new \Config();
        $id = $input->getArgument('id');
        @($person = new \ArchiPersonne($id));
        if (!isset($person->nom)) {
            $this->output->writeln('<error>Personne introuvable</error>');
            return;
        }
        $pageName = 'Personne:' . $person->prenom . ' ' . $person->nom;
        $this->output->writeln('<info>Exporting "' . $pageName . '"…</info>');
        $this->loginAsAdmin();
        $this->deletePage($pageName);
        $this->login('aw2mw bot');
        $events = $person->getEvents($id);
        $content = '';
        $sections = array();
        $sections[0] = $content;
        //Create page structure
        foreach ($events as $event) {
            $sql = 'SELECT  hE.idEvenement,
                    hE.titre, hE.idSource,
                    hE.idTypeStructure,
                    hE.idTypeEvenement,
                    hE.description,
                    hE.dateDebut,
                    hE.dateFin,
                    hE.dateDebut,
                    hE.dateFin,
                    tE.nom AS nomTypeEvenement,
                    tS.nom AS nomTypeStructure,
                    s.nom AS nomSource,
                    u.nom AS nomUtilisateur,
                    u.prenom as prenomUtilisateur,
                    tE.groupe,
                    hE.ISMH,
                    hE.MH,
                    date_format(hE.dateCreationEvenement,"' . _("%e/%m/%Y à %kh%i") . '") as dateCreationEvenement,
                    hE.isDateDebutEnviron as isDateDebutEnviron,
                    u.idUtilisateur as idUtilisateur,
                    hE.numeroArchive as numeroArchive

                    FROM historiqueEvenement hE
                    LEFT JOIN source s      ON s.idSource = hE.idSource
                    LEFT JOIN typeStructure tS  ON tS.idTypeStructure = hE.idTypeStructure
                    LEFT JOIN typeEvenement tE  ON tE.idTypeEvenement = hE.idTypeEvenement
                    LEFT JOIN utilisateur u     ON u.idUtilisateur = hE.idUtilisateur
                    WHERE hE.idEvenement = ' . mysql_real_escape_string($event["idEvenementAssocie"]) . '
            ORDER BY hE.idHistoriqueEvenement DESC';
            $res = $this->e->connexionBdd->requete($sql);
            $event = mysql_fetch_assoc($res);
            if (!empty($event['titre'])) {
                $title = $event['titre'];
            } elseif ($event['dateDebut'] != '0000-00-00') {
                $title = substr($event['dateDebut'], 0, 4);
            } else {
                $title = 'Biographie';
            }
            $title = stripslashes($title);
            $content .= '==' . $title . '==' . PHP_EOL;
        }
        $relatedPeople = $person->getRelatedPeople($id);
        if (!empty($relatedPeople)) {
            $relatedPeopleContent = '==Personnes liées==' . PHP_EOL;
        }
        foreach ($relatedPeople as $relatedId) {
            $relatedPerson = new \ArchiPersonne($relatedId);
            $relatedPeopleContent .= '* [[Personne:' . $relatedPerson->prenom . ' ' . $relatedPerson->nom . '|' . $relatedPerson->prenom . ' ' . $relatedPerson->nom . ']]' . PHP_EOL;
        }
        $content .= $relatedPeopleContent;
        $references = PHP_EOL . '==Références==' . PHP_EOL . '<references />' . PHP_EOL;
        $content .= $references;
        $this->savePage($pageName, $content, 'Sections importées depuis Archi-Wiki');
        foreach ($events as $section => $event) {
            $req = "SELECT idHistoriqueEvenement\n                    FROM historiqueEvenement\n                    WHERE idEvenement=" . mysql_real_escape_string($event["idEvenementAssocie"]) . "\n                    order by dateCreationEvenement ASC";
            $res = $this->e->connexionBdd->requete($req);
            while ($fetch = mysql_fetch_assoc($res)) {
                $sql = 'SELECT  hE.idEvenement,
                        hE.titre, hE.idSource,
                        hE.idTypeStructure,
                        hE.idTypeEvenement,
                        hE.description,
                        hE.dateDebut,
                        hE.dateFin,
                        hE.dateDebut,
                        hE.dateFin,
                        tE.nom AS nomTypeEvenement,
                        tS.nom AS nomTypeStructure,
                        s.nom AS nomSource,
                        u.nom AS nomUtilisateur,
                        u.prenom as prenomUtilisateur,
                        tE.groupe,
                        hE.ISMH ,
                        hE.MH,
                        date_format(hE.dateCreationEvenement,"' . _("%e/%m/%Y à %kh%i") . '") as dateCreationEvenement,
                        hE.isDateDebutEnviron as isDateDebutEnviron,
                        u.idUtilisateur as idUtilisateur,
                        hE.numeroArchive as numeroArchive

                        FROM historiqueEvenement hE
                        LEFT JOIN source s      ON s.idSource = hE.idSource
                        LEFT JOIN typeStructure tS  ON tS.idTypeStructure = hE.idTypeStructure
                        LEFT JOIN typeEvenement tE  ON tE.idTypeEvenement = hE.idTypeEvenement
                        LEFT JOIN utilisateur u     ON u.idUtilisateur = hE.idUtilisateur
                        WHERE hE.idHistoriqueEvenement = ' . mysql_real_escape_string($fetch['idHistoriqueEvenement']) . '
                ORDER BY hE.idHistoriqueEvenement DESC';
                $eventInfo = mysql_fetch_assoc($this->e->connexionBdd->requete($sql));
                $user = $this->u->getArrayInfosFromUtilisateur($eventInfo['idUtilisateur']);
                //Login as user
                if (!empty($user['nom'])) {
                    $this->login($user['prenom'] . ' ' . $user['nom']);
                } else {
                    $this->login('aw2mw bot');
                }
                $content = '';
                $date = $this->convertDate($eventInfo['dateDebut'], $eventInfo['dateFin'], $eventInfo['isDateDebutEnviron']);
                if (!empty($eventInfo['titre'])) {
                    $title = $eventInfo['titre'];
                } elseif (!empty($eventInfo['nomTypeEvenement'])) {
                    $title = $eventInfo['nomTypeEvenement'];
                } else {
                    $title = 'Biographie';
                }
                if ($eventInfo['idSource'] > 0) {
                    $sourceName = $this->s->getSourceLibelle($event['idSource']);
                    $title .= '<ref>[[Source:' . $sourceName . '|' . $sourceName . ']]</ref>';
                }
                if (!empty($eventInfo['numeroArchive'])) {
                    $sourceName = $this->s->getSourceLibelle(24);
                    $title .= '<ref>[[Source:' . $sourceName . '|' . $sourceName . ']] - Cote ' . $event['numeroArchive'] . '</ref>';
                }
                $title = ucfirst(stripslashes($title));
                $content .= '==' . $title . '==' . PHP_EOL;
                $html = $this->convertHtml($this->bbCode->convertToDisplay(array('text' => $eventInfo['description'])));
                $content .= trim($html) . PHP_EOL . PHP_EOL;
                $this->api->postRequest(new Api\SimpleRequest('edit', array('title' => $pageName, 'md5' => md5($content), 'text' => $content, 'section' => $section + 1, 'bot' => true, 'summary' => 'Révision du ' . $eventInfo['dateCreationEvenement'] . ' importée depuis Archi-Wiki', 'token' => $this->api->getToken())));
                $sections[$section + 1] = $content;
            }
            $linkedEvents = $person->getEvenementsLies($id, $eventInfo['dateDebut'], 3000);
            if (!empty($linkedEvents)) {
                $html = '=== Adresses liées ===' . PHP_EOL;
            }
            foreach ($linkedEvents as $linkedEvent) {
                $req = "\n                    SELECT titre, dateDebut, dateFin, idTypeEvenement\n                    FROM historiqueEvenement\n                    WHERE idEvenement = '" . $linkedEvent . "'\n                    ORDER BY idHistoriqueEvenement DESC\n                ";
                $resEvent = $config->connexionBdd->requete($req);
                $linkedEventInfo = mysql_fetch_object($resEvent);
                $linkedEventAddress = $this->a->getIntituleAdresseFrom($linkedEvent, "idEvenement", array('noHTML' => true, 'noQuartier' => true, 'noSousQuartier' => true, 'noVille' => true, 'displayFirstTitreAdresse' => true, 'setSeparatorAfterTitle' => '_'));
                if (!empty($linkedEventAddress)) {
                    $req = "\n                            SELECT  idAdresse\n                            FROM _adresseEvenement\n                            WHERE idEvenement = " . $this->e->getIdEvenementGroupeAdresseFromIdEvenement($linkedEvent);
                    $resAddress = $config->connexionBdd->requete($req);
                    $fetchAddress = mysql_fetch_object($resAddress);
                    if (isset($fetchAddress->idAdresse)) {
                        $linkedEventIdAddress = $fetchAddress->idAdresse;
                        $address = $this->a->getArrayAdresseFromIdAdresse($input->getArgument('id'));
                        $city = $address['nomVille'];
                    }
                }
                $linkedEventImg = $this->a->getUrlImageFromEvenement($linkedEvent, "mini");
                if ($linkedEventImg["url"] == $config->getUrlImage("", "transparent.gif")) {
                    $linkedEventImg = $this->a->getUrlImageFromAdresse($linkedEventIdAddress, "mini");
                }
                $linkedEventUrl = $config->creerUrl("", "adresseDetail", array("archiIdAdresse" => $linkedEventIdAddress, "archiIdEvenementGroupeAdresse" => $linkedEvent));
                $html .= '{{Adresse liée
                    |adresse=' . $this->getAddressName($linkedEventIdAddress) . PHP_EOL;
                $reqImage = 'SELECT idImage FROM historiqueImage
                    WHERE idHistoriqueImage = ' . mysql_real_escape_string($linkedEventImg['idHistoriqueImage']) . '
                    ORDER BY idHistoriqueImage DESC LIMIT 1';
                $resImage = $config->connexionBdd->requete($reqImage);
                $imageInfo = mysql_fetch_object($resImage);
                if (isset($imageInfo->idImage)) {
                    $command = $this->getApplication()->find('export:image');
                    $command->run(new ArrayInput(array('id' => $imageInfo->idImage)), $this->output);
                    $filename = $this->getImageName($imageInfo->idImage);
                    $html .= '|photo=' . $filename . PHP_EOL;
                }
                if ($linkedEventInfo->dateDebut != "0000-00-00") {
                    if ($linkedEventInfo->dateFin != "0000-00-00") {
                        $linkedDate = $linkedEventInfo->dateFin;
                    } else {
                        $linkedDate = $linkedEventInfo->dateDebut;
                    }
                    $html .= '|date=' . $config->date->toFrench($linkedDate) . PHP_EOL;
                }
                $html .= '}}' . PHP_EOL;
            }
            $this->api->postRequest(new Api\SimpleRequest('edit', array('title' => $pageName, 'md5' => md5($html), 'text' => $html, 'section' => $section + 1, 'bot' => true, 'summary' => 'Importation des adresses liées depuis Archi-Wiki', 'token' => $this->api->getToken())));
            $sections[$section + 1] .= $html;
        }
        $sections[] = $relatedPeopleContent;
        $sections[] = $references;
        //Login with bot
        $this->login('aw2mw bot');
        $content = implode('', $sections);
        //Replace <u/> with ===
        $content = $this->replaceSubtitles($content);
        $this->savePage($pageName, $content, 'Conversion des titres de section');
    }
 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::setup($input, $output);
     $address = $this->a->getArrayAdresseFromIdAdresse($input->getArgument('id'));
     if (!$address) {
         $this->output->writeln('<error>Adresse introuvable</error>');
         return;
     }
     $city = $this->a->getInfosVille($address['idVille']);
     $basePageName = $this->getAddressName($input->getArgument('id'));
     $pageName = 'Adresse:' . $basePageName;
     $groupInfo = mysql_fetch_assoc($this->a->getIdEvenementsFromAdresse($input->getArgument('id')));
     $events = array();
     $requete = "\n            SELECT DISTINCT evt.idEvenement, pe.idEvenement, pe.position\n            FROM evenements evt\n            LEFT JOIN _evenementEvenement ee on ee.idEvenement = " . mysql_real_escape_string($groupInfo['idEvenementGroupeAdresse']) . "\n            LEFT JOIN positionsEvenements pe on pe.idEvenement = ee.idEvenementAssocie\n            WHERE evt.idEvenement = ee.idEvenementAssocie\n            ORDER BY pe.position ASC\n            ";
     $result = $this->e->connexionBdd->requete($requete);
     $arrayIdEvenement = array();
     while ($res = mysql_fetch_assoc($result)) {
         $allEvents[] = $res['idEvenement'];
     }
     foreach ($allEvents as $id) {
         $rep = $this->e->connexionBdd->requete('
                 SELECT  p.idPersonne
                 FROM _evenementPersonne _eP
                 LEFT JOIN personne p ON p.idPersonne = _eP.idPersonne
                 LEFT JOIN metier m ON m.idMetier = p.idMetier
                 WHERE _eP.idEvenement=' . mysql_real_escape_string($id) . '
                 ORDER BY p.nom DESC');
         $people = array();
         while ($res = mysql_fetch_object($rep)) {
             $people[] = $res;
         }
         if (!empty($people)) {
             $events[] = $id;
         } else {
             $newsEvents[] = $id;
         }
     }
     $this->exportEvents($events, $pageName, $address);
     $this->exportEvents($newsEvents, 'Actualités_adresse:' . $basePageName, $address);
 }