コード例 #1
0
ファイル: controller.php プロジェクト: Roman921/Step-21
 public function importData()
 {
     $res = new responseGmp();
     if (!isset($_FILES['BackupFileCsv'])) {
         $res->addError(langGmp::_("Cannot Upload File"));
         return $res->ajaxExec();
     }
     $fileData = $_FILES['BackupFileCsv'];
     $uplDir = wp_upload_dir();
     $filePath = $uplDir['path'];
     $source = $fileData['tmp_name'];
     $dest = $filePath . DS . $fileData['name'];
     if (!copy($source, $dest)) {
         $res->addError(langRpw::_("Cannot Copy File"));
         return $res->ajaxExec();
     }
     $backupInfoCsv = file_get_contents($dest);
     $backupInfo = utilsGmp::unserialize($backupInfoCsv);
     if (empty($backupInfo)) {
         $res->addError(langRpw::_("Wrong Format"));
         return $res->ajaxExec();
     }
     $mapsKeys = array();
     $mapModel = frameGmp::_()->getModule("gmap")->getModel();
     $groupModule = frameGmp::_()->getModule("marker_groups");
     $markerModule = FrameGmp::_()->getModule("marker");
     $group_params = array();
     $groupKeys = array();
     $markersArr = array();
     foreach ($backupInfo as $map) {
         $map_params = array("title" => $map["title"], "description" => $map["description"], "params" => utilsGmp::serialize($map["params"]), "html_options" => utilsGmp::serialize($map["html_options"]), "create_date" => $map["create_date"]);
         //outeGmp($map_params);
         $map_new_id = frameGmp::_()->getTable("maps")->store($map_params);
         $mapsKeys[$map['id']] = $map_new_id;
         foreach ($map['markers'] as $marker) {
             if (isset($marker['groupObj']) && !empty($marker['groupObj'])) {
                 $group_params[$marker['groupObj']['id']] = $marker['groupObj'];
             }
             $markersArr[] = $marker;
         }
     }
     foreach ($group_params as $oldId => $groupInfo) {
         $gParams = array("title" => $groupInfo['title'], "description" => $groupInfo['description'], "mode" => "insert");
         $groupKeys[$oldId] = $groupModule->getModel()->saveGroup($gParams);
     }
     foreach ($markersArr as $marker) {
         $mParams = array("title" => $marker['title'], "description" => $marker['description'], "coord_x" => $marker['coord_x'], "coord_y" => $marker['coord_y'], "map_id" => $mapsKeys[$marker['map_id']], "marker_group_id" => $groupKeys[$marker['marker_group_id']], "address" => $marker['address'], "animation" => (int) $marker['animation'], "create_date" => $marker['create_date'], "params" => $marker['params'], "titleLink" => utilsGmp::serialize($marker['titleLink']));
         if (is_array($marker['icon'])) {
             $mParams['icon'] = $marker['icon']['id'];
         } elseif (is_string($marker['icon'])) {
             $mParams['icon'] = $marker['icon'];
         }
         $markerModule->getModel()->saveMarker($mParams);
     }
     outGmp($mapsKeys);
     outeGmp($groupKeys);
 }
コード例 #2
0
ファイル: controller.php プロジェクト: Roman921/Step-21
 public function sendMailToDevelopers()
 {
     $res = new responseGmp();
     $data = reqGmp::get('post');
     $fields = array('name' => new fieldGmpGmp('name', langGmp::_('Your name field is required.'), '', '', 'Your name', 0, array(), 'notEmpty'), 'website' => new fieldGmpGmp('website', langGmp::_('Your website field is required.'), '', '', 'Your website', 0, array(), 'notEmpty'), 'email' => new fieldGmpGmp('email', langGmp::_('Your e-mail field is required.'), '', '', 'Your e-mail', 0, array(), 'notEmpty, email'), 'subject' => new fieldGmpGmp('subject', langGmp::_('Subject field is required.'), '', '', 'Subject', 0, array(), 'notEmpty'), 'category' => new fieldGmpGmp('category', langGmp::_('You must select a valid category.'), '', '', 'Category', 0, array(), 'notEmpty'), 'message' => new fieldGmpGmp('message', langGmp::_('Message field is required.'), '', '', 'Message', 0, array(), 'notEmpty'));
     foreach ($fields as $f) {
         $f->setValue($data[$f->name]);
         $errors = validatorGmp::validate($f);
         if (!empty($errors)) {
             $res->addError($errors);
         }
     }
     if (!$res->error) {
         $msg = 'Message from: ' . get_bloginfo('name') . ', Host: ' . $_SERVER['HTTP_HOST'] . '<br />';
         foreach ($fields as $f) {
             $msg .= '<b>' . $f->label . '</b>: ' . nl2br($f->value) . '<br />';
         }
         $headers[] = 'From: ' . $fields['name']->value . ' <' . $fields['email']->value . '>';
         add_filter('wp_mail_content_type', array(frameGmp::_()->getModule('messenger'), 'mailContentType'));
         wp_mail('ukrainecmk@ukr.net, simon@readyshoppingcart.com, support@readyecommerce.zendesk.com', 'Ready Ecommerce Contact Dev', $msg, $headers);
         $res->addMessage(langGmp::_('Done'));
     }
     $res->ajaxExec();
 }