Open Journal Systems  2.4.4
 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  unset($result);
44 
45  return $site;
46  }
47 
52  function newDataObject() {
53  return new Site();
54  }
55 
62  function &_returnSiteFromRow(&$row, $callHook = true) {
63  $site = $this->newDataObject();
64  $site->setRedirect($row['redirect']);
65  $site->setMinPasswordLength($row['min_password_length']);
66  $site->setPrimaryLocale($row['primary_locale']);
67  $site->setOriginalStyleFilename($row['original_style_file_name']);
68  $site->setInstalledLocales(isset($row['installed_locales']) && !empty($row['installed_locales']) ? explode(':', $row['installed_locales']) : array());
69  $site->setSupportedLocales(isset($row['supported_locales']) && !empty($row['supported_locales']) ? explode(':', $row['supported_locales']) : array());
70 
71  if ($callHook) HookRegistry::call('SiteDAO::_returnSiteFromRow', array(&$site, &$row));
72 
73  return $site;
74  }
75 
80  function insertSite(&$site) {
81  $returner = $this->update(
82  'INSERT INTO site
83  (redirect, min_password_length, primary_locale, installed_locales, supported_locales, original_style_file_name)
84  VALUES
85  (?, ?, ?, ?, ?, ?)',
86  array(
87  $site->getRedirect(),
88  (int) $site->getMinPasswordLength(),
89  $site->getPrimaryLocale(),
90  join(':', $site->getInstalledLocales()),
91  join(':', $site->getSupportedLocales()),
92  $site->getOriginalStyleFilename()
93  )
94  );
95  return $returner;
96  }
97 
102  function updateObject(&$site) {
103  return $this->update(
104  'UPDATE site
105  SET
106  redirect = ?,
107  min_password_length = ?,
108  primary_locale = ?,
109  installed_locales = ?,
110  supported_locales = ?,
111  original_style_file_name = ?',
112  array(
113  $site->getRedirect(),
114  (int) $site->getMinPasswordLength(),
115  $site->getPrimaryLocale(),
116  join(':', $site->getInstalledLocales()),
117  join(':', $site->getSupportedLocales()),
118  $site->getOriginalStyleFilename()
119  )
120  );
121  }
122 
123  function updateSite(&$site) {
124  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
125  return $this->updateObject($site);
126  }
127 }
128 
129 ?>
& _returnSiteFromRow(&$row, $callHook=true)
Definition: SiteDAO.inc.php:62
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
& getSite()
Definition: SiteDAO.inc.php:32
updateObject(&$site)
Operations for retrieving and modifying the Site object.
Definition: SiteDAO.inc.php:20
getVar($section, $key, $default=null)
Definition: Config.inc.php:34
call($hookName, $args=null)
Describes system-wide site properties.
Definition: Site.inc.php:22
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
insertSite(&$site)
Definition: SiteDAO.inc.php:80
newDataObject()
Definition: SiteDAO.inc.php:52