forked from science-ation/science-ation
Fix some nav issues and start the task of detecting where in teh nav we are if we didnt navigate to the page through the links
Some general formatting cleanups on the common.inc too
This commit is contained in:
parent
fa69916607
commit
e8c8bf33fe
@ -310,48 +310,37 @@ if($_GET['switchlanguage']) {
|
||||
}
|
||||
}
|
||||
|
||||
function i18n($str,$args=array(),$argsdesc=array(),$forcelang="")
|
||||
{
|
||||
function i18n($str,$args=array(),$argsdesc=array(),$forcelang="") {
|
||||
if(!$str)
|
||||
return "";
|
||||
|
||||
if($forcelang)
|
||||
{
|
||||
if($forcelang) {
|
||||
$savelang=$_SESSION['lang'];
|
||||
$_SESSION['lang']=$forcelang;
|
||||
}
|
||||
|
||||
if($_SESSION['lang'])
|
||||
{
|
||||
if($_SESSION['lang']=="en")
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
if($_SESSION['lang']) {
|
||||
if($_SESSION['lang']=="en") {
|
||||
for($x=1;$x<=count($args);$x++) {
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
if($forcelang) $_SESSION['lang']=$savelang;
|
||||
return $str;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['lang']."' AND strmd5='".md5($str)."'");
|
||||
if($r=@mysql_fetch_object($q))
|
||||
{
|
||||
if($r->val)
|
||||
{
|
||||
if($r=@mysql_fetch_object($q)) {
|
||||
if($r->val) {
|
||||
$ret=$r->val;
|
||||
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++) {
|
||||
$ret=str_replace("%$x",$args[$x-1],$ret);
|
||||
}
|
||||
if($forcelang) $_SESSION['lang']=$savelang;
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
else {
|
||||
for($x=1;$x<=count($args);$x++) {
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
if($forcelang) $_SESSION['lang']=$savelang;
|
||||
@ -359,14 +348,11 @@ function i18n($str,$args=array(),$argsdesc=array(),$forcelang="")
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(count($argsdesc))
|
||||
{
|
||||
else {
|
||||
if(count($argsdesc)) {
|
||||
$argsdescstring="";
|
||||
$n=1;
|
||||
foreach($argsdesc AS $ad)
|
||||
{
|
||||
foreach($argsdesc AS $ad) {
|
||||
$argsdescstring.="%$n=$ad, ";
|
||||
$n++;
|
||||
}
|
||||
@ -377,8 +363,7 @@ function i18n($str,$args=array(),$argsdesc=array(),$forcelang="")
|
||||
$argsdescstring="null";
|
||||
|
||||
mysql_query("INSERT INTO translations (lang,strmd5,str,argsdesc) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."',$argsdescstring)");
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++) {
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
if($forcelang) $_SESSION['lang']=$savelang;
|
||||
@ -386,16 +371,14 @@ function i18n($str,$args=array(),$argsdesc=array(),$forcelang="")
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//no language set, assume english
|
||||
if($forcelang) $_SESSION['lang']=$savelang;
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
function error($str,$type="normal")
|
||||
{
|
||||
function error($str,$type="normal") {
|
||||
if($type=="normal")
|
||||
return "<div class=\"error\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
@ -403,24 +386,21 @@ function error($str,$type="normal")
|
||||
|
||||
}
|
||||
|
||||
function notice($str,$type="normal")
|
||||
{
|
||||
function notice($str,$type="normal") {
|
||||
if($type=="normal")
|
||||
return "<div class=\"notice\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
return "<span class=\"notice\">$str</span><br />";
|
||||
}
|
||||
|
||||
function happy($str,$type="normal")
|
||||
{
|
||||
function happy($str,$type="normal") {
|
||||
if($type=="normal")
|
||||
return "<div class=\"happy\">$str</div><br />";
|
||||
else if($type=="inline")
|
||||
return "<span class=\"happy\">$str</span><br />";
|
||||
}
|
||||
|
||||
function display_messages()
|
||||
{
|
||||
function display_messages() {
|
||||
/* Dump any messages in the queue */
|
||||
if(is_array($_SESSION['messages'])) {
|
||||
foreach($_SESSION['messages'] as $m) echo $m;
|
||||
@ -428,6 +408,15 @@ function display_messages()
|
||||
$_SESSION['messages'] = array();
|
||||
}
|
||||
|
||||
function upTree($id, &$navTree) {
|
||||
$q=mysql_query("SELECT * FROM rolestasks WHERE id='$id'");
|
||||
$r=mysql_fetch_assoc($q);
|
||||
$navTree[]=$r;
|
||||
if($r['pid']>0) {
|
||||
upTree($r['pid'], &$navTree);
|
||||
}
|
||||
}
|
||||
|
||||
$HEADER_SENT=false;
|
||||
function send_header($title="", $nav=null, $icon=null, $titletranslated=false)
|
||||
{
|
||||
@ -731,6 +720,24 @@ if($_SESSION['nav']['secondary']) {
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
|
||||
//take SFIABDIRECTORY off of the current URL
|
||||
$pageurl=substr($_SERVER['PHP_SELF'],strlen($config['SFIABDIRECTORY']));
|
||||
$q=mysql_query("SELECT * FROM rolestasks WHERE link='".mysql_real_escape_string($pageurl)."'");
|
||||
if($r=mysql_fetch_object($q)) {
|
||||
//okay we found it, now what do we do?
|
||||
//FIXME: we need to populate the secondarynva, tertiarynav, and select the right thing in the accordion,
|
||||
//because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus
|
||||
$navTree=array();
|
||||
upTree($r->id,&$navTree);
|
||||
foreach($navTree AS $t) {
|
||||
print_r($t);
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?
|
||||
|
2
nav.php
2
nav.php
@ -28,8 +28,10 @@
|
||||
if($id && $level) {
|
||||
switch($level) {
|
||||
case 1: //populate the scecondary menu
|
||||
if($_SESSION['nav']['primary']!=$id) {
|
||||
$_SESSION['nav']['primary']=$id;
|
||||
unset($_SESSION['nav']['secondary']);
|
||||
}
|
||||
$q=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' AND level=1 ORDER By ord,task");
|
||||
echo "<ul class=\"secondarynav\">";
|
||||
$cl="";
|
||||
|
Loading…
Reference in New Issue
Block a user