예제 #1
0
        $myfast = 2;
    }
    if ($sortby == 'time' or $sortby == 'time_reverse') {
        $myfast = 99;
    }
} else {
    $myfast = 99;
}
//Lets start!
//We get the categories we need
$starttime = microtime(true);
//get all articles in category with ns == 14 (category ns)
$data = db_get_articles_in_category($language, $category, $depth - 1, 14, $exclude);
if (count($data) == 0) {
    $category = utf8_encode($category);
    $data = db_get_articles_in_category($language, $category, $depth - 1, 14, $exclude);
}
//now also add the root category itself
if (!isset($data[$category])) {
    array_unshift($data, $category);
}
print "Durchsuche " . count($data) . " Kategorien.";
$output = array();
foreach ($data as $d) {
    $my_unreviewed = db_get_unreviewed($language, $d, $myfast, $namespace);
    foreach ($my_unreviewed as $k => $v) {
        // Show each article only once
        if (isset($output[$k])) {
            unset($my_unreviewed[$k]);
        }
    }
예제 #2
0
function db_get_articles_in_category($language, $category, $depth = 0, $namespace = 0, $exclude = array(), &$done_cats = array(), $no_redirects = false, $limit = '', $project = 'wikipedia', $only_redirects = false)
{
    //print $done_cats[0] . $done_cats[1] . $category . "<br/>";
    if (false) {
        if ($category == 'Militärischer_Verband_(Schweiz)') {
            print 'dfd';
        }
        if ($category == 'Fernsehen_(Schweiz)') {
            print $category;
            print $exclude[2] . '<br/>';
            print $exclude[3] . '<br/>';
        }
        if (in_array($category, $exclude)) {
            print "excluding {$category}";
        }
    }
    if (in_array($category, $done_cats)) {
        return array();
    }
    if (in_array($category, $exclude)) {
        return array();
    }
    $mysql_con = db_get_con_new($language, $project);
    //$db = get_db_name ( $language , $project ) ;
    $db = $language . 'wiki_p';
    make_db_safe($category);
    if ($limit != '') {
        $limit = "LIMIT {$limit}";
    }
    $limit = str_replace('LIMIT LIMIT', 'LIMIT', $limit);
    // Some odd bug
    $ret = array();
    $subcats = array();
    $red = $no_redirects ? ' AND page_is_redirect=0' : '';
    if ($only_redirects) {
        $red = ' AND page_is_redirect=1';
    }
    $sql = "SELECT page_title,page_namespace FROM page,categorylinks \n        WHERE page_id=cl_from AND cl_to=\"{$category}\" {$red} {$limit}";
    //  print "TESTING : $depth - $category : $sql<br/>" ;
    $res = mysql_db_query($db, $sql, $mysql_con);
    while ($o = mysql_fetch_object($res)) {
        if (!isset($o->page_namespace)) {
            continue;
        }
        if ($o->page_namespace == 14 and ($depth > 0 or $depth < -99)) {
            $subcats[] = $o->page_title;
            if ($namespace >= 0 and $o->page_namespace != $namespace) {
                continue;
            }
        } else {
            if ($namespace >= 0 and $o->page_namespace != $namespace) {
                continue;
            }
        }
        if (in_array($o->page_title, $exclude)) {
            continue;
        }
        if (substr($o->page_title, 0, 11) == 'Grasshopper') {
            print $category;
        }
        $ret[$o->page_title] = $o->page_title;
        //      print "TESTING : $depth - $category / " . $o->page_title . "<br/>" ;
    }
    mysql_free_result($res);
    $done_cats[] = $category;
    foreach ($subcats as $sc) {
        //      print "Testing : $depth - $sc<br/>" ;
        $ret2 = db_get_articles_in_category($language, $sc, $depth - 1, $namespace, $exclude, $done_cats, $no_redirects, $limit, $project);
        foreach ($ret2 as $k => $v) {
            $ret[$k] = $v;
        }
    }
    return $ret;
}