Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Ajout des tableau de parametre pour le model, variable model_params active

git authored on 21/03/2019 16:25:26
Showing 7 changed files
... ...
@@ -8,16 +8,41 @@ class Modele{
8 8
 		
9 9
 		if(file_exists(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model')){
10 10
 			$fichier = file(MODELS_PATH.DIRECTORY_SEPARATOR.$base_param['name'].'.model');
11
+			$params = array();
11 12
 			foreach ($fichier as $ligne_num => $ligne) {
12
-                if (preg_match("#[ ]*([a-zA-Z-_+]*)[ ]*[:][ ]*([a-zA-Z-_+ ']*[ ]*)#", $ligne, $matches)) {
13
-                    $this->page[$matches[1]] = $matches[2];
13
+			    //on recherche le pattern des parametres
14
+                if (preg_match("#[ ]*([a-zA-Z_+]*)[ ]*[:][ ]*([a-zA-Z0-9-_+'\{\,\ \}]*[ ]*)#", $ligne, $matches)) {
15
+                    //on recherche le pattern des tableau dans la valeur du paramètre
16
+                    if(preg_match("#{.*}#", $matches[2])) {
17
+                        if (preg_match_all("#(?<capture>[0-9a-zA-Z-_+]*)#", $matches[2], $arrayMatches)) {
18
+                            $array = array();
19
+                            foreach ($arrayMatches['capture'] as $val) {
20
+                                if($val != ''){
21
+                                $array[] = $val;
22
+                                }
23
+                            }
24
+                            $params[$matches[1]] = $array;
25
+                            continue;
26
+                        }
27
+                    }
28
+                    $params[$matches[1]] = $matches[2];
14 29
                 }
15 30
             }
31
+			//définitions des paramètres model obligatoires
32
+            $this->page['name'] = $params['name'];
33
+            $this->page['description'] = $params['description'];
34
+            $this->page['page_title'] = $params['page_title'];
35
+            //ajout des parametres inclues dans le fichier model
36
+            $this->page['model_params'] = $params;
37
+            //ajout des parametres inclues dans l'url
16 38
             $this->page['url_params'] = $base_param['params'];
17 39
 		}else{
40
+            //définitions des paramètres model obligatoires
18 41
 			$this->page['name'] = $base_param['name'];
19
-			$this->page['description'] = $base_param['description'];
20
-			$this->page['params'] = $base_param['params'];
42
+			$this->page['description'] = "";
43
+            $this->page['page_title'] = "";
44
+            //ajout des parametres inclues dans l'url
45
+            $this->page['url_params'] = $base_param['params'];
21 46
 		}
22 47
 	}
23 48
 	
... ...
@@ -9,7 +9,6 @@ class Url
9 9
 
10 10
 	$page = array();
11 11
 	$page['name'] = 'accueil';
12
-	$page['description'] = "";
13 12
 	$page['params'] = array();
14 13
 	$page['control'] = false;
15 14
 
... ...
@@ -2,4 +2,5 @@ name : accueil
2 2
 page_title : Accueil de l'application
3 3
 description : zatou stra bracadabla
4 4
 params : params
5
+array-params : { val1 , val2, int1, int2 }
5 6
 
... ...
@@ -1,7 +1,3 @@
1
-<h1>Page de gestion des adresses IP</h1>
1
+<h1>Page d'accueil et de gestion </h1>
2 2
 <br /><br /><br />
3
-<h2>Possibilités d'afficher toutes les adresses par VLAN et Zone d'adresse</h2>
4
-<h2>Ainsi que de faire des recherches par nom de machine, profil et adresse ip</h2>
5
-<h2>Possibilité d'ajouter/supprimer des VLAN dans la base de données</h2>
6
-<h2>Possibilité de supprimer les adresses ip qui ne sont pas modifiées par Abitop</h2>
7
-<h3>Historisation des ajouts et des suppressions</h3>
8 3
\ No newline at end of file
4
+<?php Dumper::dump($model_params) ?>
9 5
\ No newline at end of file
... ...
@@ -13,7 +13,7 @@
13 13
 
14 14
 /* SITE */
15 15
   Standards: HTML5, CSS3
16
-  Components: Modernizr, jQuery
16
+  Components: <your components>
17 17
   Software:
18 18
 
19 19
 
20 20
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+<?php
2
+
3
+include_once '../application/class/tri.class.php';
4
+
5
+class TriTest extends PHPUnit_Framework_TestCase
6
+{
7
+
8
+	protected $essai;
9
+	
10
+	function testCompareIp(){
11
+            $test_cmp1 = Tri::cmpIp('192.168.1.200','193.168.1.300');
12
+            $test_cmp2 = Tri::cmpIp('192.168.1.200','191.168.1.200');
13
+            $test_cmp3 = Tri::cmpIp('192.168.1.200','192.169.1.300');
14
+            $test_cmp4 = Tri::cmpIp('192.168.1.200','192.167.1.300');
15
+            $test_cmp5 = Tri::cmpIp('192.168.1.200','192.168.2.300');
16
+            $test_cmp6 = Tri::cmpIp('192.168.1.200','192.168.0.300');
17
+            $test_cmp7 = Tri::cmpIp('192.168.1.200','192.168.1.300');
18
+            $test_cmp8 = Tri::cmpIp('192.168.1.200','192.168.1.100');
19
+            $test_cmp9 = Tri::cmpIp('192.168.1.200','192.168.1.200');
20
+
21
+            $this->assertEquals('-1', $test_cmp1);
22
+            $this->assertEquals('1', $test_cmp2);
23
+            $this->assertEquals('-1', $test_cmp3);
24
+            $this->assertEquals('1', $test_cmp4);
25
+            $this->assertEquals('-1', $test_cmp5);
26
+            $this->assertEquals('1', $test_cmp6);
27
+            $this->assertEquals('-1', $test_cmp7);
28
+            $this->assertEquals('1', $test_cmp8);
29
+            $this->assertEquals('0', $test_cmp9);
30
+			//$this->assertNotEquals(10, $essai);
31
+	}
32
+
33
+	function testIntervalIp(){
34
+
35
+	    $interval = array('192.168.1.0','192.168.1.255');
36
+
37
+        $test_interval1 = array('192.168.1.10','192.168.1.25');
38
+        $test_interval2 = array('192.168.0.10','192.168.1.25');
39
+        $test_interval3 = array('192.168.1.25','192.168.2.25');
40
+        $test_interval4 = array('192.168.0.10','192.168.2.25');
41
+        $test_interval5 = array('192.168.0.10','192.168.0.25');
42
+        $test_interval6 = array('192.168.2.10','192.168.2.25');
43
+        $test_interval7 = array('192.168.0.10','192.168.1.0');
44
+        $test_interval8 = array('192.168.1.255','192.168.2.25');
45
+        $test_interval9 = array('192.168.0.10','192.168.1.255');
46
+        $test_interval10 = array('192.168.1.0','192.168.2.25');
47
+        $test_interval11 = array('192.168.1.100','192.168.1.255');
48
+        $test_interval12 = array('192.168.1.0','192.168.1.255');
49
+
50
+        $resultatTest_interval1 = Tri::cmpInterval($interval,$test_interval1);
51
+        $resultatTest_interval2 = Tri::cmpInterval($interval,$test_interval2);
52
+        $resultatTest_interval3 = Tri::cmpInterval($interval,$test_interval3);
53
+        $resultatTest_interval4 = Tri::cmpInterval($interval,$test_interval4);
54
+        $resultatTest_interval5 = Tri::cmpInterval($interval,$test_interval5);
55
+        $resultatTest_interval6 = Tri::cmpInterval($interval,$test_interval6);
56
+        $resultatTest_interval7 = Tri::cmpInterval($interval,$test_interval7);
57
+        $resultatTest_interval8 = Tri::cmpInterval($interval,$test_interval8);
58
+        $resultatTest_interval9 = Tri::cmpInterval($interval,$test_interval9);
59
+        $resultatTest_interval10 = Tri::cmpInterval($interval,$test_interval10);
60
+        $resultatTest_interval11 = Tri::cmpInterval($interval,$test_interval11);
61
+        $resultatTest_interval12 = Tri::cmpInterval($interval,$test_interval12);
62
+
63
+        $this->assertEquals('inclue', $resultatTest_interval1);
64
+        $this->assertEquals('chevauche par le debut', $resultatTest_interval2);
65
+        $this->assertEquals('chevauche par la fin', $resultatTest_interval3);
66
+        $this->assertEquals('est inclue dans', $resultatTest_interval4);
67
+        $this->assertEquals('est different (apres)', $resultatTest_interval5);
68
+        $this->assertEquals('est different (avant)', $resultatTest_interval6);
69
+        $this->assertEquals('forme une jonction par le debut avec', $resultatTest_interval7);
70
+        $this->assertEquals('forme une jonction par la fin avec', $resultatTest_interval8);
71
+        $this->assertEquals('chevauche par la fin (egalité fin)', $resultatTest_interval9);
72
+        $this->assertEquals('chevauche par le debut (egalité debut)', $resultatTest_interval10);
73
+        $this->assertEquals('est inclue dans (egalité fin)', $resultatTest_interval11);
74
+        $this->assertEquals('sont égaux', $resultatTest_interval12);
75
+
76
+    }
77
+	
78
+}
79
+
80
+?>
0 81
\ No newline at end of file
... ...
@@ -1,7 +1,7 @@
1 1
 <phpunit colors="true">
2 2
   <testsuites>
3 3
     <testsuite name="Objet_Fichier">
4
-      <file>./fichiertest.class.php</file>
4
+      <file>./TriTest.class.php</file>
5 5
       <file>./Test.php</file>
6 6
     </testsuite>
7 7
   </testsuites>