-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorage.php
More file actions
80 lines (65 loc) · 1.94 KB
/
Storage.php
File metadata and controls
80 lines (65 loc) · 1.94 KB
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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Storage
*
* @author Bevzyuk
*/
include 'item.php';
class Storage {
protected $mDOM;
public $mDOMroot;
protected $mSorce;
protected $mSchema;
protected $mPath;
public $mItem;
public $length;
function __construct($xmlsrc, $schemasrc)
{
$this->mDOM=new DOMDocument();// В конструктор
$this->mPath='./DB';
$this->mSorce=$xmlsrc;
$this->mSchema=$schemasrc;
$this->mDOM->load($this->mPath.$this->mSorce);
$this->mDOM->schemaValidate($this->mPath.$this->mSchema);
$nodelist=$this->mDOM->getElementsByTagName('item');
$this->mDOMroot= $this->mDOM->documentElement;
$this->length=$nodelist->length;
$this->mItem =new Item($nodelist->item(0));
$this->mItem->setRoot($this->mDOMroot);
}
//Save curent DOMDocument in to file
function save()
{
$this->mDOM->save($this->mPath.$this->mSorce);
}
//validate XML Schema check;
function validate()
{
if($this->mDOM->schemaValidate($this->mPath.$this->mSchema))
return TRUE;
else return FALSE;
}
//set curent Item by index
function getItemElbyIndex($index)
{
$Nodelist=$this->mDOMroot->getElementsByTagName("item");
$newItem=$Nodelist->item($index);
$this->mItem->setItem($newItem);
}
//remove curent Item
function removeItem()
{
$this->mItem->remove();
}
function modSet($Name,$Weight,$Category,$Location){
$this->mItem->modItem('name',$Name);
$this->mItem->modItem('weight',$Weight);
$this->mItem->modItem('category',$Category);
$this->mItem->modItem('location',$Location);
}
}
?>