Desc: Database Object to contain Preset Objects to be * saved to the database.

* * @package APL_Preset_Db * @since 0.1.0 * */ class APLPresetDbObj { /** * @var string * @since 0.1.0 */ var $_preset_db_name; /** * @var array(APL_Preset()) * @since 0.1.0 * @todo Change to array in 0.4.0 */ var $_preset_db; /** * @var string * @since 0.1.0 */ var $_delete; /** *

Desc: Loads Preset Database Option data. If no data * exists with the same name, then a new database * options is created and saved to the developer's * WordPress database.

* @param string $db_name * * @since 0.1.0 * @uses $this->option_load_db() * @uses $this->set_to_defaults() * @uses $this->options_save_db(); * * @tutorial *
    *
  1. Store Preset_Database-Name to * $this->Preset_Database-Name.
  2. *
  3. Load 'Preset DbOptions' values, if any then * skip Steps 3-4.
  4. *
  5. Set (this) values to default values.
  6. *
  7. Save 'Preset DbOptions.
  8. *
*/ function __construct($db_name = '') { //init $this->_preset_db_name = ''; $this->_preset_db = new stdClass(); $this->_delete = 'true'; if (!empty($db_name)) { //Step 1 $this->_preset_db_name = 'APL_preset_db-' . $db_name; //Step 2 $this->option_load_db(); } // //If data doesn't exist in options, then make one // if (empty($this->_preset_db) && empty($this->_delete)) // { // //Step 3 // $this->set_to_defaults(); // //Step 4 // $this->options_save_db(); // //$this->option_load_db(); // } } public function reset_to_version($version) { $this->reset_to_base(); } private function reset_to_base() { $this->_preset_db_name = ''; $this->_preset_db = new stdClass(); $this->_delete = 'true'; } /** *

Desc: Loads and stores database values to * (this) class values.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Get 'Preset DbOptions with the value stored in * the class varible _preset_db_name.
  2. *
  3. Store database varible to class values (_preset_db & _delete).
  4. *
*/ function option_load_db() { //Step 1 $DBOptions = get_option($this->_preset_db_name); //Step 2 if ($DBOptions == FALSE) { $this->set_to_defaults(); $this->options_save_db(); } else { $a01 = unserialize(serialize($DBOptions)); $a01 = unserialize(serialize($DBOptions->_preset_db)); $a01 = unserialize(serialize($DBOptions->_delete)); $this->_preset_db = $DBOptions->_preset_db; $this->_delete = $DBOptions->_delete; } } /** *

Desc: Saves (this) class object to the developer's * WordPress database.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Save (this) class object to database.
  2. *
*/ function options_save_db() { //Step 1 update_option($this->_preset_db_name, $this); } // function options_save_db($newOptions) // { // // //$this->_option_db_name = 'APL_option_db_'.$db_name; // //$this->update_options_db(); // if (isset($newOptions)) // { // $this->_preset_db = $newOptions->_preset_db; // update_option($newOptions->_preset_db_name, $newOptions); // } // // } /** *

Desc: Deletes the 'Preset Database Options' that is * stored in the devoloper's WordPress database.

* @param none * * @since 0.1.0 * * @tutorial *
    *
  1. Delete Options with the same Preset Db Options name.
  2. *
*/ function options_remove_db() { //Step 1 delete_option($this->_preset_db_name); } /** *

Desc:

* @param none * @return string - returns a JSON string of the Standard Class * * @since 0.1.0 * * @tutorial *
    *
  1. Set delete to 'true'.
  2. *
  3. Create a temp Preset (stdclass). Hardcoded as a JSON string.
  4. *
  5. JSON Decode and store in (this) class _preset_db value.
  6. *
  7. *
  8. *
  9. *
  10. *
  11. *
  12. *
*/ function set_to_defaults() { $this->_preset_db = new stdClass(); //$this->_preset_db = array(); //Step 1 $this->_delete = 'true'; //Step 2 $tmpPreset = (string) '{ "pageContentDivided_5": { "_postParents":[], "_postTax":{}, "_listCount":5, "_listOrderBy":"date", "_listOrder":"DESC", "_postVisibility":["public"], "_postStatus":["publish"], "_userPerm":"readable", "_postAuthorOperator":"none", "_postAuthorIDs":[], "_listIgnoreSticky":false, "_listExcludePosts":[], "_listExcludeDuplicates":false, "_postExcludeCurrent":true, "_exit":"", "_before":"

", "_content":"[post_title]<\/a> by [post_author] - [post_date][post_content]", "_after":"<\/p>" }, "postExcerptDivided_5": { "_postParents":[], "_postTax":{}, "_listCount":5, "_listOrderBy":"date", "_listOrder":"DESC", "_postVisibility":["public"], "_postStatus":["publish"], "_userPerm":"readable", "_postAuthorOperator":"none", "_postAuthorIDs":[], "_listIgnoreSticky":false, "_listExcludePosts":[], "_listExcludeDuplicates":false, "_postExcludeCurrent":true, "_exit":"", "_before":"

", "_content":"[post_title]<\/a> by [post_author] - [post_date][post_excerpt]", "_after":"<\/p>" }, "simpleAttachmentList_10": { "_postParents":[], "_postTax":{}, "_listCount":10, "_listOrderBy":"date", "_listOrder":"DESC", "_postVisibility":["public"], "_postStatus":["publish"], "_userPerm":"readable", "_postAuthorOperator":"none", "_postAuthorIDs":[], "_listIgnoreSticky":false, "_listExcludePosts":[], "_listExcludeDuplicates":false, "_postExcludeCurrent":true, "_exit":"", "_before":"