예제 #1
0
 public function processForm($data)
 {
     if (!isset($data['post'])) {
         return;
     }
     $form = $data['post'];
     $message = $data['message'];
     $notification = $data['notification'];
     $messages = $data['messages'];
     $this->setFormData($form->ID, $form->post_title);
     //  register field values
     $this->processFormForStrings($form->post_content, 'Value: ');
     // register form title
     $this->registerString('Form Title: ' . $form->post_title, $form->post_title);
     $this->registerString('Display Message: ' . $form->post_title, $message);
     // register Notification Data also
     if ($notification && isset($notification->notifications) && is_array($notification->notifications)) {
         foreach ($notification->notifications as $ii => $nott) {
             // new format
             // these are not relevant in new format for localization
             /*switch($nott['to']['type'])
               {
                   case 'wp_user':
                       $this->registerString('CRED Notification '.$ii.' Mail To', $nott['to']['user']);
                       break;
                   case 'specific_mail':
                       $this->registerString('CRED Notification '.$ii.' Mail To', $nott['to']['address']);
                       if (isset($nott['to']['name']))
                           $this->registerString('CRED Notification '.$ii.' Mail To Name', $nott['to']['name']);
                       if (isset($nott['to']['lastname']))
                           $this->registerString('CRED Notification '.$ii.' Mail To LastName', $nott['to']['lastname']);
                       break;
                   default:
                       break;
               }*/
             $hashSubject = CRED_Helper::strHash($nott['mail']['subject']);
             $hashBody = CRED_Helper::strHash($nott['mail']['body']);
             $this->registerString('CRED Notification Subject ' . $hashSubject, $nott['mail']['subject']);
             $this->registerString('CRED Notification Body ' . $hashBody, $nott['mail']['body']);
         }
     }
     // register messages also
     foreach ($messages as $msgid => $msg) {
         $this->registerString('Message_' . $msgid, $msg);
     }
     // register options from select and checkboxes/radio fields, force form build
     CRED_Loader::load('CLASS/Form_Builder');
     CRED_Form_Builder::init();
     CRED_Form_Builder::getForm($form->ID, null, false);
     // allow 3rd-party to add extra localization
     do_action('cred_localize_form', $data);
 }