/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to classes/resolution.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class RESOLUTION {
 
4
 var $cfg;
 
5
 
 
6
 function __construct($minimal = 0, &$config = false) {
 
7
    global $ADEI_CACHE;
 
8
    
 
9
    if ($minimal) {
 
10
        $this->cfg = array();
 
11
 
 
12
        if ($config) $cfg = &$config;
 
13
        else $cfg = &$ADEI_CACHE;
 
14
 
 
15
        foreach ($cfg as $res) {
 
16
            if ($res['res'] < $minimal) break;
 
17
            else array_push($this->cfg, $res);
 
18
        }
 
19
        array_push($this->cfg, array("min" => -1, "res" => 0));
 
20
    } else {
 
21
        if ($config) {
 
22
            $this->cfg = $config;
 
23
            array_push($this->cfg, array("min" => -1, "res" => 0));
 
24
        } else $this->cfg = &$ADEI_CACHE;
 
25
    }
 
26
}
 
27
 
 
28
 function RAW() {
 
29
    return sizeof($this->cfg) - 1;
 
30
 }
 
31
 
 
32
 function Minimal() {
 
33
    return sizeof($this->cfg) - 2;
 
34
 }
 
35
 
 
36
 function Smaller($res) {
 
37
    if (isset($this->cfg[$res + 1])) return $res + 1;
 
38
    return false;
 
39
 }
 
40
 
 
41
 function Larger($res) {
 
42
    if ($res > 0) return $res - 1;
 
43
    return false;
 
44
 }
 
45
 
 
46
 function Get(INTERVAL &$ivl, $amount = 0) {
 
47
    if ($amount) {
 
48
        for ($res = 0; isset($this->cfg[$res]);$res++)
 
49
            if ((!$this->cfg[$res]["res"])||(($ivl->window_size/$this->cfg[$res]["res"])>$amount)) {
 
50
                return $res;
 
51
            }
 
52
    } else {
 
53
        for ($res = 0; isset($this->cfg[$res]);$res++)
 
54
            if ($ivl->window_size > $this->cfg[$res]["min"]) {
 
55
                return $res;
 
56
            }
 
57
    }
 
58
    
 
59
 
 
60
/* 
 
61
    for ($res = 0; isset($this->cfg[$res]);$res++)
 
62
        if (($ivl->window_size > $this->cfg[$res]["min"])&&((!$this->cfg[$res]["res"])||(($ivl->window_size/$this->cfg[$res]["res"])>$amount)))
 
63
            return $res;
 
64
 
 
65
    $f=fopen("/tmp/xxx3", "w");
 
66
    fprintf($f, $ivl->window_size . "\n");
 
67
    fprintf($f, "%i %i %i\n", $ivl->window_size, (!$this->cfg[$res-1]["res"]), (($ivl->window_size/$this->cfg[$res-1]["res"])>$amount));
 
68
    fprintf($f, print_r($this->cfg[$res-1], true));
 
69
    fprintf($f, print_r($ivl, true));
 
70
    fclose($f);
 
71
*/
 
72
 
 
73
    if ($ivl->window_size <= 0)
 
74
        throw new ADEIException(translate("Invalid WINDOW %s is specified", $ivl->window_start . '+' . $ivl->window_size));
 
75
    else    
 
76
        throw new ADEIException(translate("Internal Error in module RESOLUTION"));
 
77
 }
 
78
 
 
79
 function GetWindowSize($res) {
 
80
    return $this->cfg[$res]["res"];
 
81
 }
 
82
}
 
83
 
 
84
array_push($ADEI_CACHE, array("min" => -1, "res" => 0));
 
85
 
 
86
?>
 
 
b'\\ No newline at end of file'