/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php

require($ADEI_ROOTDIR . "/classes/drawtext.php");


class WELCOME extends DRAWText {
 var $req;
 var $height, $width;
 var $graph;
 
 var $tmpfile;
 var $ready;
 
 function __construct(REQUEST $req = NULL) {
    parent::__construct($req);

    if (is_file($TMP_PATH . "/" .  $this->tmpfile)) $this->ready = true;
    else $this->ready = false;
 }

 function GetTmpFile() {
    global $ADEI_SESSION;
    global $TMP_PATH;

    $dir = "clients/" . $ADEI_SESSION . "/";

    if (!is_dir($TMP_PATH . "/" .  $dir)) {
	if (!@mkdir($TMP_PATH . "/" . $dir, 0755, true)) 
	    throw new ADEIException(translate("DRAW class have not access to the temporary directory"));
    }

    return $dir . "welcome-" . $this->width . "x" . $this->height .  ".png";
 }

 
 function Create() {
    if ($this->ready) return;
    
    $this->graph = new CanvasGraph($this->width, $this->height, 'auto');
    $this->graph->SetMargin(5,11,6,11);
/*
    $this->graph->SetShadow();
    $this->graph->SetMarginColor( "teal");
    $this->graph->InitFrame(); 
*/    

    $hpos = 15;
    
    $text = new Text("ADEI", $this->width/2, $hpos);
    $text->SetFont(FF_ARIAL, FS_BOLD, 24);
    $text->Align('center', 'top');
    $text->Stroke( $this->graph->img); 

    $hpos += $text->GetTextHeight($this->graph->img) + 10;

//    $msg = "Welcome to the Advanced Data Extraction Infrastructure! Please";
    $msg = preg_replace(
	array("/\n([^\n])/"),
	array(' \1'),
	file_get_contents("docs/welcome.txt")
    );
    

    $text_width = $this->width - 50;
    if ($text_width < 100) return;

    $text = new Text($msg, $this->width/2, $hpos);
    $text->SetFont(FF_ARIAL, FS_NORMAL, 18);
    $text->Align('center', 'top');

    $width = $text->GetWidth($this->graph->img);
    if ($width > $text_width) {
	$char_width = ceil($width / strlen($msg));
	$cpl = $text_width / $char_width;

	$wmsg = wordwrap($msg, $cpl, "\n", true);
	$text->Set($wmsg);
	
	$width = $text->GetWidth($this->graph->img);
        while (($width > $text_width)&&($cpl>10)) {
	    $cpl-=$cpl/10;
	    $wmsg = wordwrap($msg, $cpl, "\n", true);
	    $text->Set($wmsg);
	    $width = $text->GetWidth($this->graph->img);
	}
    }


    $text->Stroke( $this->graph->img); 
    

//    $text->ParagraphAlign('center'); 
//    $text->SetBox( "white", "black","gray"); 


/*
//    $text->Align('left', 'top');
//    $text->ParagraphAlign('left'); 
//    $text->SetBox( "white", "black","gray"); 
    
    $width = $text->GetWidth($this->graph->img);
    
*/    
//    $text->Stroke( $this->graph->img); 
 }
}

?>