From a2fcca15d2f37f70ce19046a519b12acb379313d Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 7 Jul 2013 17:20:33 +0200 Subject: [PATCH] Add classes --- public_html/classes/node.php | 72 +++++++++++++++++++++ public_html/classes/nodetype.php | 36 +++++++++++ public_html/classes/property.php | 82 ++++++++++++++++++++++++ public_html/classes/propertytype.php | 36 +++++++++++ public_html/classes/relationship.php | 81 +++++++++++++++++++++++ public_html/classes/relationshiptype.php | 36 +++++++++++ public_html/classes/tag.php | 33 ++++++++++ 7 files changed, 376 insertions(+) create mode 100644 public_html/classes/node.php create mode 100644 public_html/classes/nodetype.php create mode 100644 public_html/classes/property.php create mode 100644 public_html/classes/propertytype.php create mode 100644 public_html/classes/relationship.php create mode 100644 public_html/classes/relationshiptype.php create mode 100644 public_html/classes/tag.php diff --git a/public_html/classes/node.php b/public_html/classes/node.php new file mode 100644 index 0000000..54856dc --- /dev/null +++ b/public_html/classes/node.php @@ -0,0 +1,72 @@ + array( + "Name" => "Name", + "Notes" => "Notes" + ), + 'numeric' => array( + "TypeId" => "TypeId", + "ParentRevisionId" => "ParentRevisionId", + "FirstRevisionId" => "FirstRevisionId", + "UserId" => "UserId" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'boolean' => array( + "LatestRevision" => "LatestRevision" + ), + 'nodetype' => array( + "Type" => "TypeId" + ), + 'node' => array( + "ParentRevision" => "ParentRevisionId", + "FirstRevision" => "FirstRevisionId" + ), + 'user' => array( + "User" => "UserId" + ) + ); + + public function SaveRevision($user) + { + /* Create a working copy of the current object */ + $this_copy = clone $this; + + /* Create a new object representing the new revision */ + $sNode = clone $this; + $sNode->sId = 0; + $sNode->uParentRevisionId = $this->sId; + $sNode->uUserId = $user->sId; + $sNode->uCreationDate = time(); + $sNode->InsertIntoDatabase(true); + + /* Clear out all changes to the working copy, and save the changed 'latest revision' flag */ + $this_copy->RefreshData(); + $this_copy->uLatestRevision = false; + $this_copy->InsertIntoDatabase(); + + /* Set the same flag on the current object, in case of further operations */ + $this->uLatestRevision = false; + } +} diff --git a/public_html/classes/nodetype.php b/public_html/classes/nodetype.php new file mode 100644 index 0000000..934ea35 --- /dev/null +++ b/public_html/classes/nodetype.php @@ -0,0 +1,36 @@ + array( + "Name" => "Name" + ), + 'numeric' => array( + "UserId" => "UserId" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'user' => array( + "User" => "UserId" + ) + ); +} diff --git a/public_html/classes/property.php b/public_html/classes/property.php new file mode 100644 index 0000000..81bd201 --- /dev/null +++ b/public_html/classes/property.php @@ -0,0 +1,82 @@ + array( + "Name" => "Name", + "Value" => "Value", + "Source" => "Source" + ), + 'numeric' => array( + "TypeId" => "TypeId", + "ParentRevisionId" => "ParentRevisionId", + "FirstRevisionId" => "FirstRevisionId", + "UserId" => "UserId", + "NodeId" => "NodeId", + "RelationshipId" => "RelationshipId", + "Reliability" => "Reliability" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'boolean' => array( + "LatestRevision" => "LatestRevision" + ), + 'propertytype' => array( + "Type" => "TypeId" + ), + 'property' => array( + "ParentRevision" => "ParentRevisionId", + "FirstRevision" => "FirstRevisionId" + ), + 'node' => array( + "Node" => "NodeId" + ), + 'relationship' => array( + "Relationship" => "RelationshipId" + ), + 'user' => array( + "User" => "UserId" + ) + ); + + public function SaveRevision($user) + { + /* Create a working copy of the current object */ + $this_copy = clone $this; + + /* Create a new object representing the new revision */ + $sNode = clone $this; + $sNode->sId = 0; + $sNode->uParentRevisionId = $this->sId; + $sNode->uUserId = $user->sId; + $sNode->uCreationDate = time(); + $sNode->InsertIntoDatabase(true); + + /* Clear out all changes to the working copy, and save the changed 'latest revision' flag */ + $this_copy->RefreshData(); + $this_copy->uLatestRevision = false; + $this_copy->InsertIntoDatabase(); + + /* Set the same flag on the current object, in case of further operations */ + $this->uLatestRevision = false; + } +} diff --git a/public_html/classes/propertytype.php b/public_html/classes/propertytype.php new file mode 100644 index 0000000..46d184a --- /dev/null +++ b/public_html/classes/propertytype.php @@ -0,0 +1,36 @@ + array( + "Name" => "Name" + ), + 'numeric' => array( + "UserId" => "UserId" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'user' => array( + "User" => "UserId" + ) + ); +} diff --git a/public_html/classes/relationship.php b/public_html/classes/relationship.php new file mode 100644 index 0000000..e8aab51 --- /dev/null +++ b/public_html/classes/relationship.php @@ -0,0 +1,81 @@ + array( + "Name" => "Name", + "Source" => "Source", + "Notes" => "Notes" + ), + 'numeric' => array( + "TypeId" => "TypeId", + "ParentRevisionId" => "ParentRevisionId", + "FirstRevisionId" => "FirstRevisionId", + "UserId" => "UserId", + "FromNodeId" => "FromNodeId", + "ToNodeId" => "ToNodeId", + "Reliability" => "Reliability" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'boolean' => array( + "LatestRevision" => "LatestRevision", + "IsBidirectional" => "IsBidirectional" + ), + 'relationshiptype' => array( + "Type" => "TypeId" + ), + 'relationship' => array( + "ParentRevision" => "ParentRevisionId", + "FirstRevision" => "FirstRevisionId" + ), + 'node' => array( + "FromNode" => "FromNodeId", + "ToNode" => "ToNodeId" + ), + 'user' => array( + "User" => "UserId" + ) + ); + + public function SaveRevision($user) + { + /* Create a working copy of the current object */ + $this_copy = clone $this; + + /* Create a new object representing the new revision */ + $sNode = clone $this; + $sNode->sId = 0; + $sNode->uParentRevisionId = $this->sId; + $sNode->uUserId = $user->sId; + $sNode->uCreationDate = time(); + $sNode->InsertIntoDatabase(true); + + /* Clear out all changes to the working copy, and save the changed 'latest revision' flag */ + $this_copy->RefreshData(); + $this_copy->uLatestRevision = false; + $this_copy->InsertIntoDatabase(); + + /* Set the same flag on the current object, in case of further operations */ + $this->uLatestRevision = false; + } +} diff --git a/public_html/classes/relationshiptype.php b/public_html/classes/relationshiptype.php new file mode 100644 index 0000000..113c002 --- /dev/null +++ b/public_html/classes/relationshiptype.php @@ -0,0 +1,36 @@ + array( + "Name" => "Name" + ), + 'numeric' => array( + "UserId" => "UserId" + ), + 'timestamp' => array( + "CreationDate" => "CreationDate" + ), + 'user' => array( + "User" => "UserId" + ) + ); +} diff --git a/public_html/classes/tag.php b/public_html/classes/tag.php new file mode 100644 index 0000000..7ce534c --- /dev/null +++ b/public_html/classes/tag.php @@ -0,0 +1,33 @@ + array( + "Name" => "Name" + ), + 'numeric' => array( + "NodeId" => "NodeId" + ), + 'node' => array( + "Node" => "NodeId" + ) + ); +}