Merge pull request #506 from DakuTree/bugfixes

Fixes #505 & other small fixes
This commit is contained in:
Shish 2015-08-12 10:41:00 +01:00
commit 6c304420a6
4 changed files with 44 additions and 32 deletions

View File

@ -1168,6 +1168,7 @@ class Tag {
*/ */
public static function resolve_alias($tag) { public static function resolve_alias($tag) {
assert('is_string($tag)'); assert('is_string($tag)');
global $database;
$negative = false; $negative = false;
if(!empty($tag) && ($tag[0] == '-')) { if(!empty($tag) && ($tag[0] == '-')) {
@ -1175,14 +1176,18 @@ class Tag {
$tag = substr($tag, 1); $tag = substr($tag, 1);
} }
global $database;
$newtag = $database->get_one( $newtag = $database->get_one(
$database->scoreql_to_sql("SELECT newtag FROM aliases WHERE SCORE_STRNORM(oldtag)=SCORE_STRNORM(:tag)"), $database->scoreql_to_sql("SELECT newtag FROM aliases WHERE SCORE_STRNORM(oldtag)=SCORE_STRNORM(:tag)"),
array("tag"=>$tag)); array("tag"=>$tag)
);
if(empty($newtag)) { if(empty($newtag)) {
//tag has no alias, use old tag
$newtag = $tag; $newtag = $tag;
} }
return $negative ? "-$newtag" : $newtag;
return !$negative ? $newtag : preg_replace("/(\S+)/", "-$1", $newtag);
} }
/** /**

View File

@ -1257,39 +1257,40 @@ function full_copy($source, $target) {
* @return array file list * @return array file list
*/ */
function list_files(/*string*/ $base, $_sub_dir="") { function list_files(/*string*/ $base, $_sub_dir="") {
assert(is_dir($base)); assert(is_dir($base));
$file_list = array(); $file_list = array();
$files = array(); $files = array();
$dir = opendir("$base/$_sub_dir"); $dir = opendir("$base/$_sub_dir");
while($f = readdir($dir)) { while($f = readdir($dir)) {
$files[] = $f; $files[] = $f;
} }
closedir($dir); closedir($dir);
sort($files); sort($files);
foreach($files as $filename) { foreach($files as $filename) {
$full_path = "$base/$_sub_dir/$filename"; $full_path = "$base/$_sub_dir/$filename";
if(is_link($full_path)) { if(is_link($full_path)) {
// ignore // ignore
} }
else if(is_dir($full_path)) { else if(is_dir($full_path)) {
if($filename == "." || $filename == "..") { if(!($filename == "." || $filename == "..")) {
$file_list = array_merge( //subdirectory found
$file_list, $file_list = array_merge(
list_files($base, "$_sub_dir/$filename") $file_list,
); list_files($base, "$_sub_dir/$filename")
} );
} }
else { }
$full_path = str_replace("//", "/", $full_path); else {
$file_list[] = $full_path; $full_path = str_replace("//", "/", $full_path);
} $file_list[] = $full_path;
} }
}
return $file_list; return $file_list;
} }

View File

@ -24,6 +24,12 @@ class BulkAdd extends Extension {
$list = add_dir($_POST['dir']); $list = add_dir($_POST['dir']);
if(strlen($list) > 0) { if(strlen($list) > 0) {
$this->theme->add_status("Adding files", $list); $this->theme->add_status("Adding files", $list);
} else {
if(is_dir($_POST['dir'])) {
$this->theme->add_status("No files in directory", "No files exists in specified directory ({$_POST['dir']}).");
} else {
$this->theme->add_status("Directory does not exist", "Specified directory does not exist ({$_POST['dir']}).");
}
} }
$this->theme->display_upload_results($page); $this->theme->display_upload_results($page);
} }

View File

@ -143,7 +143,7 @@ class PoolsTheme extends Themelet {
<br><a href="'.make_link("pool/updated").'">Pool Changes</a> <br><a href="'.make_link("pool/updated").'">Pool Changes</a>
'; ';
$page->add_block(new Block($nav_html, null, "left", 5)); $page->add_block(new Block($nav_html, null, "left", 5, "indexnavleft"));
$page->add_block(new Block("Pool Navigation", $poolnav_html, "left", 10)); $page->add_block(new Block("Pool Navigation", $poolnav_html, "left", 10));
if(count($pools) == 1) { if(count($pools) == 1) {