~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to modules/newitems/classes/NewItemsSortOrder.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * $RCSfile: NewItemsSortOrder.class,v $
4
4
 *
5
5
 * Gallery - a web based photo album viewer and editor
6
 
 * Copyright (C) 2000-2005 Bharat Mediratta
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
20
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
21
21
 */
22
22
/**
23
 
 * @version $Revision: 1.6 $ $Date: 2005/08/23 03:49:47 $
 
23
 * @version $Revision: 1.8 $ $Date: 2006/01/13 03:39:47 $
24
24
 * @package NewItems
25
25
 * @author Alan Harder <alan.harder@sun.com>
26
26
 */
27
27
 
28
 
GalleryCoreApi::relativeRequireOnce('modules/core/classes/GallerySortInterface_1_1.class');
 
28
GalleryCoreApi::requireOnce('modules/core/classes/GallerySortInterface_1_1.class');
29
29
 
30
30
/**
31
31
 * Sort with new items shown first, followed by other items sorted by view count.
40
40
     */
41
41
    function getSortInfo() {
42
42
        list ($ret, $module) = GalleryCoreApi::loadPlugin('module', 'newitems');
43
 
        if ($ret->isError()) {
 
43
        if ($ret) {
44
44
            return array($ret->wrap(__FILE__, __LINE__), null, null);
45
45
        }
46
46
 
47
 
        return array(GalleryStatus::success(), $module->translate('New Items First'), true);
 
47
        return array(null, $module->translate('New Items First'), true);
48
48
    }
49
49
 
50
50
    /**
54
54
        global $gallery;
55
55
        $storage =& $gallery->getStorage();
56
56
 
57
 
        list ($ret, $newTime) = GalleryCoreApi::getPluginParameter('module', 'newitems', 'days.new');
58
 
        if ($ret->isError()) {
 
57
        list ($ret, $newTime) =
 
58
            GalleryCoreApi::getPluginParameter('module', 'newitems', 'days.new');
 
59
        if ($ret) {
59
60
            return array($ret->wrap(__FILE__, __LINE__), null, null, null, null);
60
61
        }
61
62
        $newTime = time() - $newTime * 86400;
62
63
        list ($ret, $case) = $storage->getFunctionSql('CASE',
63
64
            array("[GalleryEntity::creationTimestamp] > $newTime", '0', '1'));
64
 
        if ($ret->isError()) {
 
65
        if ($ret) {
65
66
            return array($ret->wrap(__FILE__, __LINE__), null, null, null, null);
66
67
        }
67
68
 
68
 
        return array(GalleryStatus::success(), '%1%', $case,
 
69
        return array(null, '%1%', $case,
69
70
                     '[GalleryEntity::id] = [GalleryChildEntity::id]', null);
70
71
    }
71
72
}