コード例 #1
0
ファイル: slide.php プロジェクト: resolverRaun/hosp123
 function create()
 {
     if (isset($_POST['save'])) {
         $title = trim($this->input->post('title'));
         $alias = trim($this->input->post('alias'));
         if ($alias) {
             $alias = preg_replace('/\\s+/', '-', strtolower($alias));
             $alias = preg_replace('/&/', '-', $alias);
             $alias = preg_replace('#/+#', '-', $alias);
             $alias = preg_replace('/---/', '-', $alias);
             $alias = preg_replace('/(\'|\\(|\\))/', '', $alias);
         } else {
             $alias = preg_replace('/\\s+/', '-', strtolower($title));
             $alias = preg_replace('/&/', '-', $alias);
             $alias = preg_replace('#/+#', '-', $alias);
             $alias = preg_replace('/---/', '-', $alias);
             $alias = preg_replace('/(\'|\\(|\\))/', '', $alias);
         }
         $data = array('title' => $title, 'alias' => strtolower($alias), 'state' => $this->input->post('state'), 'order' => trim($this->input->post('order')), 'width' => trim($this->input->post('width')), 'height' => trim($this->input->post('height')), 'alt_text' => trim($this->input->post('alt_text')), 'link' => trim($this->input->post('link')), 'image' => trim($this->input->post('image')), 'scat_id' => trim($this->input->post('scat_id')), 'created_date' => date('y:m:d h:m:s'), 'intro_desc' => trim($this->input->post('intro_desc')));
         $dataIn = $this->crud_model->insertData('slide', $data);
         if ($dataIn) {
             $this->admintemp->write('message', $title . ' Saved Successfully');
             redirect('slide');
         } else {
             $this->admintemp->write('error', 'An error occured while inserting the section.');
             Slide::index();
         }
     } else {
         Slide::_create();
     }
 }