Command/QueryWikipediaCommand.php
changeset 58 87bf6ec8af90
parent 43 54f204bceb28
child 67 989d9e117586
equal deleted inserted replaced
57:186c4121c7b3 58:87bf6ec8af90
    39         parent::configure();
    39         parent::configure();
    40 
    40 
    41         $this
    41         $this
    42             ->setName('wikitag:query-wikipedia')
    42             ->setName('wikitag:query-wikipedia')
    43             ->setDescription('Query wikipedia for tags.')
    43             ->setDescription('Query wikipedia for tags.')
    44             ->addOption("force","f",InputOption::VALUE_NONE, "Force remove tags")
    44             ->addOption("force","f",InputOption::VALUE_NONE, "Force processing tags, will ask no confirmation")
    45             ->addOption("all","a",InputOption::VALUE_NONE, "all")
    45             ->addOption("all","a",InputOption::VALUE_NONE, "Search all tags")
       
    46             ->addOption("null","n",InputOption::VALUE_NONE, "Treat only non processed tags")
    46             ->addOption("redirection",null,InputOption::VALUE_NONE, "Treat redirections")
    47             ->addOption("redirection",null,InputOption::VALUE_NONE, "Treat redirections")
    47             ->addOption("random","r",InputOption::VALUE_NONE, "randomize query on tags")
    48             ->addOption("random","r",InputOption::VALUE_NONE, "randomize query on tags")
    48             ->addOption("site","S",InputOption::VALUE_OPTIONAL, "the url for the wikipedia site", "http://fr.wikipedia.org/w/api.php")
    49             ->addOption("site","S",InputOption::VALUE_OPTIONAL, "the url for the wikipedia site", "http://fr.wikipedia.org/w/api.php")
    49             ->addOption("limit","l",InputOption::VALUE_OPTIONAL, "number of tag to process", -1)
    50             ->addOption("limit","l",InputOption::VALUE_OPTIONAL, "number of tag to process", -1)
    50             ->addOption("start",null,InputOption::VALUE_OPTIONAL, "number of tag to ignore", 0);
    51             ->addOption("start",null,InputOption::VALUE_OPTIONAL, "number of tag to ignore", 0);
    58         $random = $input->getOption('random');
    59         $random = $input->getOption('random');
    59         $redirection = $input->getOption('redirection');
    60         $redirection = $input->getOption('redirection');
    60         $site = $input->getOption('site');
    61         $site = $input->getOption('site');
    61         $limit = intval($input->getOption('limit'));
    62         $limit = intval($input->getOption('limit'));
    62         $start = intval($input->getOption('start'));
    63         $start = intval($input->getOption('start'));
       
    64         $null = $input->getOption('null');
    63         
    65         
    64         $doctrine = $this->getContainer()->get('doctrine');
    66         $doctrine = $this->getContainer()->get('doctrine');
    65         $qb = $doctrine->getEntityManager()->createQueryBuilder();
    67         $qb = $doctrine->getEntityManager()->createQueryBuilder();
    66         
    68         
    67         
    69         
    70         if(!$all)
    72         if(!$all)
    71         {
    73         {
    72             if($redirection) {
    74             if($redirection) {
    73                 $qb->where($qb->expr()->andx($qb->expr()->eq("t.urlStatus",Tag::$TAG_URL_STATUS_DICT['redirection']), $qb->expr()->isNull("t.alternativeLabel")));
    75                 $qb->where($qb->expr()->andx($qb->expr()->eq("t.urlStatus",Tag::$TAG_URL_STATUS_DICT['redirection']), $qb->expr()->isNull("t.alternativeLabel")));
    74             }
    76             }
       
    77             elseif($null) {
       
    78                 $qb->where($qb->expr()->isNull("t.urlStatus"));
       
    79             }
    75             else {
    80             else {
    76                 $qb->where($qb->expr()->isNull("t.urlStatus"));
    81                 $qb->where($qb->expr()->orx($qb->expr()->isNull("t.urlStatus"), $qb->expr()->eq("t.urlStatus", Tag::$TAG_URL_STATUS_DICT['null_result'])));
    77             }
    82             }
    78         }
    83         }
    79         
    84         
    80         if($start > 0)
    85         if($start > 0)
    81         {
    86         {