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

« back to all changes in this revision

Viewing changes to modules/rewrite/classes/parsers/pathinfo/parser.inc

  • 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:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: parser.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or (at
 
11
 * your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 
21
 */
 
22
/**
 
23
 * @package Rewrite
 
24
 * @version $Revision: 1.2 $ $Date: 2006/01/10 04:42:18 $
 
25
 * @author Douglas Cau <douglas@cau.se>
 
26
 */
 
27
 
 
28
/* Required class */
 
29
GalleryCoreApi::requireOnce('modules/rewrite/classes/RewriteParser.class');
 
30
 
 
31
/* Status code used by the PHP Path Info parser */
 
32
define('REWRITE_STATUS_NO_PATH_INFO', 21);
 
33
 
 
34
/**
 
35
 * This URL Rewrite parser provides PHP Path Info support for short URLs.
 
36
 *
 
37
 * @package Rewrite
 
38
 * @subpackage Parsers
 
39
 */
 
40
class PathInfoParser extends RewriteParser {
 
41
 
 
42
    function PathInfoParser() {
 
43
        $this->_setParserId('pathinfo');
 
44
        $this->_setParserType('inGallery');
 
45
        $this->_setUrlGeneratorId('PathInfoUrlGenerator');
 
46
    }
 
47
 
 
48
    /**
 
49
     * @see RewriteParser::saveActiveRules
 
50
     */
 
51
    function saveActiveRules($activeRules=null, $rewriteModule=null) {
 
52
        GalleryCoreApi::requireOnce(
 
53
            'modules/rewrite/classes/parsers/pathinfo/PathInfoHelper.class');
 
54
        return PathInfoHelper::saveActiveRules($this, $activeRules, $rewriteModule);
 
55
    }
 
56
 
 
57
    /**
 
58
     * @see RewriteParser::needsConfiguration
 
59
     */
 
60
    function needsConfiguration() {
 
61
        GalleryCoreApi::requireOnce(
 
62
            'modules/rewrite/classes/parsers/pathinfo/PathInfoHelper.class');
 
63
 
 
64
        list ($ret, $code) = PathInfoHelper::checkPathInfo();
 
65
        if ($ret) {
 
66
            return array($ret->wrap(__FILE__, __LINE__), null);
 
67
        }
 
68
 
 
69
        return array(null, $code != REWRITE_STATUS_OK);
 
70
    }
 
71
 
 
72
    /**
 
73
     * @see RewriteParser::loadTestResultsTemplate
 
74
     */
 
75
    function loadTestResultsTemplate(&$template, &$form) {
 
76
        GalleryCoreApi::requireOnce(
 
77
            'modules/rewrite/classes/parsers/pathinfo/PathInfoHelper.class');
 
78
        return PathInfoHelper::loadTestResultsTemplate($template, $form);
 
79
    }
 
80
 
 
81
    /**
 
82
     * @see RewriteParser::handleTestResultsRequest
 
83
     */
 
84
    function handleTestResultsRequest($form) {
 
85
        $error = $status = array();
 
86
 
 
87
        $ret = GalleryCoreApi::assertUserIsSiteAdministrator();
 
88
        if ($ret) {
 
89
            return array($ret->wrap(__FILE__, __LINE__), null, null);
 
90
        }
 
91
 
 
92
        if (isset($form['force']['test'])) {
 
93
            $ret = GalleryCoreApi::setPluginParameter('module', 'rewrite', 'pathinfo.forced', '1');
 
94
            if ($ret) {
 
95
                return array($ret->wrap(__FILE__, __LINE__), null, null);
 
96
            }
 
97
        }
 
98
 
 
99
        $status['saved'] = 1;
 
100
        return array(null, $error, $status);
 
101
    }
 
102
}
 
103
?>