initializing git repo
This commit is contained in:
commit
3df8fc53b8
86 changed files with 5649 additions and 0 deletions
173
includes/nested_list_functions.php
Executable file
173
includes/nested_list_functions.php
Executable file
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
///////////
|
||||
//logistics
|
||||
function NestedListGetParentId($Id, $TableName)
|
||||
{
|
||||
if (!$TableName || !$Id) return 0;
|
||||
$ReturnValue=0;
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
$Query = "SELECT `ParentId` FROM `$TableName` WHERE `Id` =$Id";
|
||||
$Query = mysqli_query($GlobalMysqlHandler, $Query);
|
||||
|
||||
if (mysqli_num_rows($Query))
|
||||
{
|
||||
$Data=mysqli_fetch_array($Query);
|
||||
$ReturnValue=$Data['ParentId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[nested_list_functions.php] No table element found at id $Id in table \"$Table\"!");
|
||||
}
|
||||
|
||||
return $ReturnValue;
|
||||
}
|
||||
|
||||
function NestedListGetName($Id, $TableName)
|
||||
{
|
||||
if (!$TableName || !$Id) return "";
|
||||
$ReturnValue="";
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
$Query = "SELECT `Name` FROM `$TableName` WHERE `Id` =$Id";
|
||||
$Query = mysqli_query($GlobalMysqlHandler, $Query);
|
||||
|
||||
if (mysqli_num_rows($Query))
|
||||
{
|
||||
$Data=mysqli_fetch_array($Query);
|
||||
$ReturnValue=$Data['Name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[nested_list_functions.php] No table element found at id $Id in table \"$Table\"!");
|
||||
}
|
||||
|
||||
return $ReturnValue;
|
||||
}
|
||||
|
||||
|
||||
function NestedLisGetSubelements ($ParentId, $TableName)
|
||||
{
|
||||
if (!$TableName) return 0;
|
||||
$ReturnValue=array();
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
$Query = "SELECT `Id`,`Name` FROM `$TableName` WHERE `ParentId` = $ParentId";
|
||||
$Query = mysqli_query($Query,$GlobalMysqlHandler);
|
||||
while ($Item = mysqli_fetch_row($Query))
|
||||
{
|
||||
$counter=count($ReturnValue);
|
||||
$ReturnValue[$counter][0] = $Item[0];
|
||||
$ReturnValue[$counter][1] = $Item[1];
|
||||
}
|
||||
|
||||
return $ReturnValue;
|
||||
}
|
||||
|
||||
/////////////
|
||||
// statistics
|
||||
|
||||
function NestedListCountSubElements($ParentId, $TableName)
|
||||
{
|
||||
if (!$TableName) return 0;
|
||||
$ReturnValue=1;
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
$Query = "SELECT * FROM `$TableName` WHERE `ParentId` =$ParentId";
|
||||
$Query = mysqli_query($GlobalMysqlHandler, $Query);
|
||||
|
||||
$ReturnValue=mysqli_num_rows($Query);
|
||||
|
||||
return $ReturnValue;
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
//list-visibility functions
|
||||
|
||||
function NestedListVisibilityToggle ($Id, $ListIdentifier)
|
||||
{
|
||||
if (!$Id || !$ListIdentifier) return;
|
||||
if (!isset($_SESSION[$ListIdentifier]))
|
||||
{
|
||||
$EmptyArray = array();
|
||||
$_SESSION[$ListIdentifier] = $EmptyArray;
|
||||
}
|
||||
|
||||
$IdArray = $_SESSION[$ListIdentifier];
|
||||
if (NestedListVisibilityIsSet($Id, $ListIdentifier)) $IdArray[$Id] = "False";
|
||||
else $IdArray[$Id] = "True";
|
||||
$_SESSION[$ListIdentifier]=$IdArray;
|
||||
}
|
||||
|
||||
function NestedListVisibilitySetAllParents ($Id, $ListIdentifier, $TableName)
|
||||
{
|
||||
global $GlobalMysqlHandler;
|
||||
while ($Id)
|
||||
{
|
||||
$Query="SELECT `ParentId` FROM `$TableName` WHERE `Id` = $Id";
|
||||
$Query=mysqli_query($GlobalMysqlHandler, $Query);
|
||||
if (mysqli_num_rows($Query))
|
||||
{
|
||||
$Item=mysqli_fetch_array($Query);
|
||||
$Id=$Item['ParentId'];
|
||||
NestedListVisibilitySet ($Id,$ListIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorLog("[nested_list_functions.php] No id '$Id' found in table '$TableName'!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function NestedListVisibilitySet ($Id, $ListIdentifier)
|
||||
{
|
||||
if (!NestedListVisibilityIsSet($Id, $ListIdentifier)) NestedListVisibilityToggle ($Id, $ListIdentifier);
|
||||
}
|
||||
|
||||
function NestedListVisibilityUnset ($Id, $ListIdentifier)
|
||||
{
|
||||
if (NestedListVisibilityIsSet($Id, $ListIdentifier)) NestedListVisibilityToggle ($Id, $ListIdentifier);
|
||||
}
|
||||
|
||||
function NestedListVisibilityIsSet ($Id, $ListIdentifier)
|
||||
{
|
||||
if (!$Id || !$ListIdentifier || !isset($_SESSION[$ListIdentifier])) return 0;
|
||||
$IdArray = $_SESSION[$ListIdentifier];
|
||||
//$Ret = ((count($IdArray)>=$Id) && (strtolower($IdArray[$Id])=="true")) ? 1:0;
|
||||
$Ret = (isset($IdArray[$Id]) && (strtolower($IdArray[$Id])=="true")) ? 1:0;
|
||||
return $Ret;
|
||||
}
|
||||
|
||||
function NestedListVisibilityUnsetAllSubelements ($ParentId, $ListIdentifier, $TableName)
|
||||
{
|
||||
if (!$TableName) return 0;
|
||||
$ReturnValue=1;
|
||||
global $GlobalMysqlHandler;
|
||||
|
||||
$Query = "SELECT * FROM `$TableName` WHERE `ParentId` =$ParentId";
|
||||
$Query = mysqli_query($GlobalMysqlHandler, $Query);
|
||||
while ($Item = mysqli_fetch_array($Query))
|
||||
{
|
||||
NestedListVisibilityUnset ($Item['Id'], $ListIdentifier);
|
||||
}
|
||||
|
||||
return $ReturnValue;
|
||||
}
|
||||
|
||||
function NestedListVisibilityUnsetAllElements ($ListIdentifier)
|
||||
{
|
||||
if (!$ListIdentifier) return;
|
||||
if (!isset($_SESSION[$ListIdentifier]))
|
||||
{
|
||||
$EmptyArray = array();
|
||||
$_SESSION[$ListIdentifier] = $EmptyArray;
|
||||
}
|
||||
|
||||
$IdArray = $_SESSION[$ListIdentifier];
|
||||
for ($i=0; $i < count($IdArray); $i++) $IdArray[$i] = "False";
|
||||
$_SESSION[$ListIdentifier]=$IdArray;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue