예제 #1
0
 public function change()
 {
     if (!isAdmin()) {
         $this->kickOut();
     }
     if ($_POST) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('Organization', 'Organization', 'trim|required|xss_clean');
         $this->form_validation->set_rules('SourceDescription', 'Source Description', 'trim|required|xss_clean');
         $this->form_validation->set_rules('ContactName', 'Contact Name', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Phone', 'Phone Number', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Email', 'Email Address', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Address', 'Address', 'trim|required|xss_clean');
         $this->form_validation->set_rules('City', 'City', 'trim|required|xss_clean');
         $this->form_validation->set_rules('State', 'State', 'trim|required|xss_clean');
         $this->form_validation->set_rules('ZipCode', 'Zip Code', 'trim|required|xss_clean');
         $this->form_validation->set_rules('TopicCategory', 'Topic Category', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Title', 'Title', 'trim|required|xss_clean');
         $this->form_validation->set_rules('Abstract', 'Abstract', 'trim|required|xss_clean');
     }
     if ($this->form_validation->run() == FALSE) {
         $errors = validation_errors();
         if (!empty($errors)) {
             addError($errors);
         }
     } else {
         //Array for generating MetadatID
         $dataPoint = array('TopicCategory' => $this->input->post('TopicCategory'), 'Title' => $this->input->post('Title'), 'Abstract' => $this->input->post('Abstract'), 'ProfileVersion' => $this->cNull($this->config->item('ProfileVersion')), 'MetadataLink' => $this->input->post('MetadataLink'));
         $metaID = $this->sources->updateMD($dataPoint, $this->input->post('MetadataID'));
         $result = $this->sources->updateSource($this->input->post('Organization'), $this->input->post('SourceDescription'), $this->input->post('SourceLink'), $this->input->post('ContactName'), $this->input->post('Phone'), $this->input->post('Email'), $this->input->post('Address'), $this->input->post('City'), $this->input->post('State'), $this->input->post('ZipCode'), $this->input->post('Citation'), $this->input->post('MetadataID'), $this->input->post('SourceID'));
         if ($result) {
             addSuccess(getTxt('SourceEdited'));
         } else {
             addError(getTxt('ProcessingError'));
         }
     }
     $sources = $this->sources->getAll();
     $sourceOptions = optionsSource($sources);
     //List of CSS to pass to this view
     $data = $this->StyleData;
     $data['sourceOptions'] = $sourceOptions;
     //Getting the states dropdown
     $states = getStates();
     $states['NULL'] = getTxt('International');
     $stateOptions = genOptions($states);
     $data['stateOptions'] = $stateOptions;
     //Gets the topicCategory dropdown
     //getTC was created in the model
     $topics = $this->sources->getTC();
     $topicsArray = array();
     foreach ($topics as $topic) {
         $topicsArray[$topic['Term']] = translateTerm($topic['Term']);
     }
     $topicOptions = genOptions($topicsArray);
     $data['topicOptions'] = $topicOptions;
     $this->load->view('sources/changesource', $data);
 }
예제 #2
0
파일: sites.php 프로젝트: CMIP5/HUC8Climate
 public function change()
 {
     if ($_POST) {
         //Try uploading the site image. If no new image is set, it should be an error.
         $name = 'siteimg' . time();
         //Processing the SiteImage.
         $config['upload_path'] = './uploads/';
         $config['allowed_types'] = 'gif|jpg|png|jpeg';
         $config['max_size'] = '1024';
         $config['max_width'] = '0';
         $config['max_height'] = '0';
         $config['file_name'] = $name;
         $this->load->library('upload', $config);
         $name = "";
         if ($this->upload->do_upload('picture')) {
             $uploaddata = $this->upload->data();
             $name = $uploaddata['file_name'];
         }
         //Create the site.
         $site = $this->createSite();
         $siteID = $this->input->post('SiteID');
         if ($name != "") {
             //Add image to sitepic table.
             $this->site->addPic($name, $siteID);
         }
         $result = $this->site->update($site, $siteID);
         if (!$result) {
             addError(getTxt('ProcessingError') . " Error while adding sites. ");
         } else {
             //Update Series.
             $series = array('SiteCode' => $this->input->post('SiteCode'), 'SiteName' => $this->input->post('SiteName'), 'SiteType' => $this->input->post('SiteType'));
             $this->load->model('sc', '', TRUE);
             //Add to the series catalog
             $result = $this->sc->updateSite($series, $siteID);
             if ($result) {
                 addSuccess(getTxt('SiteSuccessfullyEdited'));
             } else {
                 addError(getTxt('ProcessingError') . " Error while updating Series. ");
             }
         }
     }
     $sources = $this->sources->getAll();
     $sourceOptions = optionsSource($sources);
     $types = $this->site->getSiteTypes();
     $typesArray = array();
     foreach ($types as $type) {
         $typesArray[$type['Term']] = translateTerm($type['Term']);
     }
     $typeOptions = genOptions($typesArray);
     $vds = $this->site->getVD();
     $verticalDatumArray = array();
     foreach ($vds as $vd) {
         $verticalDatumArray[$vd['Term']] = translateTerm($vd['Term']);
     }
     $vdOptions = genOptions($verticalDatumArray);
     $srs = $this->site->getSR();
     $srArray = array();
     foreach ($srs as $sr) {
         $srArray[$sr['SpatialReferenceID']] = translateTerm($sr['SRSName']);
     }
     $srOptions = genOptions($srArray);
     //List of CSS to pass to this view
     $data = $this->StyleData;
     $data['sourceOptions'] = $sourceOptions;
     $data['typeOptions'] = $typeOptions;
     $data['vdOptions'] = $vdOptions;
     $data['srOptions'] = $srOptions;
     //Getting the states dropdown
     $states = getStates();
     $states['NULL'] = getTxt('International');
     $stateOptions = genOptions($states);
     $data['stateOptions'] = $stateOptions;
     $this->load->view('sites/editsite', $data);
 }
예제 #3
-1
 public function importfile()
 {
     if ($_POST) {
         $result = $this->fileUploadHandler();
         if ($result) {
             $dataset = $this->processFiles($result);
             if ($dataset) {
                 $rows = count($dataset);
                 $result = $this->datapoints->addPoints($dataset);
                 if ($result) {
                     addSuccess(getTxt('Success'));
                     $this->updateSC();
                 } else {
                     addError(getTxt('ProcessingError') . "Error in data input");
                 }
             }
         }
     }
     //GetSources
     $sources = $this->sources->getAll();
     $sourceOptions = optionsSource($sources);
     //Get Variables
     $variables = $this->variables->getAll();
     $varOptions = optionsVariable($variables);
     //List of CSS to pass to this view
     $data = $this->StyleData;
     $data['sourcesOptions'] = $sourceOptions;
     $data['variableOptions'] = $varOptions;
     $this->load->view('datapoint/importfile', $data);
 }