示例#1
0
 public static function CountDownloads($category)
 {
     // get category id
     $categoryid = $category->get('categoryid');
     // count files immediately parented to this category
     $downloads = Download_File::DAOFactory();
     Download::SetCategoryId($downloads, $categoryid);
     $count = $downloads->getTotal();
     // count children
     $subcats = Download_Category::DAOFactory();
     Download::SetParentId($subcats, $categoryid);
     foreach ($subcats->getAll() as $subcat) {
         $count += self::CountDownloads($subcat);
     }
     return $count;
 }
示例#2
0
文件: delete.php 项目: ssrsfs/blg
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
    return;
}
// create category with the given id
$categoryid = @$_POST['categoryid'];
$category = new Download_Category($categoryid);
// download category must exist to proceed
if (!$category->exists()) {
    Typeframe::Redirect('Invalid category specified.', $typef_app_dir, -1);
    return;
}
// make sure the category is not in use
$categories = Download_Category::DAOFactory();
$categories->select()->where('parentid = ?', $categoryid);
$catCount = $categories->getTotal();
$files = Download_File::DAOFactory();
$files->select()->where('categoryid = ?', $categoryid);
$fileCount = $files->getTotal();
if ($catCount > 0 || $fileCount > 0) {
    $message = 'Unable to delete category. It is in use by';
    $categories = 1 == $catCount ? 'category' : 'categories';
    if ($catCount > 0) {
        $message .= " {$catCount} {$categories}";
    }
    $files = 1 == $fileCount ? 'file' : 'files';
    if ($fileCount > 0) {
        $message .= ($catCount > 0 ? ' and' : '') . " {$fileCount} {$files}";
    }
    Typeframe::Redirect("{$message}.", $typef_app_dir, -1);
    return;
}