CMS  Version 3.9
topic.inc
Go to the documentation of this file.
1 <?
2 /**************************************************************
3 
4  Copyright (c) 2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
37 class Topic extends DataItem
38 {
39  // Fields
40 
41  var $fields = array("topic_id" => Number,
42  "topic" => String
43  );
44 
45  // Relations
46 
47  var $relations = array( "Documents" => Document);
48 
49  function Documents($constraints = "")
50  {
51  return $this->crossReference(Document, DocumentTopicXref, $constraints);
52  }
53 
54  static function getTopicsArray()
55  {
56  $topics = query(Topic, "ORDER BY topic");
57 
58  $tarr = array();
59 
60  foreach($topics as $topic)
61  {
62  $tarr[$topic->topic] = $topic->topic;
63  }
64 
65  return $tarr;
66  }
67 
68  function Topic()
69  {
70  $this->primary_key = "topic_id";
71  $this->table = "topic";
72 
73  $this->default_format = "{topic}";
74 
75  $this->DataItem(func_get_args());
76  }
77 }
78 
79 class DocumentTopicXref extends DataItem
80 {
81  // Fields
82  var $fields = array("document_topic_xref_id" => Number,
83  "document_id" => Number,
84  "topic_id" => Number);
85 
86  // Relations
87 
88  var $relations = array( "Document" => Document,
89  "Topic" => Topic);
90 
91  function Document()
92  {
93  return $this->getRelated(Document);
94  }
95 
96  function Topic()
97  {
98  return $this->getRelated(Topic);
99  }
100 
101  function DocumentTopicXref()
102  {
103  $this->primary_key = "document_topic_xref_id";
104  $this->table = "document_topic_xref";
105 
106  $this->DataItem(func_get_args());
107  }
108 }
109 
110 class GroupTopicXref extends DataItem
111 {
112  // Fields
113  var $fields = array("group_topic_id" => Number,
114  "group_id" => Number,
115  "topic_id" => Number);
116 
117  // Relations
118 
119  var $relations = array( "Group" => Group,
120  "Topic" => Topic);
121 
122  function Grp()
123  {
124  return $this->getRelated(Group);
125  }
126 
127  function Topic()
128  {
129  return $this->getRelated(Topic);
130  }
131 
132  function GroupTopicXref()
133  {
134  $this->primary_key = "group_topic_id";
135  $this->table = "grp_topic_xref";
136 
137  $this->DataItem(func_get_args());
138  }
139 }
140 ?>
This class maps the publication table.
Definition: document.inc:43
Definition: group.inc:35
GroupTopicXref()
Definition: topic.inc:132
This class maps the topic table.
Definition: topic.inc:38
$relations
Definition: topic.inc:47
$fields
Definition: topic.inc:41
Documents($constraints="")
Definition: topic.inc:49
static getTopicsArray()
Definition: topic.inc:54
Topic()
Definition: topic.inc:68
$topics
Definition: group_form.inc:52
$topic
Definition: topic_form.inc:42