aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2007-02-07 23:08:04 +0000
committerrub <rub@piwigo.org>2007-02-07 23:08:04 +0000
commit5631a3fc545bd736cb4b82a93fa7d2b48814973c (patch)
treeaea9cfa1fb8f563e1d41fd4b611a6024864c1af4
parent3c8775b25255a2be4f561b1c0ede275cbae3f73b (diff)
Issue 0000639: Force selected page on index.php
When page index.php is called without defined section, redirect to a page selected by random on a user list. git-svn-id: http://piwigo.org/svn/trunk@1788 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/config_default.inc.php13
-rw-r--r--include/functions_url.inc.php6
-rw-r--r--include/menubar.inc.php2
-rw-r--r--include/section_init.inc.php25
-rw-r--r--profile.php2
-rw-r--r--template/yoga/menubar.tpl2
-rw-r--r--template/yoga/profile.tpl2
7 files changed, 45 insertions, 7 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index f33047a73..b93f3e51d 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -212,6 +212,19 @@ $conf['show_version'] = true;
// page.
$conf['links'] = array();
+// random_index_redirect: list of 'internal' links to use when no section is defined on index.php.
+// An example is the best than a long explanation :
+//
+// for each link is associated a php condition
+// '' condition is equivalent to 'return true;'
+// $conf['random_index_redirect'] = array(
+// PHPWG_ROOT_PATH.'index.php?/best_rated' => 'return true;',
+// PHPWG_ROOT_PATH.'index.php?/recent_pics' => 'return $user[\'is_the_guest\'];',
+// PHPWG_ROOT_PATH.'random.php' => '',
+// PHPWG_ROOT_PATH.'index.php?/categories' => '',
+// );
+$conf['random_index_redirect'] = array();
+
// List of notes to display on all header page
// example $conf['header_notes'] = array('Test', 'Hello');
$conf['header_notes'] = array();
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 376d4f4e9..2a567e8c5 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -312,7 +312,7 @@ function make_section_in_url($params)
if (!isset($params['section']))
{
- $params['section'] = 'categories';
+ $params['section'] = 'none';
}
switch($params['section'])
@@ -398,6 +398,10 @@ function make_section_in_url($params)
break;
}
+ case 'none' :
+ {
+ break;
+ }
default :
{
$section_string.= '/'.$params['section'];
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 4a35cccbf..030c46cbd 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -43,7 +43,7 @@ $template->assign_vars(
'USERNAME' => $user['username'],
'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
'F_IDENTIFY' => get_root_url().'identification.php',
- 'U_HOME' => make_index_url(),
+ 'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
'U_REGISTER' => get_root_url().'register.php',
'U_LOST_PASSWORD' => get_root_url().'password.php',
'U_LOGOUT' => get_root_url().'?act=logout',
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index a1535668a..78ec73fa0 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -51,8 +51,6 @@
// 'action' => 'fill_caddie'
// );
-$page['section'] = 'categories';
-
// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
// default apache implementation it is not set
if ( $conf['question_mark_in_urls']==false and
@@ -268,6 +266,29 @@ else if ('list' == $tokens[$next_token])
}
$next_token++;
}
+else
+{
+ if (!empty($conf['random_index_redirect']))
+ {
+ $random_index_redirect = array();
+ foreach ($conf['random_index_redirect'] as $random_url => $random_url_condition)
+ {
+ if (empty($random_url_condition) or eval($random_url_condition))
+ {
+ $random_index_redirect[] = $random_url;
+ }
+ }
+ }
+
+ if (!empty($random_index_redirect))
+ {
+ redirect($random_index_redirect[mt_rand(0, count($random_index_redirect)-1)]);
+ }
+ else
+ {
+ $page['section'] = 'categories';
+ }
+}
$i = $next_token;
diff --git a/profile.php b/profile.php
index 3e512703a..e83eac010 100644
--- a/profile.php
+++ b/profile.php
@@ -53,7 +53,7 @@ if (!defined('PHPWG_ROOT_PATH'))
make_index_url(), // for redirect
$userdata );
- $template->assign_var('U_RETURN', make_index_url() );
+ $template->assign_var('U_HOME', make_index_url() );
// +-----------------------------------------------------------------------+
// | errors display |
diff --git a/template/yoga/menubar.tpl b/template/yoga/menubar.tpl
index c698ed497..603733fa2 100644
--- a/template/yoga/menubar.tpl
+++ b/template/yoga/menubar.tpl
@@ -29,7 +29,7 @@
<a href="{stop_filter.URL}" title="{lang:stop_filter_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter.png" class="button" alt="{lang:stop_filter_hint}"></a>
<!-- END stop_filter -->
<dl id="mbCategories">
- <dt><a href="{U_HOME}">{lang:Categories}</a></dt>
+ <dt><a href="{U_CATEGORIES}">{lang:Categories}</a></dt>
<dd>
{MENU_CATEGORIES_CONTENT}
<p class="totalImages">{NB_PICTURE} {lang:total}</p>
diff --git a/template/yoga/profile.tpl b/template/yoga/profile.tpl
index f48a711c1..248dce787 100644
--- a/template/yoga/profile.tpl
+++ b/template/yoga/profile.tpl
@@ -12,7 +12,7 @@
<div class="titrePage">
<ul class="categoryActions">
- <li><a href="{U_RETURN}" title="{lang:return to homepage}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li>
+ <li><a href="{U_HOME}" title="{lang:return to homepage}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li>
</ul>
<h2>{lang:Profile}</h2>
</div>