public function modifyQuery(DpleQuery &$query)
 {
     switch ($this->redirects_) {
         case 'only':
             $query->addConds(array('page_is_redirect' => 1));
             break;
         case 'exclude':
             $query->addConds(array('page_is_redirect' => 0));
             break;
     }
 }
 public function modifyQuery(DpleQuery &$query)
 {
     $dbr = $query->getDbr();
     switch ($this->subpages_) {
         case 'only':
             $query->addConds('page_title' . $dbr->buildLike($dbr->anyString(), '/', $dbr->anyString()));
             break;
         case 'exclude':
             $query->addConds('page_title NOT' . $dbr->buildLike($dbr->anyString(), '/', $dbr->anyString()));
             break;
     }
 }
 public function modifyQuery(DpleQuery &$query)
 {
     switch (count($this->namespaces_)) {
         case 0:
             break;
         case 1:
             $query->addConds("page_namespace = {$this->namespaces_[0]}");
             break;
         default:
             $query->addConds('page_namespace IN (' . implode(',', $this->namespaces_) . ')');
     }
     switch (count($this->notNamespaces_)) {
         case 0:
             break;
         case 1:
             $query->addConds("page_namespace != {$this->notNamespaces_[0]}");
             break;
         default:
             $query->addConds('page_namespace NOT IN (' . implode(',', $this->notNamespaces_) . ')');
     }
 }
 public function modifyQuery(DpleQuery &$query)
 {
     $dbr = $query->getDbr();
     $tableName = $dbr->tableName('revision');
     /** Add condition based on @ref $createdby_. */
     if ($this->createdby_) {
         $table = "{$tableName} AS rev_c";
         $query->addTables($table);
         $cond = $this->buildIn($this->createdby_);
         $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_c.rev_page', 'rev_c.rev_parent_id = 0'));
         $query->addConds("rev_c.rev_user {$cond}");
     }
     /** Add condition based on @ref $notCreatedby_. */
     if ($this->notCreatedby_) {
         $table = "{$tableName} AS rev_nc";
         $query->addTables($table);
         $cond = 'NOT' . $this->buildIn($this->notCreatedby_);
         $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_nc.rev_page', 'rev_nc.rev_parent_id = 0'));
         $query->addConds("rev_nc.rev_user {$cond}");
     }
     /** Add condition based on @ref $lastmodifiedby_. */
     if ($this->lastmodifiedby_) {
         $table = "{$tableName} AS rev_l";
         $query->addTables($table);
         $cond = $this->buildIn($this->lastmodifiedby_);
         $query->addJoinCond($table, 'INNER JOIN', array('page_latest = rev_l.rev_id'));
         $query->addConds("rev_l.rev_user {$cond}");
     }
     /** Add condition based on @ref $notLastmodifiedby_. */
     if ($this->notLastmodifiedby_) {
         $table = "{$tableName} AS rev_nl";
         $query->addTables($table);
         $cond = 'NOT' . $this->buildIn($this->notLastmodifiedby_);
         $query->addJoinCond($table, 'INNER JOIN', array('page_latest = rev_nl.rev_id'));
         $query->addConds("rev_nl.rev_user {$cond}");
     }
     /** Add condition based on @ref $modifiedby_. */
     if ($this->modifiedby_) {
         $table = "{$tableName} AS rev_m";
         $query->addTables($table);
         $cond = $this->buildIn($this->modifiedby_);
         $query->addJoinCond($table, 'INNER JOIN', array('page_id = rev_m.rev_page'));
         $query->addConds("rev_m.rev_user {$cond}");
         $query->setOption('DISTINCT');
     }
     /** Add condition based on @ref $notModifiedby_. */
     if ($this->notModifiedby_) {
         $table = "{$tableName} AS rev_nm";
         $query->addTables($table);
         $cond = $this->buildIn($this->notModifiedby_);
         $query->addJoinCond($table, 'LEFT OUTER JOIN', array('page_id = rev_nm.rev_page', "rev_nm.rev_user {$cond}"));
         $query->addConds(array('rev_nm.rev_page' => null));
         $query->setOption('DISTINCT');
     }
 }
 public function modifyQuery(DpleQuery &$query)
 {
     $dbr = $query->getDbr();
     if ($this->titleprefixes_) {
         $prefixConds = array();
         foreach ($this->titleprefixes_ as $prefix) {
             $prefixConds[] = 'page_title' . $dbr->buildLike($prefix, $dbr->anyString());
         }
         $query->addConds('(' . implode(' OR ', $prefixConds) . ')');
     }
     foreach ((array) $this->notTitleprefixes_ as $prefix) {
         $query->addConds('page_title NOT' . $dbr->buildLike($prefix, $dbr->anyString()));
     }
     if ($this->titlesuffixes_) {
         $suffixConds = array();
         foreach ($this->titlesuffixes_ as $suffix) {
             $suffixConds[] = 'page_title' . $dbr->buildLike($dbr->anyString(), $suffix);
         }
         $query->addConds('(' . implode(' OR ', $suffixConds) . ')');
     }
     foreach ((array) $this->notTitlesuffixes_ as $suffix) {
         $query->addConds('page_title NOT' . $dbr->buildLike($dbr->anyString(), $suffix));
     }
     if ($this->titlecontains_) {
         $containsConds = array();
         foreach ($this->titlecontains_ as $contains) {
             $containsConds[] = 'page_title' . $dbr->buildLike($dbr->anyString(), $contains, $dbr->anyString());
         }
         $query->addConds('(' . implode(' OR ', $containsConds) . ')');
     }
     foreach ((array) $this->notTitlecontains_ as $contains) {
         $query->addConds('page_title NOT' . $dbr->buildLike($dbr->anyString(), $contains, $dbr->anyString()));
     }
 }
 public function modifyQuery(DpleQuery &$query)
 {
     $categoryFeature = $this->getFeature('DpleFeatureCategory');
     /** Do nothing if no category was defined. */
     if (!isset($categoryFeature) || !$categoryFeature->getLinkedCount()) {
         return;
     }
     $dbr = $query->getDbr();
     /** Otherwise, also fetch the sort key for the first
      *	category. */
     $query->addVars(array('sortkey' => 'cl1.cl_sortkey_prefix'));
     if ($this->extras_) {
         $extraConds = array();
         /** Add conditions based on @ref $extras_. */
         foreach ($this->extras_ as $extra) {
             $extraConds[] = 'cl1.cl_sortkey_prefix' . $dbr->buildLike($dbr->anyString(), "|{$extra}");
         }
         $query->addConds('(' . implode(' OR ', $extraConds) . ')');
     }
     /** Add conditions based on @ref $notExtras_. */
     foreach ((array) $this->notExtras_ as $extra) {
         $query->addConds('cl1.cl_sortkey_prefix NOT ' . $dbr->buildLike($dbr->anyString(), "|{$extra}"));
     }
 }
 /**
  * @brief Modify a given query.
  *
  * Add table aliases `{$tableAlias_}1, {$tableAlias_}2, ...` to
  * DpleQuery::$tables_.
  *
  * @param DpleQuery $query Query object.
  */
 public function modifyQuery(DpleQuery &$query)
 {
     $dbr = $query->getDbr();
     $tableName = $dbr->tableName($this->tableName_);
     $n = 1;
     /** Add conditions based on @ref $linkedTitles_. */
     for ($i = 0; $i < $this->linkedCount_; $i++) {
         $table = "{$tableName} AS {$this->tableAlias_}{$n}";
         $query->addTables($table);
         $query->addJoinCond($table, 'INNER JOIN', $this->transformJoinConds_($dbr, $n, $this->linkedTitles_[$i]));
         $n++;
     }
     /** Add conditions based on @ref $notLinkedTitles_. */
     for ($i = 0; $i < $this->notLinkedCount_; $i++) {
         $table = "{$tableName} AS {$this->tableAlias_}{$n}";
         $query->addTables($table);
         $query->addJoinCond($table, 'LEFT OUTER JOIN', $this->transformJoinConds_($dbr, $n, $this->notLinkedTitles_[$i]));
         $query->addConds(array("{$this->tableAlias_}{$n}.{$this->tableColumn_}" => null));
         $n++;
     }
 }