2 /* CommitLoader.class.php - phpgitweb
3 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
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.
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.
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/>.
20 public static $commit_id, $commit_base_id;
23 public static function parse($log_page = false) {
24 if(array_key_exists('h', $_GET) && Validation::validate_hash($_GET['h']))
25 $commit_id = $_GET['h'];
29 if(array_key_exists('hb', $_GET) && Validation::validate_hash($_GET['hb']))
30 $commit_base_id = $_GET['hb'];
31 else if(!$log_page && $_SESSION['hb'])
32 $commit_base_id = $_SESSION['hb'];
34 $commit_base_id = $commit_id;
37 $_SESSION['hb'] = $commit_base_id;
39 ContentProvider::overall_set('commit_base_id', $commit_base_id);
40 ContentProvider::overall_set('commit_id', $commit_id);
42 self::$commit_id = $commit_id;
43 self::$commit_base_id = $commit_base_id;
44 return array('id' => $commit_id, 'base_id' => $commit_base_id);
47 public function __construct($project) {
48 $this->project = $project;
51 public function load($id = null) {
52 if(!$id && self::$commit_id)
53 $id = self::$commit_id;
54 else if(!Validation::validate_hash($id)) {
55 trigger_error("Invalid hash parameter", E_USER_ERROR);
58 if(strtolower($id) == 'all')
60 $commit = GitCommand::get_commit($this->project['path'], $id);