filter data on retrieval
This commit is contained in:
parent
bc323ec085
commit
44ec990b86
2 changed files with 23 additions and 9 deletions
0
includes/layout.php
Normal file
0
includes/layout.php
Normal file
|
@ -1,12 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
$fname = "/srv/http/sitedata.yml";
|
function retrieve_data ($file, $public_only) {
|
||||||
|
$freader = fopen($file, "r") or die("Unable to open file!");
|
||||||
$myfile = fopen($fname, "r") or die("Unable to open file!");
|
$yamldata = fread($freader,filesize($file));
|
||||||
$data = fread($myfile,filesize($fname));
|
fclose($freader);
|
||||||
fclose($myfile);
|
|
||||||
|
|
||||||
$parsed = yaml_parse($data);
|
|
||||||
|
|
||||||
var_dump($parsed);
|
|
||||||
|
|
||||||
|
$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