Fix sort order for the reorganization

This commit is contained in:
Squidly271 2021-02-21 12:04:53 -05:00
parent 466d9a1099
commit 39edcb2a1f
2 changed files with 29 additions and 55 deletions

View File

@ -94,7 +94,7 @@ switch ($_POST['action']) {
previous_apps(); previous_apps();
break; break;
case 'remove_application': case 'remove_application':
remove_applications(); remove_application();
break; break;
case 'updatePLGstatus': case 'updatePLGstatus':
updatePLGstatus(); updatePLGstatus();
@ -520,7 +520,7 @@ function displayRepositories() {
# get_content - get the results from templates according to categories, filters, etc # # get_content - get the results from templates according to categories, filters, etc #
###################################################################################### ######################################################################################
function get_content() { function get_content() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$filter = getPost("filter",false); $filter = getPost("filter",false);
$category = getPost("category",false); $category = getPost("category",false);
@ -745,7 +745,7 @@ function get_content() {
# force_update -> forces an update of the applications # # force_update -> forces an update of the applications #
######################################################## ########################################################
function force_update() { function force_update() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$lastUpdatedOld = readJsonFile($caPaths['lastUpdated-old']); $lastUpdatedOld = readJsonFile($caPaths['lastUpdated-old']);
@ -800,8 +800,7 @@ function force_update() {
# display_content - displays the templates according to view mode, sort order, etc # # display_content - displays the templates according to view mode, sort order, etc #
#################################################################################### ####################################################################################
function display_content() { function display_content() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$sortOrder = getSortOrder(getPostArray('sortOrder')); $sortOrder = getSortOrder(getPostArray('sortOrder'));
$pageNumber = getPost("pageNumber","1"); $pageNumber = getPost("pageNumber","1");
$startup = getPost("startup",false); $startup = getPost("startup",false);
@ -821,8 +820,7 @@ function display_content() {
# convert_docker - called when system adds a container from dockerHub # # convert_docker - called when system adds a container from dockerHub #
####################################################################### #######################################################################
function convert_docker() { function convert_docker() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$dockerID = getPost("ID",""); $dockerID = getPost("ID","");
$file = readJsonFile($caPaths['dockerSearchResults']); $file = readJsonFile($caPaths['dockerSearchResults']);
@ -854,8 +852,7 @@ function convert_docker() {
# search_dockerhub - returns the results from dockerHub # # search_dockerhub - returns the results from dockerHub #
######################################################### #########################################################
function search_dockerhub() { function search_dockerhub() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$filter = getPost("filter",""); $filter = getPost("filter","");
$pageNumber = getPost("page","1"); $pageNumber = getPost("page","1");
$sortOrder = getSortOrder(getPostArray('sortOrder')); $sortOrder = getSortOrder(getPostArray('sortOrder'));
@ -913,14 +910,12 @@ function search_dockerhub() {
# dismiss_warning - dismisses the warning from appearing at startup # # dismiss_warning - dismisses the warning from appearing at startup #
##################################################################### #####################################################################
function dismiss_warning() { function dismiss_warning() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
file_put_contents($caPaths['warningAccepted'],"warning dismissed"); file_put_contents($caPaths['warningAccepted'],"warning dismissed");
postReturn(['status'=>"warning dismissed"]); postReturn(['status'=>"warning dismissed"]);
} }
function dismiss_plugin_warning() { function dismiss_plugin_warning() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
file_put_contents($caPaths['pluginWarning'],"disclaimer ok"); file_put_contents($caPaths['pluginWarning'],"disclaimer ok");
postReturn(['status'=>"disclaimed"]); postReturn(['status'=>"disclaimed"]);
} }
@ -929,8 +924,7 @@ function dismiss_plugin_warning() {
# Displays the list of installed or previously installed apps # # Displays the list of installed or previously installed apps #
############################################################### ###############################################################
function previous_apps() { function previous_apps() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$installed = getPost("installed",""); $installed = getPost("installed","");
$dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']); $dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
$info = $caSettings['dockerRunning'] ? $DockerClient->getDockerContainers() : array(); $info = $caSettings['dockerRunning'] ? $DockerClient->getDockerContainers() : array();
@ -1127,8 +1121,7 @@ if ( $caSettings['dockerRunning'] ) {
# Removes an app from the previously installed list (ie: deletes the user template # # Removes an app from the previously installed list (ie: deletes the user template #
#################################################################################### ####################################################################################
function remove_application() { function remove_application() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$application = getPost("application",""); $application = getPost("application","");
if ( pathinfo($application,PATHINFO_EXTENSION) == "xml" || pathinfo($application,PATHINFO_EXTENSION) == "plg" ) if ( pathinfo($application,PATHINFO_EXTENSION) == "xml" || pathinfo($application,PATHINFO_EXTENSION) == "plg" )
@unlink($application); @unlink($application);
@ -1140,8 +1133,7 @@ function remove_application() {
# Checks for an update still available (to update display) after update installed # # Checks for an update still available (to update display) after update installed #
################################################################################### ###################################################################################
function updatePLGstatus() { function updatePLGstatus() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$filename = getPost("filename",""); $filename = getPost("filename","");
$displayed = readJsonFile($caPaths['community-templates-displayed']); $displayed = readJsonFile($caPaths['community-templates-displayed']);
$superCategories = array_keys($displayed); $superCategories = array_keys($displayed);
@ -1161,8 +1153,7 @@ function updatePLGstatus() {
# Uninstalls a docker # # Uninstalls a docker #
####################### #######################
function uninstall_docker() { function uninstall_docker() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$application = getPost("application",""); $application = getPost("application","");
# get the name of the container / image # get the name of the container / image
@ -1186,8 +1177,7 @@ function uninstall_docker() {
# Pins / Unpins an application for later viewing # # Pins / Unpins an application for later viewing #
################################################## ##################################################
function pinApp() { function pinApp() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$repository = getPost("repository","oops"); $repository = getPost("repository","oops");
$name = getPost("name","oops"); $name = getPost("name","oops");
$pinnedApps = readJsonFile($caPaths['pinnedV2']); $pinnedApps = readJsonFile($caPaths['pinnedV2']);
@ -1200,8 +1190,7 @@ function pinApp() {
# Gets if any apps are pinned or not # # Gets if any apps are pinned or not #
###################################### ######################################
function areAppsPinned() { function areAppsPinned() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
postReturn(['status' => in_array(true,readJsonFile($caPaths['pinnedV2']))]); postReturn(['status' => in_array(true,readJsonFile($caPaths['pinnedV2']))]);
} }
@ -1209,8 +1198,7 @@ function areAppsPinned() {
# Displays the pinned applications # # Displays the pinned applications #
#################################### ####################################
function pinnedApps() { function pinnedApps() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$pinnedApps = readJsonFile($caPaths['pinnedV2']); $pinnedApps = readJsonFile($caPaths['pinnedV2']);
$file = readJsonFile($caPaths['community-templates-info']); $file = readJsonFile($caPaths['community-templates-info']);
@unlink($caPaths['community-templates-allSearchResults']); @unlink($caPaths['community-templates-allSearchResults']);
@ -1251,8 +1239,7 @@ function pinnedApps() {
# Displays the possible branch tags for an app # # Displays the possible branch tags for an app #
################################################ ################################################
function displayTags() { function displayTags() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$leadTemplate = getPost("leadTemplate","oops"); $leadTemplate = getPost("leadTemplate","oops");
postReturn(['tags'=>formatTags($leadTemplate)]); postReturn(['tags'=>formatTags($leadTemplate)]);
} }
@ -1261,8 +1248,7 @@ function displayTags() {
# Displays The Statistics For The Appfeed # # Displays The Statistics For The Appfeed #
########################################### ###########################################
function statistics() { function statistics() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
@unlink($caPaths['community-templates-displayed']); @unlink($caPaths['community-templates-displayed']);
@unlink($caPaths['community-templates-allSearchResults']); @unlink($caPaths['community-templates-allSearchResults']);
@unlink($caPaths['community-templates-catSearchResults']); @unlink($caPaths['community-templates-catSearchResults']);
@ -1349,8 +1335,7 @@ function statistics() {
# Removes a private app from the list # # Removes a private app from the list #
####################################### #######################################
function removePrivateApp() { function removePrivateApp() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$path = getPost("path",false); $path = getPost("path",false);
if ( ! $path || pathinfo($path,PATHINFO_EXTENSION) != "xml") { if ( ! $path || pathinfo($path,PATHINFO_EXTENSION) != "xml") {
@ -1381,8 +1366,7 @@ function removePrivateApp() {
# Creates the entries for autocomplete on searches # # Creates the entries for autocomplete on searches #
#################################################### ####################################################
function populateAutoComplete() { function populateAutoComplete() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$templates = readJsonFile($caPaths['community-templates-info']); $templates = readJsonFile($caPaths['community-templates-info']);
$autoComplete = array_map(function($x){return str_replace(":","",tr($x['Cat']));},readJsonFile($caPaths['categoryList'])); $autoComplete = array_map(function($x){return str_replace(":","",tr($x['Cat']));},readJsonFile($caPaths['categoryList']));
foreach ($templates as $template) { foreach ($templates as $template) {
@ -1428,8 +1412,7 @@ function populateAutoComplete() {
# Displays the changelog # # Displays the changelog #
########################## ##########################
function caChangeLog() { function caChangeLog() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$o = "<div style='margin:auto;width:500px;'>"; $o = "<div style='margin:auto;width:500px;'>";
$o .= "<div class='ca_center'><font size='4rem'>".tr("Community Applications Changelog")."</font></div><br><br>"; $o .= "<div class='ca_center'><font size='4rem'>".tr("Community Applications Changelog")."</font></div><br><br>";
postReturn(["changelog"=>$o.Markdown(plugin("changes","/var/log/plugins/community.applications.plg"))."<br><br>"]); postReturn(["changelog"=>$o.Markdown(plugin("changes","/var/log/plugins/community.applications.plg"))."<br><br>"]);
@ -1439,8 +1422,7 @@ function caChangeLog() {
# Populates the category list # # Populates the category list #
############################### ###############################
function get_categories() { function get_categories() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$categories = readJsonFile($caPaths['categoryList']); $categories = readJsonFile($caPaths['categoryList']);
if ( ! is_array($categories) || empty($categories) ) { if ( ! is_array($categories) || empty($categories) ) {
$cat = "<span class='ca_fa-warning'></span> Category list N/A<br><br>"; $cat = "<span class='ca_fa-warning'></span> Category list N/A<br><br>";
@ -1491,8 +1473,7 @@ function get_categories() {
# Get the html for the popup # # Get the html for the popup #
############################## ##############################
function getPopupDescription() { function getPopupDescription() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$appNumber = getPost("appPath",""); $appNumber = getPost("appPath","");
postReturn(getPopupDescriptionSkin($appNumber)); postReturn(getPopupDescriptionSkin($appNumber));
} }
@ -1501,8 +1482,7 @@ function getPopupDescription() {
# Get the html for a repo popup # # Get the html for a repo popup #
################################# #################################
function getRepoDescription() { function getRepoDescription() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$repository = html_entity_decode(getPost("repository",""),ENT_QUOTES); $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
postReturn(getRepoDescriptionSkin($repository)); postReturn(getRepoDescriptionSkin($repository));
} }
@ -1511,8 +1491,7 @@ function getRepoDescription() {
# Creates the XML for a container install # # Creates the XML for a container install #
########################################### ###########################################
function createXML() { function createXML() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$xmlFile = getPost("xml",""); $xmlFile = getPost("xml","");
if ( ! $xmlFile ) { if ( ! $xmlFile ) {
postReturn(["error"=>"CreateXML: XML file was missing"]); postReturn(["error"=>"CreateXML: XML file was missing"]);
@ -1606,8 +1585,7 @@ function createXML() {
# Switch to a language # # Switch to a language #
######################## ########################
function switchLanguage() { function switchLanguage() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$language = getPost("language",""); $language = getPost("language","");
if ( $language == "en_US" ) if ( $language == "en_US" )
$language = ""; $language = "";
@ -1626,8 +1604,7 @@ function switchLanguage() {
# Delete multiple checked off apps from previous apps # # Delete multiple checked off apps from previous apps #
####################################################### #######################################################
function remove_multiApplications() { function remove_multiApplications() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$apps = getPostArray("apps"); $apps = getPostArray("apps");
if ( ! count($apps) ) { if ( ! count($apps) ) {
postReturn(["error"=>"No apps were in post when trying to remove multiple applications"]); postReturn(["error"=>"No apps were in post when trying to remove multiple applications"]);
@ -1650,8 +1627,7 @@ function remove_multiApplications() {
# Get's the categories present on a search # # Get's the categories present on a search #
############################################ ############################################
function getCategoriesPresent() { function getCategoriesPresent() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
if ( is_file($caPaths['community-templates-allSearchResults']) ) if ( is_file($caPaths['community-templates-allSearchResults']) )
$displayed = readJsonFile($caPaths['community-templates-allSearchResults']); $displayed = readJsonFile($caPaths['community-templates-allSearchResults']);
else else
@ -1679,8 +1655,7 @@ function getCategoriesPresent() {
# Set's the favourite repository # # Set's the favourite repository #
################################## ##################################
function toggleFavourite() { function toggleFavourite() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
$repository = html_entity_decode(getPost("repository",""),ENT_QUOTES); $repository = html_entity_decode(getPost("repository",""),ENT_QUOTES);
$caSettings['favourite'] = $repository; $caSettings['favourite'] = $repository;
@ -1692,8 +1667,7 @@ function toggleFavourite() {
# Returns the favourite repository # # Returns the favourite repository #
#################################### ####################################
function getFavourite() { function getFavourite() {
global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning; global $caPaths, $caSettings, $DockerClient, $DockerTemplates, $dockerRunning, $sortOrder;
postReturn(["favourite"=>$caSettings['favourite']]); postReturn(["favourite"=>$caSettings['favourite']]);
} }
?> ?>