Skip to content

Commit

Permalink
Fix running on PHP 5.x (replace [] by array()
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 19, 2023
1 parent 24bdf2f commit 89c5638
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 41 deletions.
14 changes: 7 additions & 7 deletions modules/site/edithtml.php
Expand Up @@ -27,7 +27,7 @@

function get_children ($parent_id, $lookup, $column, $type) {
// children
$children = [];
$children = array();
//we are at a leaf level
if (empty($lookup[$parent_id]['children'])){
return $children;
Expand Down Expand Up @@ -175,9 +175,9 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
*/
$sql = "select category_id, category_name, parent_id from {$xerte_toolkits_site->database_table_prefix}syndicationcategories";
$categories = db_query($sql);
$lookup = [];
$lookup = array();
foreach ($categories as $node){
$node['children'] = [];
$node['children'] = array();
$lookup = $lookup + [$node['category_id'] => $node];
}
foreach ($lookup as $node){
Expand All @@ -186,7 +186,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
}
}

$parsed_categories = [];
$parsed_categories = array();
foreach ($lookup as $value){
//find all tree origins
if ($value['parent_id'] == null) {
Expand All @@ -202,9 +202,9 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$sql = "select educationlevel_id, educationlevel_name, parent_id from {$xerte_toolkits_site->database_table_prefix}educationlevel order by parent_id asc";
$educationlevels = db_query($sql);

$lookup = [];
$lookup = array();
foreach ($educationlevels as $node){
$node['children'] = [];
$node['children'] = array();
$lookup = $lookup + [$node['educationlevel_id'] => $node];
}
foreach ($lookup as $node){
Expand All @@ -213,7 +213,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
}
}

$parsed_educationlevels = [];
$parsed_educationlevels = array();
foreach ($lookup as $value){
//find all tree origins
if ($value['parent_id'] == null) {
Expand Down
14 changes: 7 additions & 7 deletions modules/xerte/edithtml.php
Expand Up @@ -28,7 +28,7 @@

function get_children ($parent_id, $lookup, $column, $type) {
// children
$children = [];
$children = array();
//we are at a leaf level
if (empty($lookup[$parent_id]['children'])){
return $children;
Expand Down Expand Up @@ -198,9 +198,9 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
*/
$sql = "select category_id, category_name, parent_id from {$xerte_toolkits_site->database_table_prefix}syndicationcategories";
$categories = db_query($sql);
$lookup = [];
$lookup = array();
foreach ($categories as $node){
$node['children'] = [];
$node['children'] = array();
$lookup = $lookup + [$node['category_id'] => $node];
}
foreach ($lookup as $node){
Expand All @@ -209,7 +209,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
}
}

$parsed_categories = [];
$parsed_categories = array();
foreach ($lookup as $value){
//find all tree origins
if ($value['parent_id'] == null) {
Expand All @@ -225,9 +225,9 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
$sql = "select educationlevel_id, educationlevel_name, parent_id from {$xerte_toolkits_site->database_table_prefix}educationlevel order by parent_id asc";
$educationlevels = db_query($sql);

$lookup = [];
$lookup = array();
foreach ($educationlevels as $node){
$node['children'] = [];
$node['children'] = array();
$lookup = $lookup + [$node['educationlevel_id'] => $node];
}
foreach ($lookup as $node){
Expand All @@ -236,7 +236,7 @@ function output_editor_code($row_edit, $xerte_toolkits_site, $read_status, $vers
}
}

$parsed_educationlevels = [];
$parsed_educationlevels = array();
foreach ($lookup as $value){
//find all tree origins
if ($value['parent_id'] == null) {
Expand Down
4 changes: 2 additions & 2 deletions oai-pmh/management/categories.php
Expand Up @@ -8,7 +8,7 @@
if ($argc > 1) {
clearCategoryTable();
createCategoryTable();
$lookup = [];
$lookup = array();
for ($args = 1; $args < $argc; $args++) {

$xmlfile = $argv[$args];
Expand All @@ -20,7 +20,7 @@
$relations = $xml->xpath("//vdex:relationship");

foreach ($nodes as $node) {
$row = [];
$row = array();
$ns = $node->getNamespaces();
$c = $node->children($ns['vdex']);
$row[label] = (string)$c->caption->langstring;
Expand Down
4 changes: 2 additions & 2 deletions oai-pmh/management/educational.php
Expand Up @@ -16,10 +16,10 @@

$nodes = $xml->xpath('//vdex:term');
$relations = $xml->xpath("//vdex:relationship");
$lookup = [];
$lookup = array();

foreach ($nodes as $node) {
$row = [];
$row = array();
$c = $node->children($ns['vdex']);
$row['label'] = (string)$c->caption->langstring;
$row['ID'] = (string)$c->termIdentifier;
Expand Down
2 changes: 1 addition & 1 deletion oai-pmh/oai.php
Expand Up @@ -240,7 +240,7 @@ function getTemplates($metadataPrefix,$from,$until) {
$q = "select template_id, status, timestamp from {$xerte_toolkits_site->database_table_prefix}oai_publish where audith_id IN (SELECT max(audith_id) from {$xerte_toolkits_site->database_table_prefix}oai_publish group by template_id)";
$publish_status = db_query($q);
}
$temp_added = [];
$temp_added = array();

for($i=0;$i<count($templates);$i++)
{
Expand Down
18 changes: 9 additions & 9 deletions oai-pmh/xerteobjects.php
Expand Up @@ -110,17 +110,17 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
$cat = (string)$xml['category'];
}
$cat = explode("|", $cat);
$response = [];
$xerteMetaObj->domain = [];
$xerteMetaObj->domainId = [];
$xerteMetaObj->domainSource = [];
$response = array();
$xerteMetaObj->domain = array();
$xerteMetaObj->domainId = array();
$xerteMetaObj->domainSource = array();
$q = "select * from {$xerte_toolkits_site->database_table_prefix}oai_categories where label=?";
// query oai_categories
foreach ($cat as $value){
$params = array($value);
$response[] = db_query_one($q, $params);
}
$parents = [];
$parents = array();
foreach ($response as $data){
if ($data !== false and $data !== null) {
$xerteMetaObj->domain[] = $data["label"];
Expand Down Expand Up @@ -153,16 +153,16 @@ function get_meta_data($template_id, $creator_user_name="", $template_type_name=
if (isset($xml['metaEducation'])) {
// query oai-education
$edu = explode("|", (string)$xml["metaEducation"]);
$response = [];
$xerteMetaObj->level = [];
$xerteMetaObj->levelId = [];
$response = array();
$xerteMetaObj->level = array();
$xerteMetaObj->levelId = array();
$q = "select * from {$xerte_toolkits_site->database_table_prefix}oai_education where label=?";

foreach ($edu as $value){
$params = array($value);
$response[] = db_query_one($q, $params);
}
$parents = [];
$parents = array();
foreach ($response as $data){
if ($data !== false and $data !== null) {
$xerteMetaObj->level[] = $data["label"];
Expand Down
8 changes: 4 additions & 4 deletions website_code/php/display_library.php
Expand Up @@ -736,7 +736,7 @@ function get_workspace_contents($folder_id, $tree_id, $sort_type, $copy_only=fal
//remove double items


$uniqueItems = [];
$uniqueItems = array();
foreach ($items as $item => $value){
/*if(!in_array($value, $uniqueItems)){
$uniqueItems[$item] = $value;
Expand Down Expand Up @@ -936,7 +936,7 @@ function get_workspace_folders($folder_id, $tree_id, $sort_type, $copy_only=fals
_debug("Error in get_workspace_folders: " . $error_msg);
}

$sharedFolders = [];
$sharedFolders = array();
foreach ($query_response as $index => $folder){
if(intval($folder['nrshared']) > 1){
array_push($sharedFolders, $folder["folder_id"]);
Expand All @@ -960,7 +960,7 @@ function get_workspace_folders($folder_id, $tree_id, $sort_type, $copy_only=fals
}

/*$query = "SELECT * FROM folderdetails where";
$params = [];
$params = array();
foreach ($query_response as $folder){
if(intval($folder['nrshared']) > 1){
Expand Down Expand Up @@ -1148,7 +1148,7 @@ function get_users_projects($sort_type, $copy_only=false)
$workspace->nodes[$item->id] = $item;
//$items = get_folder_contents($item->xot_id, $item->id, $sort_type, $copy_only, "_top");
$items = get_workspace_contents($item->xot_id, $item->id, $sort_type, $copy_only,"_top");
$sharedItems = [];
$sharedItems = array();
if ($items) {
$workspace->items = array_merge($workspace->items, $items);
foreach($items as $item)
Expand Down
2 changes: 1 addition & 1 deletion website_code/php/management/add_member.php
Expand Up @@ -58,7 +58,7 @@ function add_members_to_group($login_ids, $group_id){
$query = "SELECT * FROM {$prefix}user_group_members WHERE group_id=? AND login_id in (" . $logins . ")";
$exists = db_query($query, $params);

$existing_arr = [];
$existing_arr = array();
foreach($exists as $row){
array_push($existing_arr, $row['login_id']);
}
Expand Down
8 changes: 4 additions & 4 deletions website_code/php/management/management_library.php
Expand Up @@ -30,12 +30,12 @@ function category_list(){
$query_response = db_query($query);

//build tree
$tree = [];
$tree = array();
foreach ($query_response as $data){
if (!is_null($data) or $data !== false) {
$child[id] = $data["category_id"];
$child[name] = $data["category_name"];
$child[children] = [];
$child[children] = array();
if (is_null($data["parent_id"])) {
$tree[$child["id"]] = $child;
} else {
Expand Down Expand Up @@ -82,12 +82,12 @@ function educationlevel_list(){
$query_response = db_query($query);

//build tree
$tree = [];
$tree = array();
foreach ($query_response as $data){
if (!is_null($data) or $data !== false) {
$child[id] = $data["educationlevel_id"];
$child[name] = $data["educationlevel_name"];
$child[children] = [];
$child[children] = array();
if (is_null($data["parent_id"])) {
$tree[$child["id"]] = $child;
} else {
Expand Down
8 changes: 4 additions & 4 deletions website_code/php/properties/properties_library.php
Expand Up @@ -854,8 +854,8 @@ function sharing_info($template_id)
$sql = "SELECT * FROM {$xerte_toolkits_site->database_table_prefix}folderrights where folder_id = ?";
$query_folders = db_query($sql, array($query_folder_id[0]["folder"]));

$related_folders = [];
$params = [];
$related_folders = array();
$params = array();
array_push($related_folders, $query_folders[0]);

if(!empty($related_folders)){
Expand Down Expand Up @@ -1197,8 +1197,8 @@ function folder_sharing_info($folder_id)
$sql = "SELECT * FROM {$xerte_toolkits_site->database_table_prefix}folderrights where folder_id = ?";
$query_folders = db_query($sql, array($query_folder_id["folder_id"]));

$related_folders = [];
$params = [];
$related_folders = array();
$params = array();
array_push($related_folders, $query_folders[0]);

if(!empty($related_folders)){
Expand Down

0 comments on commit 89c5638

Please sign in to comment.