Beispiel #1
0
 /**
  * Default constructor that takes in initial parameters and setting prefix.
  * @param Array $paramList The list of parameters to create the form from.
  * @param String $settingPrefix The prefix to use for the settings.
  * @param String $formID The optional ID to give to the form. Ideal for when there's more than 1 form on a page. 
  */
 public function __construct($paramList, $settingPrefix, $formID = false)
 {
     parent::__construct($paramList, $formID);
     // Default save text reflects this is a settings form
     $this->buttonText = 'Save Settings';
     // Store the setting prefix.
     $this->settingPrefix = $settingPrefix;
     // Load default values
     parent::loadDefaults(TidySettings_getSettings($settingPrefix));
 }
Beispiel #2
0
 /**
  * Default constructor that takes in initial parameters and setting prefix.
  * @param Array $paramList The list of parameters to create the form from.
  * @param String $settingPrefix The prefix to use for the settings.
  * @param String $formID The optional ID to give to the form. Ideal for when there's more than 1 form on a page. 
  */
 public function __construct($paramList, $settingPrefix, $formID = false)
 {
     parent::__construct($paramList, $formID);
     // Default save text reflects this is a settings form
     $this->buttonText = __('Save Settings');
     // Store the setting prefix.
     $this->settingPrefix = $settingPrefix;
     // Messages
     $this->msg_settingsSaved = __('Settings successfully saved.');
     $this->msg_settingsProblem = __('There was a problem saving the settings.');
     // Load default values
     parent::loadDefaults(TidySettings_getSettings($settingPrefix));
 }
 /**
  * If we have primary key and table details, load details from the database to load the defaults. This method 
  * will also load the meta values if we have any.
  * 
  * @return Return the details that were loaded from the database.
  */
 protected function loadDefaultsFromDB()
 {
     if (!$this->primaryKey || !$this->tableName) {
         $this->messages = $this->showMessage('loadDefaultsFromDB(): Nothing could be loaded, as the table name and primary key details are invalid.', true);
         return false;
     }
     // Fetch any existing details for the main record.
     $this->recordDetails = getRecordDetails($this->tableName, $this->primaryKey, $this->primaryKeyValue, ARRAY_A);
     if (empty($this->recordDetails)) {
         return false;
     }
     // Try to fetch the meta values if we have any
     if (!empty($this->meta_element_list)) {
         if (!$this->metaTableName) {
             $this->messages = $this->showMessage('loadDefaultsFromDB(): The specified meta table is not valid, so meta values could not be loaded.', true);
             return $this->recordDetails;
         }
         global $wpdb;
         $wpdb->show_errors();
         foreach ($this->meta_element_list as $fieldName) {
             $SQL = $wpdb->prepare("\n\t\t\t\t\tSELECT meta_value \n\t\t\t\t\tFROM {$this->metaTableName}\n\t\t\t\t\tWHERE {$this->primaryKey} = %s\n\t\t\t\t\t  AND meta_key = %s\n\t\t\t\t\tLIMIT 1", $this->primaryKeyValue, $fieldName);
             // Add details, even if blank
             $this->recordDetails[$fieldName] = $wpdb->get_var($SQL);
         }
         // end of foreach
     }
     // end of if
     // Load the details into the defaults.
     parent::loadDefaults($this->recordDetails);
     // Exists checks
     $this->alreadyInDB = true;
     return $this->recordDetails;
 }