<?php

# Script:  Alphabetical Order List of Asteroids Etc. in Sweph Folder.phpb
#
# by Apollia - http://apollia.com/
#
# http://eryss.com/
#
#
# -------------------------------------------------------------------------------
# 
# In alphabetical order, lists the asteroid and dwarf planet ephemerides
# you have in your /root/sweph/ folder.
#
#-------------------------------------------------------------------------------
# 
# 
# Under the GNU Affero General Public License v3.0.
# 
# 
# Copyright (C) 2013-2019  Apollia
# 
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as published
#     by the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
# 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
# 
#     You should have received a copy of the GNU Affero General Public License
#     along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
# 
# Contact info:     http://astroblahhh.com/contact-apollia.shtml
# 
# ----



#*****************************************************************************
#
# Settings you can change. 
#
#

$Folder_of_Ephemerides="/root/sweph/";

$Should_Use_Space_Saving_Output_Format = false;
	# I think the non-space-saving format is more readable.
	# Doesn't apply to HTML page.


$Default_Search_Engine = "Bing";
	# Possibilities:
	#	
	#	AOL
	#	Bing
	#	Dogpile
	#	Google (its links doesn't work right with the Dillo web browser, as of 7:54:31 4/7/2013)
	#	Yahoo
	
	
$Web_Browser_Shell_Command = "defaultbrowser";
	# Possibilities:
	#
	#	dillo
	#		A fast but primitive web browser.  
	#		Installed in many Puppies by default.
	#		
	#		Much faster than Firefox and Chromium.
	#		
	#	firefox
	#	chromium
	#		These will work if you have them installed.  Will be slow for
	#		large files.
	#	
	#	defaultbrowser
	#		Whatever your default browser is set to be.
	#		
	#		It can be changed by editing this file:
	#		/usr/local/bin/defaultbrowser

	
$Should_Output_HTML_Page = true;
$Should_Display_HTML_Page = true;

$Full_Path_to_Temporary_HTML_Page = "/tmp/Temporary_File_of_Alphabetical_Order_List_of_Asteroids_Etc_in_Sweph_Folder.html";

#
#
# End of settings you can change.
#
#*****************************************************************************
#
#
# Everything else can be left alone.
#
#

require("includes/Library-of-Functions.php");


swe_set_ephe_path($Folder_of_Ephemerides);


$Ephemeris_Filenames = Get_Ephemeris_Filenames_from_Ephemeris_Files_in_($Folder_of_Ephemerides);
# Not just numbers - usually, numbers + "s", indicating a short ephemeris file
# covering 600 years - 1500-2100 - instead of a long ephemeris, covering
# 6000 years: -3000 to 3000.


$Asteroid_Numbers_and_Names = Asteroid_Numbers_and_Names_for_($Ephemeris_Filenames);
# Actually not just names - can be names + "long ephemeris" or "long & short". 
#
# The numbers, however, are now just numbers.


natcasesort($Asteroid_Numbers_and_Names);
	# Alphabetizes them.


Print_Asteroid_Numbers_and_Names($Should_Use_Space_Saving_Output_Format, $Asteroid_Numbers_and_Names);

Print_Total_Number_of_Celestial_Objects_and_Ephemerides($Asteroid_Numbers_and_Names, $Ephemeris_Filenames);



if ($Should_Output_HTML_Page)
{
	$Temporary_HTML_Page = new HTML_Page("Alphabetical Order List of Asteroids, Etc. in Sweph Folder", $CSS_for_HTML_Page, "<center><h3>Alphabetical Order List of Asteroids, Etc. in Sweph Folder</h3><p>");
	
	
	$html = Prepare_Total_Number_of_Celestial_Objects_and_Ephemerides_for_HTML_Display($Asteroid_Numbers_and_Names, $Ephemeris_Filenames);
	
	$Temporary_HTML_Page->Add_More_Content($html . "<p>");	
	
	if ($Web_Browser_Shell_Command == "dillo")
	{
		$html = Prepare_Dillo_Web_Browser_Tips_for_HTML_Display();
		$Temporary_HTML_Page->Add_More_Content("<p><br>" . $html . "<p>");	
	}
	
	$html = Prepare_Asteroid_Numbers_and_Names_for_HTML_Display($Asteroid_Numbers_and_Names);
	
	$Temporary_HTML_Page->Add_More_Content($html);	

	
	if ($Web_Browser_Shell_Command == "dillo")
	{
		$Temporary_HTML_Page -> Build_Page($dillo_html_body_stuff);
	}
	else
	{
		$Temporary_HTML_Page -> Build_Page();
	}
	
	$Temporary_HTML_Page -> Output_HTML_File_to_Path_($Full_Path_to_Temporary_HTML_Page);
}


if ($Should_Display_HTML_Page)
{
	execInBackground("$Web_Browser_Shell_Command \"$Full_Path_to_Temporary_HTML_Page\"");
}

die;

#
#
#
#*****************************************
# End of script.