moved page helper classes to own files
[phpgitweb.git] / htdocs / pages / shortlog.class.php
1 <?php
2 /* shortlog.class.php - phpgitweb
3  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
4  * 
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License 
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
17  */
18
19 class page_shortlog {
20     private $page, $phpgitweb;
21         
22     public function main($phpgitweb, $project) {
23                 $this->phpgitweb = $phpgitweb;
24                 $this->project = $project;
25                 if(!$this->project)
26                         return new ContentProvider('main', 'err400');
27                 $project['refs'] = $phpgitweb->get_project_loader()->getProjectRefs($project);
28                 $phpgitweb->append_header_nav("shortlog", null, true);
29                 $phpgitweb->append_title("shortlog");
30                 CommitLoader::parse(true);
31                 
32                 $this->page = new ContentProvider('shortlog', 'main');
33                 if(strtolower(CommitLoader::$commit_base_id) != 'all') {
34                         $this->page->set('refname', ' - '.CommitLoader::$commit_base_id);
35                 } else
36                         $this->page->set('refname', '');
37                 
38                 //pages
39                 if(array_key_exists('pg', $_GET)) {
40                         $pg = $_GET['pg'];
41                         if($pg < 0)
42                                 $pg = 0;
43                         $skip = $_GET['pg'] * 100;
44                         $next_page = $_GET['pg'] + 1;
45                 } else {
46                         $pg = 0;
47                         $skip = 0;
48                         $next_page = 1;
49                 }
50                 
51                 $subnav = new ContentProvider('shortlog', 'shortlog_subnav');
52                 $phpgitweb->append_sub_nav($subnav);
53                 
54                 if($pg) {
55                         $subnav->set('first', new ContentProvider('shortlog', 'shortlog_subnav_first_link'));
56                         $subnav->set('prev', new ContentProvider('shortlog', 'shortlog_subnav_prev_link', array('page' => ($pg - 1))));
57                 } else {
58                         $subnav->set('first', new ContentProvider('shortlog', 'shortlog_subnav_first'));
59                         $subnav->set('prev', new ContentProvider('shortlog', 'shortlog_subnav_prev'));
60                 }
61                 
62                 $shortlog = new shortlog();
63                 $this->page->set('shortlog', $shortlog->generate_shortlog($project, CommitLoader::$commit_base_id, 100, $skip, null, true, $next_page));
64                 
65                 if($shortlog->get_have_more())
66                         $subnav->set('next', new ContentProvider('shortlog', 'shortlog_subnav_next_link', array('page' => ($pg + 1))));
67                 else
68                         $subnav->set('next', new ContentProvider('shortlog', 'shortlog_subnav_next'));
69                 
70                 return $this->page;
71         }
72         
73 }
74
75 ?>