00001 <?php 00006 00007 class ConventionSettings 00008 { 00009 var $page_id = 12; 00010 var $menu_id = 100; 00011 var $title; 00012 var $defaultDuration = 4; 00013 var $currentConvention = null; 00014 var $currency; 00015 00016 var $availableConventions; 00017 var $nextConventionID = -1; 00018 00019 var $conventionDir; 00020 var $settingsFile; 00021 00025 function ConventionSettings() 00026 { 00027 global $module_folder; 00028 $this->title = i18n("Travelsized Conventions"); 00029 $this->settingsFile = "$module_folder/convention/settings.php"; 00030 $this->conventionDir = "$module_folder/convention/conventions"; 00031 00032 $this->load(); 00033 } 00034 00038 function load() 00039 { 00040 if( file_exists($this->settingsFile) ) 00041 include($this->settingsFile); 00042 00043 if( is_array( $settings ) ) 00044 foreach( $settings as $key => $value ) 00045 $this->$key = $value; 00046 00047 // Get a list of the available conventions 00048 $this->availableConventions = array(); 00049 00050 if( !is_dir($this->conventionDir) ) 00051 mkdir( $this->conventionDir ); 00052 00053 $dir = dir($this->conventionDir); 00054 while( false !== $entry = $dir->read() ) 00055 { 00056 // Skip dot files (including pointers) 00057 if ( substr($entry, 0, 1) == "." ) 00058 continue; 00059 00060 include( $this->conventionDir . "/$entry/convention.php" ); 00061 00062 $this->availableConventions[$entry] = $settings["title"]; 00063 } 00064 } 00065 00069 function save() 00070 { 00071 if( file_exists($this->settingsFile) ) 00072 unlink($this->settingsFile); 00073 00074 $settings["page_id"] = $this->page_id; 00075 $settings["menu_id"] = $this->menu_id; 00076 $settings["title"] = $this->title; 00077 $settings["defaultDuration"] = $this->defaultDuration; 00078 $settings["currentConvention"] = $this->currentConvention->id; 00079 $settings["currency"] = $this->currency; 00080 $settings["nextConventionID"] = $this->nextConventionID; 00081 00082 if( file_put_contents( $this->settingsFile, array_export( $settings, "settings" ) ) ) 00083 return true; 00084 else 00085 return false; 00086 } 00087 00088 function nextConventionID() 00089 { 00090 $this->nextConventionID++; 00091 $this->save(); 00092 return $this->nextConventionID; 00093 } 00094 } 00095 ?>