static function Optimize($srctree, $flags = 0) { return SOURCETree::Create(SOURCETree::Parse($srctree, true, $flags), $flags); }
function GetDownloadDetails() { $i = 0; $download = $_GET['dl_id']; $res = $this->cache->GetDownloads($download); $row = mysql_fetch_assoc($res); $opts = array('dl_id' => ''); foreach ($row as $key => $value) { $opts[$key] = $value; } if (!($size = $opts['filesize'])) { $size = "n/a"; } else { if ($size < 1) { $size = "<1 MB"; } else { $size .= " MB"; } } if ($opts['ctype'] == "application/x-zip-compressed") { $format = "zip/{$opts['format']}"; } else { $format = $opts['format']; } if ($row['srctree'] != "") { $res = SOURCETree::Parse($row['srctree']); foreach ($res as $key => $grp) { $req = new DATARequest($grp['props']); $reader = $req->CreateReader(); $itemlist[$key] = $reader->GetItemList(); } } else { $req = new DATARequest($opts); $reader = $req->CreateReader(); $grps = $reader->GetGroups(); $glist = $reader->GetGroupList(); $mask = new MASK($opts); foreach ($glist as $grp => $det) { $itemlist[$det['gid']] = $reader->GetItemList($grps[$i], $mask); $i = $i + 1; } } $window = $this->ParseReadableWindow($opts['window']); if ($opts['status'] == "ERROR") { $download_props['error'] = "Something went wrong while preparing data."; } if ($error = $opts['error']) { $download_props['error'] = $error; } $download_props['window'] = $window; $download_props['format'] = $format; $download_props['size'] = $size; $download_details['props'] = $download_props; foreach ($itemlist as $gid => $items) { if (!is_numeric($gid)) { foreach ($items as $key => $item) { $download_details['groups'][$gid][$key] = array("id" => "{$item['id']}", "name" => "{$item['name']}"); } } } return $download_details; }