root/trunk/plogger.php

Revision 588, 5.2 KB (checked in by kimparsell, 3 weeks ago)

+ Minor markup changes for install/upgrade process.
+ Minor admin section changes to make action notices consistent.
+ Miscellaneous cleanup.

Line 
1<?php
2
3include_once(dirname(__FILE__)."/plog-load-config.php");
4
5global $config;
6
7if (!empty($_POST['comment_post_ID'])) {
8    include_once(PLOGGER_DIR.'plog-includes/plog-comment.php');
9}
10
11// process path here - is set if mod_rewrite is in use
12if (!empty($_REQUEST['path'])) {
13    // The following line calculates the path in the album and excludes any subdirectories if
14    // Plogger is installed in one
15    $path = join("/",array_diff(explode("/",$_SERVER['REQUEST_URI']),explode("/",$_SERVER['PHP_SELF'])));
16    $resolved_path = resolve_path($path);
17    if (is_array($resolved_path)) {
18        if (isset($resolved_path['level'])) {
19            $_GET['level'] = $resolved_path['level'];
20        }
21        if (isset($resolved_path['id'])) {
22            $_GET['id'] = $resolved_path['id'];
23        }
24        if (isset($resolved_path['plog_page'])) {
25            $_GET['plog_page'] = $resolved_path['plog_page'];
26        }
27        if (isset($resolved_path['mode'])) {
28            $_GET['mode'] = $resolved_path['mode'];
29        }
30
31        // get the path for RSS links (maybe should rework this)
32        $parts = parse_url($_SERVER['REQUEST_URI']);
33        $path = $parts['path'];
34    }
35} else {
36    //check for additional $_GET query arguments (non-Plogger)
37    $query_args = array();
38    $query_parts = array();
39    $parts = parse_url($_SERVER['REQUEST_URI']);
40    if (isset($parts['query'])) {
41        parse_str($parts['query'],$query_parts);
42    }
43    $plogger_args = array("level", "id", "mode", "plog_page", "searchterms", "sortby", "sortdir");
44    $url_args = array_keys($query_parts);
45    $diff_args = array_diff($url_args, $plogger_args);
46    foreach ($diff_args as $diff){
47        $query_args[] = $diff."=".$query_parts[$diff];
48    }
49    if (!empty($query_args)){
50        $config['query_args'] = implode("&amp;",$query_args);
51    }
52}
53
54// Set sorting session variables if they are passed
55if (isset($_GET['sortby'])) {
56    $_SESSION['plogger_sortby'] = $_GET['sortby'];
57}
58
59if (isset($_GET['sortdir'])) {
60    $_SESSION['plogger_sortdir'] = $_GET['sortdir'];
61}
62
63// The three GET parameters that it accepts are
64// $level = "collection", "album", or "picture"
65// $id = id number of collection, album, or picture
66// $n = starting element (for pagination) go from n to n + max_thumbs (in global config)
67
68// use plogger specific variables to avoid name clashes if Plogger is embedded
69
70$GLOBALS['plogger_level'] = isset($_GET['level']) ? $_GET['level'] : '';
71$GLOBALS['plogger_id'] = isset($_GET['id']) ? intval($_GET['id']) : 0;
72$GLOBALS['plogger_mode'] = isset($_GET['mode']) ? $_GET['mode'] : '';
73
74// count collections and albums with pictures in them
75$active = get_active_collections_albums();
76
77// if only 1 active album, truncate the "collection" & "collections" portion of Plogger
78if (count($active['albums']) == 1) {
79    $config['truncate_breadcrumb'] = 'album';
80    if ($GLOBALS['plogger_level']!="picture" && $GLOBALS['plogger_level']!="404") {
81        if ($GLOBALS['plogger_level']!="search") {
82            $GLOBALS['plogger_level'] = "album";
83        }
84        $GLOBALS['plogger_id'] = $active['albums'][0];
85    }
86// if only 1 active collection, truncate the "collections" portion of Plogger
87} else if (count($active['collections']) == 1) {
88    $config['truncate_breadcrumb'] = 'collection';
89    if ($GLOBALS['plogger_level']!="album" && $GLOBALS['plogger_level']!='picture' && $GLOBALS['plogger_level']!="404") {
90        if ($GLOBALS['plogger_level']!="search") {
91            $GLOBALS['plogger_level'] = "collection";
92        }
93        $GLOBALS['plogger_id'] = $active['collections'][0];
94    }
95} else {
96    $config['truncate_breadcrumb'] = false;
97}
98
99$allowed_levels = array('collections','collection','album','picture','search','404');
100if (!in_array($GLOBALS['plogger_level'],$allowed_levels)) {
101    $GLOBALS['plogger_level'] = 'collections';
102}
103
104// Some Estonian remarks was here ?!?
105
106define('THEME_DIR', PLOGGER_DIR.'plog-content/themes/'.$config['theme_dir']);
107define('THEME_URL', $config['theme_url']);
108
109// initialize plogger
110plogger_init();
111
112// throw 404 headers if a 404 error has occurred
113if ($GLOBALS['plogger_level'] == "404" && !headers_sent()) {
114    header( "Status: 404 Not Found" );
115    header($_SERVER['SERVER_PROTOCOL']." 404 Not Found");
116}
117
118function the_plogger_head() {
119    plogger_head();
120
121    $use_file = 'head.php';
122    if (file_exists(THEME_DIR."/".$use_file)) {
123        include(THEME_DIR."/".$use_file);
124    } else {
125        include(PLOGGER_DIR.'plog-content/themes/default/'.$use_file);
126    }
127}
128
129function the_plogger_gallery() {
130    // collections mode (show all albums within a collection)
131    // it's the default
132    $use_file = "collections.php";
133    if ($GLOBALS['plogger_level'] == "picture"){
134        $use_file = 'picture.php';
135    } elseif ($GLOBALS['plogger_level'] == "search"){
136        if ($GLOBALS['plogger_mode'] == "slideshow") {
137            $use_file = 'slideshow.php';
138        } else {
139            $use_file = 'search.php';
140        }
141    } elseif ($GLOBALS['plogger_level'] == "album") {
142        // Album level display mode (display all pictures within album)
143        if ($GLOBALS['plogger_mode'] == "slideshow") {
144            $use_file = 'slideshow.php';
145        } else {
146            $use_file = 'album.php';
147        }
148    } else if ($GLOBALS['plogger_level'] == "collection") {
149        $use_file = 'collection.php';
150    } else if ($GLOBALS['plogger_level'] == "404") {
151        $use_file = '404.php';
152    }
153
154    // if the theme does not have the requested file, then use the one from the default template
155    if (file_exists(THEME_DIR . "/" . $use_file)) {
156        include(THEME_DIR . "/" . $use_file);
157    } else {
158        include(PLOGGER_DIR.'/plog-content/themes/default/'.$use_file);
159    }
160}
161?>
Note: See TracBrowser for help on using the browser.