ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

CitationDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('citation.Citation');
19 
20 class CitationDAO extends DAO {
26  function insertCitation(&$citation) {
27  $this->update(
28  sprintf('INSERT INTO citations
29  (assoc_type, assoc_id, citation_state, raw_citation, edited_citation, parse_score, lookup_score)
30  VALUES
31  (?, ?, ?, ?, ?, ?, ?)'),
32  array(
33  (integer)$citation->getAssocType(),
34  (integer)$citation->getAssocId(),
35  (integer)$citation->getCitationState(),
36  $citation->getRawCitation(),
37  $citation->getEditedCitation(),
38  $citation->getParseScore(),
39  $citation->getLookupScore()
40  )
41  );
42  $citation->setId($this->getInsertId());
43  $this->_updateCitationMetadata($citation, false);
44  return $citation->getId();
45  }
46 
52  function &getCitation($citationId) {
53  $result =& $this->retrieve(
54  'SELECT * FROM citations WHERE citation_id = ?', $citationId
55  );
56 
57  $citation = null;
58  if ($result->RecordCount() != 0) {
59  $citation =& $this->_fromRow($result->GetRowAssoc(false));
60  $this->getDataObjectSettings('citation_settings', 'citation_id', $citation->getId(), $citation);
61  }
62 
63  $result->Close();
64  unset($result);
65 
66  return $citation;
67  }
68 
76  function &getCitationsByAssocId($assocType, $assocId, $rangeInfo = null) {
77  $result =& $this->retrieveRange(
78  'SELECT *
79  FROM citations
80  WHERE assoc_type = ? AND assoc_id = ?
81  ORDER BY citation_id DESC',
82  array($assocType, $assocId),
83  $rangeInfo
84  );
85 
86  $returner = new DAOResultFactory($result, $this, '_fromRow', array('id'));
87  return $returner;
88  }
89 
94  function updateCitation(&$citation) {
95  $returner = $this->update(
96  'UPDATE citations
97  SET assoc_type = ?,
98  assoc_id = ?,
99  citation_state = ?,
100  raw_citation = ?,
101  edited_citation = ?,
102  parse_score = ?,
103  lookup_score = ?
104  WHERE citation_id = ?',
105  array(
106  (integer)$citation->getAssocType(),
107  (integer)$citation->getAssocId(),
108  (integer)$citation->getCitationState(),
109  $citation->getRawCitation(),
110  $citation->getEditedCitation(),
111  $citation->getParseScore(),
112  $citation->getLookupScore(),
113  (integer)$citation->getId()
114  )
115  );
116  $this->_updateCitationMetadata($citation);
117  }
118 
124  function deleteCitation(&$citation) {
125  return $this->deleteCitationById($citation->getId());
126  }
127 
133  function deleteCitationById($citationId) {
134  $params = array((int)$citationId);
135  $this->update('DELETE FROM citation_settings WHERE citation_id = ?', $params);
136  return $this->update('DELETE FROM citations WHERE citation_id = ?', $params);
137  }
138 
145  function deleteCitationsByAssocId($assocType, $assocId) {
146  $citations =& $this->getCitationsByAssocId($assocType, $assocId);
147  while (($citation =& $citations->next())) {
148  $this->deleteCitationById($citation->getId());
149  unset($citation);
150  }
151  return true;
152  }
153 
154 
155  //
156  // Protected helper methods
157  //
162  function getInsertId() {
163  return parent::getInsertId('citations', 'citation_id');
164  }
165 
166 
167  //
168  // Private helper methods
169  //
174  function &_newDataObject() {
175  $citation = new Citation();
176  return $citation;
177  }
178 
185  function &_fromRow(&$row) {
186  $citation =& $this->_newDataObject();
187  $citation->setId($row['citation_id']);
188  $citation->setAssocType($row['assoc_type']);
189  $citation->setAssocId($row['assoc_id']);
190  $citation->setCitationState($row['citation_state']);
191  $citation->setRawCitation($row['raw_citation']);
192  $citation->setEditedCitation($row['edited_citation']);
193  $citation->setParseScore($row['parse_score']);
194  $citation->setLookupScore($row['lookup_score']);
195 
196  $this->getDataObjectSettings('citation_settings', 'citation_id', $row['citation_id'], $citation);
197 
198  return $citation;
199  }
200 
205  function _updateCitationMetadata(&$citation) {
206  // Persist citation meta-data
207  $this->updateDataObjectSettings('citation_settings', $citation,
208  array('citation_id' => $citation->getId()));
209  }
210 }
211 
212 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
Operations for retrieving and modifying Citation objects.
& getCitationsByAssocId($assocType, $assocId, $rangeInfo=null)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
deleteCitation(&$citation)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
& _fromRow(&$row)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
deleteCitationById($citationId)
_updateCitationMetadata(&$citation)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
insertCitation(&$citation)
& getCitation($citationId)
updateCitation(&$citation)
Class representing a citation (bibliographic reference)
deleteCitationsByAssocId($assocType, $assocId)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186