Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
SiteDAO.inc.php
1 <?php
2 
18 import('lib.pkp.classes.site.Site');
19 
20 class SiteDAO extends DAO {
24  function SiteDAO() {
25  parent::DAO();
26  }
27 
32  function &getSite() {
33  $site = null;
34  $result = $this->retrieve(
35  'SELECT * FROM site'
36  );
37 
38  if ($result->RecordCount() != 0) {
39  $site = $this->_returnSiteFromRow($result->GetRowAssoc(false));
40  }
41 
42  $result->Close();
43  return $site;
44  }
45 
50  function newDataObject() {
51  return new Site();
52  }
53 
60  function &_returnSiteFromRow($row, $callHook = true) {
61  $site = $this->newDataObject();
62  $site->setRedirect($row['redirect']);
63  $site->setMinPasswordLength($row['min_password_length']);
64  $site->setPrimaryLocale($row['primary_locale']);
65  $site->setOriginalStyleFilename($row['original_style_file_name']);
66  $site->setInstalledLocales(isset($row['installed_locales']) && !empty($row['installed_locales']) ? explode(':', $row['installed_locales']) : array());
67  $site->setSupportedLocales(isset($row['supported_locales']) && !empty($row['supported_locales']) ? explode(':', $row['supported_locales']) : array());
68 
69  if ($callHook) HookRegistry::call('SiteDAO::_returnSiteFromRow', array(&$site, &$row));
70 
71  return $site;
72  }
73 
78  function insertSite(&$site) {
79  $returner = $this->update(
80  'INSERT INTO site
81  (redirect, min_password_length, primary_locale, installed_locales, supported_locales, original_style_file_name)
82  VALUES
83  (?, ?, ?, ?, ?, ?)',
84  array(
85  $site->getRedirect(),
86  (int) $site->getMinPasswordLength(),
87  $site->getPrimaryLocale(),
88  join(':', $site->getInstalledLocales()),
89  join(':', $site->getSupportedLocales()),
90  $site->getOriginalStyleFilename()
91  )
92  );
93  return $returner;
94  }
95 
100  function updateObject(&$site) {
101  return $this->update(
102  'UPDATE site
103  SET
104  redirect = ?,
105  min_password_length = ?,
106  primary_locale = ?,
107  installed_locales = ?,
108  supported_locales = ?,
109  original_style_file_name = ?',
110  array(
111  $site->getRedirect(),
112  (int) $site->getMinPasswordLength(),
113  $site->getPrimaryLocale(),
114  join(':', $site->getInstalledLocales()),
115  join(':', $site->getSupportedLocales()),
116  $site->getOriginalStyleFilename()
117  )
118  );
119  }
120 }
121 
122 ?>
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
& getSite()
Definition: SiteDAO.inc.php:32
& _returnSiteFromRow($row, $callHook=true)
Definition: SiteDAO.inc.php:60
updateObject(&$site)
Operations for retrieving and modifying the Site object.
Definition: SiteDAO.inc.php:20
static call($hookName, $args=null)
Describes system-wide site properties.
Definition: Site.inc.php:23
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
insertSite(&$site)
Definition: SiteDAO.inc.php:78
newDataObject()
Definition: SiteDAO.inc.php:50