Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
PublishedArticleDAO.inc.php
1 <?php
2 
17 import('classes.article.PublishedArticle');
18 
19 class PublishedArticleDAO extends DAO {
20  var $articleDao;
21  var $authorDao;
22  var $galleyDao;
23  var $suppFileDao;
24 
25  var $articleCache;
26  var $articlesInSectionsCache;
27 
28  function _articleCacheMiss(&$cache, $id) {
29  $publishedArticle =& $this->getPublishedArticleByBestArticleId(null, $id, null);
30  $cache->setCache($id, $publishedArticle);
31  return $publishedArticle;
32  }
33 
34  function &_getPublishedArticleCache() {
35  if (!isset($this->articleCache)) {
36  $cacheManager =& CacheManager::getManager();
37  $this->articleCache =& $cacheManager->getObjectCache('publishedArticles', 0, array(&$this, '_articleCacheMiss'));
38  }
39  return $this->articleCache;
40  }
41 
42  function _articlesInSectionsCacheMiss(&$cache, $id) {
43  $articlesInSections =& $this->getPublishedArticlesInSections($id, null);
44  $cache->setCache($id, $articlesInSections);
45  return $articlesInSections;
46  }
47 
48  function &_getArticlesInSectionsCache() {
49  if (!isset($this->articlesInSectionsCache)) {
50  $cacheManager =& CacheManager::getManager();
51  $this->articlesInSectionsCache =& $cacheManager->getObjectCache('articlesInSections', 0, array(&$this, '_articlesInSectionsCacheMiss'));
52  }
53  return $this->articlesInSectionsCache;
54  }
55 
59  function PublishedArticleDAO() {
60  parent::DAO();
61  $this->articleDao =& DAORegistry::getDAO('ArticleDAO');
62  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
63  $this->galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
64  $this->suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
65  }
66 
72  function &getPublishedArticles($issueId) {
73  $primaryLocale = AppLocale::getPrimaryLocale();
74  $locale = AppLocale::getLocale();
75  $publishedArticles = array();
76 
77  $params = array(
78  (int) $issueId,
79  'title',
80  $primaryLocale,
81  'title',
82  $locale,
83  'abbrev',
84  $primaryLocale,
85  'abbrev',
86  $locale,
87  (int) $issueId
88  );
89 
90  $sql = 'SELECT DISTINCT
91  pa.*,
92  a.*,
93  SUBSTRING(COALESCE(stl.setting_value, stpl.setting_value) FROM 1 FOR 255) AS section_title,
94  SUBSTRING(COALESCE(sal.setting_value, sapl.setting_value) FROM 1 FOR 255) AS section_abbrev,
95  COALESCE(o.seq, s.seq) AS section_seq,
96  pa.seq
97  FROM published_articles pa,
98  articles a LEFT JOIN sections s ON s.section_id = a.section_id
99  LEFT JOIN custom_section_orders o ON (a.section_id = o.section_id AND o.issue_id = ?)
100  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
101  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
102  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
103  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
104  WHERE pa.article_id = a.article_id
105  AND pa.issue_id = ?
106  AND a.status <> ' . STATUS_ARCHIVED . '
107  ORDER BY section_seq ASC, pa.seq ASC';
108 
109  $result =& $this->retrieve($sql, $params);
110 
111  while (!$result->EOF) {
112  $publishedArticles[] =& $this->_returnPublishedArticleFromRow($result->GetRowAssoc(false));
113  $result->moveNext();
114  }
115 
116  $result->Close();
117  unset($result);
118 
119  return $publishedArticles;
120  }
121 
125  function getPublishedArticleCountByJournalId($journalId) {
126  $result =& $this->retrieve(
127  'SELECT count(*) FROM published_articles pa, articles a WHERE pa.article_id = a.article_id AND a.journal_id = ? AND a.status <> ' . STATUS_ARCHIVED,
128  (int) $journalId
129  );
130  list($count) = $result->fields;
131  $result->Close();
132  return $count;
133  }
134 
142  function &getPublishedArticlesByJournalId($journalId = null, $rangeInfo = null, $reverse = false) {
143  $primaryLocale = AppLocale::getPrimaryLocale();
144  $locale = AppLocale::getLocale();
145  $params = array(
146  'title',
147  $primaryLocale,
148  'title',
149  $locale,
150  'abbrev',
151  $primaryLocale,
152  'abbrev',
153  $locale
154  );
155  if ($journalId !== null) $params[] = (int) $journalId;
156  $result =& $this->retrieveRange(
157  'SELECT pa.*,
158  a.*,
159  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
160  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
161  FROM published_articles pa
162  LEFT JOIN articles a ON pa.article_id = a.article_id
163  LEFT JOIN issues i ON pa.issue_id = i.issue_id
164  LEFT JOIN sections s ON s.section_id = a.section_id
165  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
166  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
167  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
168  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
169  WHERE i.published = 1
170  ' . ($journalId !== null?'AND a.journal_id = ?':'') . '
171  AND a.status <> ' . STATUS_ARCHIVED . '
172  ORDER BY date_published '. ($reverse?'DESC':'ASC'),
173  $params,
174  $rangeInfo
175  );
176 
177  $returner = new DAOResultFactory($result, $this, '_returnPublishedArticleFromRow');
178  return $returner;
179  }
180 
187  function &getPublishedArticlesInSections($issueId, $useCache = false) {
188  if ($useCache) {
189  $cache =& $this->_getArticlesInSectionsCache();
190  $returner = $cache->get($issueId);
191  return $returner;
192  }
193 
194  $primaryLocale = AppLocale::getPrimaryLocale();
195  $primaryLocale = AppLocale::getPrimaryLocale();
196  $locale = AppLocale::getLocale();
197  $publishedArticles = array();
198 
199  $result =& $this->retrieve(
200  'SELECT DISTINCT
201  pa.*,
202  a.*,
203  SUBSTRING(COALESCE(stl.setting_value, stpl.setting_value) FROM 1 FOR 255) AS section_title,
204  SUBSTRING(COALESCE(sal.setting_value, sapl.setting_value) FROM 1 FOR 255) AS section_abbrev,
205  s.abstracts_not_required AS abstracts_not_required,
206  s.hide_title AS section_hide_title,
207  s.hide_author AS section_hide_author,
208  COALESCE(o.seq, s.seq) AS section_seq,
209  pa.seq
210  FROM published_articles pa,
211  articles a
212  LEFT JOIN sections s ON s.section_id = a.section_id
213  LEFT JOIN custom_section_orders o ON (a.section_id = o.section_id AND o.issue_id = ?)
214  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
215  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
216  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
217  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
218  WHERE pa.article_id = a.article_id
219  AND pa.issue_id = ?
220  AND a.status <> ' . STATUS_ARCHIVED . '
221  ORDER BY section_seq ASC, pa.seq ASC',
222  array(
223  (int) $issueId,
224  'title',
225  $primaryLocale,
226  'title',
227  $locale,
228  'abbrev',
229  $primaryLocale,
230  'abbrev',
231  $locale,
232  (int) $issueId
233  )
234  );
235 
236  $currSectionId = 0;
237  while (!$result->EOF) {
238  $row =& $result->GetRowAssoc(false);
239  $publishedArticle =& $this->_returnPublishedArticleFromRow($row);
240  if ($publishedArticle->getSectionId() != $currSectionId) {
241  $currSectionId = $publishedArticle->getSectionId();
242  $publishedArticles[$currSectionId] = array(
243  'articles'=> array(),
244  'title' => '',
245  'abstractsNotRequired' => $row['abstracts_not_required'],
246  'hideAuthor' => $row['section_hide_author']
247  );
248 
249  if (!$row['section_hide_title']) {
250  $publishedArticles[$currSectionId]['title'] = $publishedArticle->getSectionTitle();
251  }
252  }
253  $publishedArticles[$currSectionId]['articles'][] = $publishedArticle;
254  $result->moveNext();
255  }
256 
257  $result->Close();
258  unset($result);
259 
260  return $publishedArticles;
261  }
262 
270  function &getPublishedArticlesBySectionId($sectionId, $issueId, $simple = false) {
271  $primaryLocale = AppLocale::getPrimaryLocale();
272  $locale = AppLocale::getLocale();
273  $func = $simple?'_returnSimplePublishedArticleFromRow':'_returnPublishedArticleFromRow';
274  $publishedArticles = array();
275 
276  $result =& $this->retrieve(
277  'SELECT pa.*,
278  a.*,
279  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
280  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
281  FROM published_articles pa,
282  articles a,
283  sections s
284  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
285  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
286  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
287  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
288  WHERE a.section_id = s.section_id
289  AND pa.article_id = a.article_id
290  AND a.section_id = ?
291  AND pa.issue_id = ?
292  AND a.status <> ' . STATUS_ARCHIVED . '
293  ORDER BY pa.seq ASC',
294  array(
295  'title',
296  $primaryLocale,
297  'title',
298  $locale,
299  'abbrev',
300  $primaryLocale,
301  'abbrev',
302  $locale,
303  (int) $sectionId,
304  (int) $issueId
305  )
306  );
307 
308  $currSectionId = 0;
309  while (!$result->EOF) {
310  $publishedArticle =& $this->$func($result->GetRowAssoc(false));
311  $publishedArticles[] = $publishedArticle;
312  $result->moveNext();
313  }
314 
315  $result->Close();
316  unset($result);
317 
318  return $publishedArticles;
319  }
320 
327  function &getPublishedArticleById($publishedArticleId, $simple = false) {
328  $result =& $this->retrieve(
329  'SELECT * FROM published_articles WHERE published_article_id = ?', (int) $publishedArticleId
330  );
331  $row = $result->GetRowAssoc(false);
332 
333  $publishedArticle = new PublishedArticle();
334  $publishedArticle->setPublishedArticleId($row['published_article_id']);
335  $publishedArticle->setId($row['article_id']);
336  $publishedArticle->setIssueId($row['issue_id']);
337  $publishedArticle->setDatePublished($this->datetimeFromDB($row['date_published']));
338  $publishedArticle->setSeq($row['seq']);
339  $publishedArticle->setAccessStatus($row['access_status']);
340 
341  if (!$simple) $publishedArticle->setSuppFiles($this->suppFileDao->getSuppFilesByArticle($row['article_id']));
342 
343  $result->Close();
344  unset($result);
345 
346  return $publishedArticle;
347  }
348 
356  function &getPublishedArticleByArticleId($articleId, $journalId = null, $useCache = false) {
357  if ($useCache) {
358  $cache =& $this->_getPublishedArticleCache();
359  $returner = $cache->get($articleId);
360  if ($returner && $journalId != null && $journalId != $returner->getJournalId()) $returner = null;
361  return $returner;
362  }
363 
364  $primaryLocale = AppLocale::getPrimaryLocale();
365  $locale = AppLocale::getLocale();
366  $params = array(
367  'title',
368  $primaryLocale,
369  'title',
370  $locale,
371  'abbrev',
372  $primaryLocale,
373  'abbrev',
374  $locale,
375  (int) $articleId
376  );
377  if ($journalId) $params[] = (int) $journalId;
378 
379  $result =& $this->retrieve(
380  'SELECT pa.*,
381  a.*,
382  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
383  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
384  FROM published_articles pa,
385  articles a
386  LEFT JOIN sections s ON s.section_id = a.section_id
387  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
388  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
389  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
390  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
391  WHERE pa.article_id = a.article_id
392  AND a.article_id = ?' .
393  ($journalId?' AND a.journal_id = ?':''),
394  $params
395  );
396 
397  $publishedArticle = null;
398  if ($result->RecordCount() != 0) {
399  $publishedArticle =& $this->_returnPublishedArticleFromRow($result->GetRowAssoc(false));
400  }
401 
402  $result->Close();
403  unset($result);
404 
405  return $publishedArticle;
406  }
407 
418  function &getPublishedArticleByPubId($pubIdType, $pubId, $journalId = null, $useCache = false) {
419  if ($useCache && $pubIdType == 'publisher-id') {
420  $cache =& $this->_getPublishedArticleCache();
421  $returner = $cache->get($pubId);
422  if ($returner && $journalId != null && $journalId != $returner->getJournalId()) $returner = null;
423  return $returner;
424  }
425 
426  $publishedArticle = null;
427  if (!empty($pubId)) {
428  $publishedArticles =& $this->getBySetting('pub-id::'.$pubIdType, $pubId, $journalId);
429  if (!empty($publishedArticles)) {
430  assert(count($publishedArticles) == 1);
431  $publishedArticle =& $publishedArticles[0];
432  }
433  }
434  return $publishedArticle;
435  }
436 
444  function &getBySetting($settingName, $settingValue, $journalId = null) {
445  $primaryLocale = AppLocale::getPrimaryLocale();
446  $locale = AppLocale::getLocale();
447 
448  $params = array(
449  'title',
450  $primaryLocale,
451  'title',
452  $locale,
453  'abbrev',
454  $primaryLocale,
455  'abbrev',
456  $locale,
457  $settingName
458  );
459 
460  $sql = 'SELECT pa.*,
461  a.*,
462  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
463  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
464  FROM published_articles pa
465  INNER JOIN articles a ON pa.article_id = a.article_id
466  LEFT JOIN sections s ON s.section_id = a.section_id
467  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
468  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
469  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
470  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) ';
471  if (is_null($settingValue)) {
472  $sql .= 'LEFT JOIN article_settings ast ON a.article_id = ast.article_id AND ast.setting_name = ?
473  WHERE (ast.setting_value IS NULL OR ast.setting_value = "")';
474  } else {
475  $params[] = $settingValue;
476  $sql .= 'INNER JOIN article_settings ast ON a.article_id = ast.article_id
477  WHERE ast.setting_name = ? AND ast.setting_value = ?';
478  }
479  if ($journalId) {
480  $params[] = (int) $journalId;
481  $sql .= ' AND a.journal_id = ?';
482  }
483  $sql .= ' ORDER BY pa.issue_id, a.article_id';
484  $result =& $this->retrieve($sql, $params);
485 
486  $publishedArticles = array();
487  while (!$result->EOF) {
488  $publishedArticles[] =& $this->_returnPublishedArticleFromRow($result->GetRowAssoc(false));
489  $result->moveNext();
490  }
491  $result->Close();
492 
493  return $publishedArticles;
494  }
495 
504  function &getPublishedArticleByBestArticleId($journalId, $articleId, $useCache = false) {
505  $article =& $this->getPublishedArticleByPubId('publisher-id', $articleId, (int) $journalId, $useCache);
506  if (!isset($article) && ctype_digit("$articleId")) $article =& $this->getPublishedArticleByArticleId((int) $articleId, (int) $journalId, $useCache);
507  return $article;
508  }
509 
519  function &getPublishedArticleIdsAlphabetizedByJournal($journalId = null, $useCache = true) {
520  $params = array(
521  'cleanTitle', AppLocale::getLocale(),
522  'cleanTitle'
523  );
524  if (isset($journalId)) $params[] = (int) $journalId;
525 
526  $articleIds = array();
527  $functionName = $useCache?'retrieveCached':'retrieve';
528  $result =& $this->$functionName(
529  'SELECT a.article_id AS pub_id,
530  COALESCE(atl.setting_value, atpl.setting_value) AS article_title
531  FROM published_articles pa,
532  issues i,
533  articles a
534  LEFT JOIN sections s ON s.section_id = a.section_id
535  LEFT JOIN article_settings atl ON (a.article_id = atl.article_id AND atl.setting_name = ? AND atl.locale = ?)
536  LEFT JOIN article_settings atpl ON (a.article_id = atpl.article_id AND atpl.setting_name = ? AND atpl.locale = a.locale)
537  WHERE pa.article_id = a.article_id
538  AND i.issue_id = pa.issue_id
539  AND i.published = 1
540  AND s.section_id IS NOT NULL' .
541  (isset($journalId)?' AND a.journal_id = ?':'') . ' ORDER BY article_title',
542  $params
543  );
544 
545  while (!$result->EOF) {
546  $row = $result->getRowAssoc(false);
547  $articleIds[] = $row['pub_id'];
548  $result->moveNext();
549  }
550 
551  $result->Close();
552  unset($result);
553 
554  return $articleIds;
555  }
556 
565  function &getPublishedArticleIdsByJournal($journalId = null, $useCache = true) {
566  $articleIds = array();
567  $functionName = $useCache?'retrieveCached':'retrieve';
568  $result =& $this->$functionName(
569  'SELECT a.article_id AS pub_id FROM published_articles pa, articles a LEFT JOIN sections s ON s.section_id = a.section_id WHERE pa.article_id = a.article_id' . (isset($journalId)?' AND a.journal_id = ?':'') . ' ORDER BY pa.date_published DESC',
570  isset($journalId)?(int) $journalId:false
571  );
572 
573  while (!$result->EOF) {
574  $row = $result->getRowAssoc(false);
575  $articleIds[] = $row['pub_id'];
576  $result->moveNext();
577  }
578 
579  $result->Close();
580  unset($result);
581 
582  return $articleIds;
583  }
590  function getPublishedArticleIdsBySection($sectionId, $useCache = true) {
591  $articleIds = array();
592  $functionName = $useCache?'retrieveCached':'retrieve';
593  $result =& $this->$functionName(
594  'SELECT a.article_id FROM published_articles pa, articles a, issues i WHERE pa.issue_id = i.issue_id AND i.published = 1 AND pa.article_id = a.article_id AND a.section_id = ? ORDER BY pa.date_published DESC',
595  (int) $sectionId
596  );
597 
598  while (!$result->EOF) {
599  $row = $result->getRowAssoc(false);
600  $articleIds[] = $row['article_id'];
601  $result->moveNext();
602  }
603 
604  $result->Close();
605  unset($result);
606 
607  return $articleIds;
608  }
609 
616  function &_returnPublishedArticleFromRow($row, $callHooks = true) {
617  $publishedArticle = new PublishedArticle();
618  $publishedArticle->setPublishedArticleId($row['published_article_id']);
619  $publishedArticle->setIssueId($row['issue_id']);
620  $publishedArticle->setDatePublished($this->datetimeFromDB($row['date_published']));
621  $publishedArticle->setSeq($row['seq']);
622  $publishedArticle->setAccessStatus($row['access_status']);
623 
624  $publishedArticle->setGalleys($this->galleyDao->getGalleysByArticle($row['article_id']));
625 
626  // Article attributes
627  $this->articleDao->_articleFromRow($publishedArticle, $row);
628 
629  $publishedArticle->setSuppFiles($this->suppFileDao->getSuppFilesByArticle($row['article_id']));
630 
631  if ($callHooks) HookRegistry::call('PublishedArticleDAO::_returnPublishedArticleFromRow', array(&$publishedArticle, &$row));
632  return $publishedArticle;
633  }
634 
635 
642  function insertPublishedArticle(&$publishedArticle) {
643  $this->update(
644  sprintf('INSERT INTO published_articles
645  (article_id, issue_id, date_published, seq, access_status)
646  VALUES
647  (?, ?, %s, ?, ?)',
648  $this->datetimeToDB($publishedArticle->getDatePublished())),
649  array(
650  (int) $publishedArticle->getId(),
651  (int) $publishedArticle->getIssueId(),
652  $publishedArticle->getSeq(),
653  $publishedArticle->getAccessStatus()
654  )
655  );
656 
657  $publishedArticle->setPublishedArticleId($this->getInsertPublishedArticleId());
658  return $publishedArticle->getPublishedArticleId();
659  }
660 
666  return $this->getInsertId('published_articles', 'published_article_id');
667  }
668 
673  function deletePublishedArticleById($publishedArticleId) {
674  $this->update(
675  'DELETE FROM published_articles WHERE published_article_id = ?', (int) $publishedArticleId
676  );
677 
678  $this->flushCache();
679  }
680 
686  function deletePublishedArticleByArticleId($articleId) {
687  return $this->update(
688  'DELETE FROM published_articles WHERE article_id = ?', (int) $articleId
689  );
690  $this->flushCache();
691  }
692 
697  function deletePublishedArticlesBySectionId($sectionId) {
698  $result =& $this->retrieve(
699  'SELECT pa.article_id AS article_id FROM published_articles pa, articles a WHERE pa.article_id = a.article_id AND a.section_id = ?', (int) $sectionId
700  );
701 
702  while (!$result->EOF) {
703  $row = $result->GetRowAssoc(false);
704  $this->update(
705  'DELETE FROM published_articles WHERE article_id = ?', $row['article_id']
706  );
707  }
708 
709  $result->Close();
710  unset($result);
711 
712  $this->flushCache();
713  }
714 
719  function deletePublishedArticlesByIssueId($issueId) {
720  $this->update(
721  'DELETE FROM published_articles WHERE issue_id = ?', (int) $issueId
722  );
723 
724  $this->flushCache();
725  }
726 
731  function updatePublishedArticle($publishedArticle) {
732  $this->update(
733  sprintf('UPDATE published_articles
734  SET
735  article_id = ?,
736  issue_id = ?,
737  date_published = %s,
738  seq = ?,
739  access_status = ?
740  WHERE published_article_id = ?',
741  $this->datetimeToDB($publishedArticle->getDatePublished())),
742  array(
743  (int) $publishedArticle->getId(),
744  (int) $publishedArticle->getIssueId(),
745  $publishedArticle->getSeq(),
746  $publishedArticle->getAccessStatus(),
747  (int) $publishedArticle->getPublishedArticleId()
748  )
749  );
750 
751  $this->flushCache();
752  }
753 
760  function updatePublishedArticleField($publishedArticleId, $field, $value) {
761  $this->update(
762  "UPDATE published_articles SET $field = ? WHERE published_article_id = ?", array($value, (int) $publishedArticleId)
763  );
764 
765  $this->flushCache();
766  }
767 
771  function resequencePublishedArticles($sectionId, $issueId) {
772  $result =& $this->retrieve(
773  'SELECT pa.published_article_id FROM published_articles pa, articles a WHERE a.section_id = ? AND a.article_id = pa.article_id AND pa.issue_id = ? ORDER BY pa.seq',
774  array((int) $sectionId, (int) $issueId)
775  );
776 
777  for ($i=1; !$result->EOF; $i++) {
778  list($publishedArticleId) = $result->fields;
779  $this->update(
780  'UPDATE published_articles SET seq = ? WHERE published_article_id = ?',
781  array($i, $publishedArticleId)
782  );
783 
784  $result->moveNext();
785  }
786 
787  $result->close();
788  unset($result);
789 
790  $this->flushCache();
791  }
792 
797  function incrementViewsByArticleId($articleId) {
798  return $this->update(
799  'UPDATE published_articles SET views = views + 1 WHERE article_id = ?',
800  (int) $articleId
801  );
802  }
803 
809  function getArticleYearRange($journalId = null) {
810  $result =& $this->retrieve(
811  'SELECT MAX(pa.date_published), MIN(pa.date_published) FROM published_articles pa, articles a WHERE pa.article_id = a.article_id' . (isset($journalId)?' AND a.journal_id = ?':''),
812  isset($journalId)?(int) $journalId:false
813  );
814  $returner = array($result->fields[0], $result->fields[1]);
815 
816  $result->Close();
817  unset($result);
818 
819  return $returner;
820  }
821 }
822 
823 ?>
getPublishedArticleCountByJournalId($journalId)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
deletePublishedArticleById($publishedArticleId)
& getBySetting($settingName, $settingValue, $journalId=null)
& getPublishedArticleByArticleId($articleId, $journalId=null, $useCache=false)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
insertPublishedArticle(&$publishedArticle)
getInsertId($table= '', $id= '', $callHooks=true)
Definition: DAO.inc.php:252
deletePublishedArticlesBySectionId($sectionId)
resequencePublishedArticles($sectionId, $issueId)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:176
& getPublishedArticleIdsByJournal($journalId=null, $useCache=true)
getArticleYearRange($journalId=null)
& getPublishedArticlesByJournalId($journalId=null, $rangeInfo=null, $reverse=false)
updatePublishedArticleField($publishedArticleId, $field, $value)
datetimeFromDB($dt)
Definition: DAO.inc.php:316
Operations for retrieving and modifying PublishedArticle objects.
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
Published article class.
& getDAO($name, $dbconn=null)
& getPublishedArticleById($publishedArticleId, $simple=false)
call($hookName, $args=null)
flushCache()
Definition: DAO.inc.php:285
& getPublishedArticleByPubId($pubIdType, $pubId, $journalId=null, $useCache=false)
& getPublishedArticleByBestArticleId($journalId, $articleId, $useCache=false)
datetimeToDB($dt)
Definition: DAO.inc.php:296
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
& getPublishedArticlesBySectionId($sectionId, $issueId, $simple=false)
& _returnPublishedArticleFromRow($row, $callHooks=true)
updatePublishedArticle($publishedArticle)
deletePublishedArticleByArticleId($articleId)
& getPublishedArticlesInSections($issueId, $useCache=false)
& getPublishedArticleIdsAlphabetizedByJournal($journalId=null, $useCache=true)
getPublishedArticleIdsBySection($sectionId, $useCache=true)