PluginProbe
Smart Forms – when you need more than just a contact form / trunk
Smart Forms – when you need more than just a contact form vtrunk
trunk 0.5 0.5.5 0.6 0.7 0.8 0.8.5 0.9.1
smart-forms / php_classes / edit / php_entry_editor_base.php

php_entry_editor_base.php in Smart Forms – when you need more than just a contact form trunk, at php_classes/edit/php_entry_editor_base.php

47 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 abstract class php_entry_editor_base{
3 public $entryId;
4 private $newEntryData;
5 private $oldEntryData=null;
6 public $elementOptions;
7
8 private $formId=null;
9
10 public function __construct($entryId, $entryData, $elementOptions)
11 {
12 $this->entryId = $entryId;
13 $this->newEntryData = $entryData;
14 $this->elementOptions = $elementOptions;
15 }
16
17 public function GetNewEntryData($format){
18 if($format=='string')
19 return $this->newEntryData;
20
21 if($format=='raw')
22 return json_decode($this->newEntryData,true);
23 throw new Exception('Undefined format');
24 }
25
26 public function GetOldEntryData($format){
27 global $wpdb;
28 if($this->oldEntryData==null)
29 $this->oldEntryData=$wpdb->get_var($wpdb->prepare('select data from '.SMART_FORMS_ENTRY.' where entry_id=%d',$this->entryId));
30
31 if($format=='string')
32 return $this->oldEntryData;
33
34 if($format=='raw')
35 return json_decode($this->oldEntryData,true);
36
37 throw new Exception('Undefined format');
38 }
39
40 public function GetFormId(){
41 global $wpdb;
42 if($this->formId==null)
43 $this->formId=$wpdb->get_var($wpdb->prepare('select form_id from '.SMART_FORMS_ENTRY.' where entry_id=%d',$this->entryId));
44 return $this->formId;
45 }
46
47 }