com web/doc: Don't Repeat Yourself: include/lib_revcheck.in c.php
| From: | sobak@php.net | Date: | Tue, 24 Jun 2014 10:38:27 +0000 |
| Subject: | com web/doc: Don't Repeat Yourself: include/lib_revcheck.in c.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-2396@lists.php.net to get a copy of this message | ||
Commit: 8ccfbc3eb4a83df9dfd8e036ff0ec520d6c90134
Author: Sobak <msobaczewski@gmail.com> Tue, 24 Jun 2014 12:38:27 +0200
Parents: 67c7ede0bbea6f2b005edc828b1267a47687d153
Branches: master
Link: http://git.php.net/?p=web/doc.git;a=commitdiff;h=8ccfbc3eb4a83df9dfd8e036ff0ec520d6c90134
Log:
Don't Repeat Yourself
Changed paths:
M include/lib_revcheck.inc.php
Diff:
diff --git a/include/lib_revcheck.inc.php b/include/lib_revcheck.inc.php
index 3dd1be4..2beafd4 100644
--- a/include/lib_revcheck.inc.php
+++ b/include/lib_revcheck.inc.php
@@ -58,81 +58,23 @@ function get_dirs($idx, $lang) {
return $tmp;
}
-// return an array with the outdated files in $dir
-function get_outdated_files($idx, $lang, $dir)
+// return an array with the outdated files; can be optionally filtered by user or dir
+function get_outdated_files($idx, $lang, $filter = null, $value = null)
{
- $sql = 'SELECT
- a.status as status,
- a.name as file,
- a.maintainer as maintainer,
- c.revision as en_rev,
- a.revision as trans_rev,
- b.name AS name,
- a.dir as dir
- FROM
- files a,
- dirs b
- LEFT JOIN
- files c
- ON
- c.name = a.name
- AND
- c.dir = a.dir
- WHERE
- b.id = a.dir
- AND
- a.lang="' . $lang . '"
- AND
- c.lang="en"
- AND
- a.dir = "' . (int)$dir . '"
- AND
- a.revision != c.revision ORDER BY b.name';
- $result = $idx->query($sql);
- $tmp = array();
- while ($r = $result->fetchArray()) {
- $tmp[] = array(
- 'name' => $r['name'],
- 'en_rev' => $r['en_rev'],
- 'trans_rev' => $r['trans_rev'],
- 'status' => $r['status'],
- 'maintainer' => $r['maintainer'],
- 'file' => $r['file']);
+ $sql = 'SELECT a.status, a.name AS file, a.maintainer, c.revision AS en_rev, a..revision
AS trans_rev, b.name AS name, a.dir AS dir
+ FROM files a, dirs b
+ LEFT JOIN files c ON c.name = a.name AND c.dir = a.dir
+ WHERE b.id = a.dir AND a.lang="' . $lang . '" AND a.revision != c..revision
AND c.lang="en" ';
+
+ if ($filter == 'dir') {
+ $sql .= 'AND a.dir = '.(int)$value;
+ }
+ elseif ($filter == 'translator') {
+ $sql .= 'AND a.maintainer =
"'.SQLite3::escapeString($value).'"';
}
- return $tmp;
-}
+ $sql .= ' ORDER BY b.name';
-// return an array with the outdated files maintained by $user
-function get_outdated_translator_files($idx, $lang, $user)
-{
- $sql = 'SELECT
- a.status as status,
- a.name as file,
- a.maintainer as maintainer,
- c.revision as en_rev,
- a.revision as trans_rev,
- b.name AS name,
- a.dir as dir
- FROM
- files a,
- dirs b
- LEFT JOIN
- files c
- ON
- c.name = a.name
- AND
- c.dir = a.dir
- WHERE
- b..id = a.dir
- AND
- a.lang="' . $lang . '"
- AND
- c.lang="en"
- AND
- a.maintainer = \'' . SQLite3::escapeString($user) . '\'
- AND
- a.revision != c.revision ORDER BY b.name';
$result = $idx->query($sql);
$tmp = array();
while ($r = $result->fetchArray()) {