blob: 96673daba8a772ea0cc1ff5850417dad54cf1487 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?
require_once 'header.php';
if(!$tree) {
require_once 'class.portage.tree.php';
$tree = new PortageTree();
}
require_once 'class.portage.category.php';
require_once 'class.db.category.php';
$table = 'category';
$arr = $tree->getCategories();
$arr_diff = importDiff($table, $arr);
if(count($arr_diff['delete'])) {
foreach($arr_diff['delete'] as $name) {
$sql = "DELETE FROM $table WHERE name = ".$db->quote($name).";";
shell::msg($sql);
$db->query($sql);
}
}
if(count($arr_diff['insert'])) {
foreach($arr_diff['insert'] as $name) {
$arr_insert = array('name' => $name);
$db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT);
}
}
// FIXME I should check the mtimes of the directories
// instead, just to get an idea of when things were
// last changed. Also, store the metadata mtime.
// Update descriptions
if($verbose)
shell::msg("Updating descriptions");
$sql = "SELECT name, id FROM category;";
$arr = $db->getAssoc($sql);
foreach($arr as $category_name => $category) {
$db_category = new DBCategory($category);
$c = new PortageCategory($category_name);
if($db_category->description != $c->description['en'])
$db_category->description = $c->description['en'];
}
?>
|