コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Variable();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Variable'])) {
         $model->attributes = $_POST['Variable'];
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
         //$this->redirect(array('view','id'=>$model->id));
     }
     $this->render('create', array('model' => $model));
 }
コード例 #2
0
 public function prepareData()
 {
     $site = new Site();
     $site->site_id = 1;
     $site->site_domain = 'site1';
     $site->save();
     $site = new Site();
     $site->site_id = 2;
     $site->site_domain = 'site2';
     $site->save();
     $var = new Variable();
     $var->variable_id = 1;
     $var->variable_name = 'var1';
     $var->save();
     $var = new Variable();
     $var->variable_id = 2;
     $var->variable_name = 'var2';
     $var->save();
     $varval = new SiteVarvalue();
     $varval->site_id = 1;
     $varval->variable_id = 1;
     $varval->varvalue_value = 'val1 dom1 var1';
     $varval->save();
     $varval = new SiteVarvalue();
     $varval->site_id = 1;
     $varval->variable_id = 2;
     $varval->varvalue_value = 'val2 dom1 var2';
     $varval->save();
     $varval = new SiteVarvalue();
     $varval->site_id = 2;
     $varval->variable_id = 1;
     $varval->varvalue_value = 'val3 dom2 var1';
     $varval->save();
     $varval = new SiteVarvalue();
     $varval->site_id = 2;
     $varval->variable_id = 2;
     $varval->varvalue_value = 'val4 dom2 var2';
     $varval->save();
 }
コード例 #3
0
 public function defineFields($id)
 {
     $bladetemp = $this->bladetemp->findOrFail($id);
     $file = $bladetemp->file;
     $fullpath = app_path() . '/views/uploads/' . $file;
     $string = file_get_contents($fullpath);
     $string = str_replace('{{', '|{{', $string);
     $strings = explode('|', $string);
     $pattern = "/{{(.*?)}}/";
     //print_r($strings);
     foreach ($strings as $string) {
         if (preg_match($pattern, $string, $matches)) {
             $variable = new Variable();
             $var_title = substr($matches[1], strpos($matches[1], '"') + 2);
             $variable->name = str_replace('"', '', $var_title);
             echo $variable->name;
             $variable->t_id = $id;
             $variable->save();
             //print_r($matches);
         }
     }
     return Redirect::route('variables.assigntypes', array('id' => $id));
 }