filter data on retrieval
This commit is contained in:
parent
bc323ec085
commit
44ec990b86
2 changed files with 23 additions and 9 deletions
includes
0
includes/layout.php
Normal file
0
includes/layout.php
Normal file
|
@ -1,12 +1,26 @@
|
|||
<?php
|
||||
$fname = "/srv/http/sitedata.yml";
|
||||
|
||||
$myfile = fopen($fname, "r") or die("Unable to open file!");
|
||||
$data = fread($myfile,filesize($fname));
|
||||
fclose($myfile);
|
||||
|
||||
$parsed = yaml_parse($data);
|
||||
|
||||
var_dump($parsed);
|
||||
function retrieve_data ($file, $public_only) {
|
||||
$freader = fopen($file, "r") or die("Unable to open file!");
|
||||
$yamldata = fread($freader,filesize($file));
|
||||
fclose($freader);
|
||||
|
||||
$data = yaml_parse($yamldata);
|
||||
if($public_only){
|
||||
$filtereddata = array();
|
||||
foreach($data as $category => $items){
|
||||
$filteredcat = array();
|
||||
foreach($items as $item => $value){
|
||||
if($value[public]=true){
|
||||
$filteredcat[$item] = $value;
|
||||
}
|
||||
}
|
||||
if($filteredcat){
|
||||
$filtereddata[$category] = $filteredcat;
|
||||
}
|
||||
}
|
||||
return $filtereddata;
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue