Exemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Style();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Style'])) {
         $model->attributes = $_POST['Style'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 2
0
 public function run()
 {
     $row = 0;
     if (($handle = fopen(storage_path() . "/csvs/styles.csv", "r")) !== FALSE) {
         while (($data = fgetcsv($handle)) !== FALSE) {
             $row++;
             if ($row > 1) {
                 try {
                     $style = new Style();
                     $style->style_name = $data[2];
                     // $beer->beer_id = $data[0];
                     $style->save();
                 } catch (Exception $e) {
                 }
             }
         }
         fclose($handle);
     }
 }
Exemplo n.º 3
0
 /**
  * Submit style form
  */
 public function saveStyle()
 {
     if (Input::get('style_id') != null) {
         //edit style
         $style = Style::find(Input::get('style_id'));
     } else {
         //create style
         $style = new Style();
     }
     if (Input::get('parent_style') != null) {
         $parent_style = Style::where('name', Input::get('parent_style'))->first();
         if ($parent_style) {
             $parent_style_id = $parent_style->id;
         }
     } else {
         $parent_style_id = null;
     }
     $style->name = Input::get('name');
     $style->description = Input::get('description');
     $style->style_id = $parent_style_id;
     $style->wikipedia_url = Input::get('wikipedia');
     $style->save();
     return Redirect::back()->withMessage('Style created correctly');
 }
Exemplo n.º 4
0
 function changeStyle()
 {
     $current_user = new User();
     $current_user->createFromID($this->getCurrentUserID());
     $deckid = $_POST['deck'];
     $deck = new Deck();
     $deck->id = $deckid;
     $deck->title = $deck->getTitle();
     $deck->slug_title = $deck->sluggify($deck->title);
     $styleid = isset($_POST['id']) ? $_POST['id'] : 1;
     if (isset($_POST['submit'])) {
         $response = 1;
         $s = $_POST['style'];
         if (isset($_POST['new'])) {
             $s['based_on'] = $s['id'];
             unset($s['id']);
             $new_style = new Style();
             $new_style->name = $s['name'];
             if (!$s['name']) {
                 header('Location: ' . BASE_PATH . 'error/400');
             }
             $new_style->user_id = $current_user->id;
             $new_style->based_on = $s['based_on'];
             $new_style->css = $s['css'];
             $new_style->scss_varfunc = $s['scss_varfunc'];
             $new_style->scss = $s['scss'];
             $new_style->comment = $s['comment'];
             $new_style->create();
             $styleid = $new_style->id;
         } else {
             $current_style = new Style();
             $current_style->createFromID($s['id']);
             $current_style->name = $s['name'];
             //$current_style->user_id = $current_user->id;
             //$current_style->based_on = $s ['based_on'];
             $current_style->css = $s['css'];
             $current_style->scss_varfunc = $s['scss_varfunc'];
             $current_style->scss = $s['scss'];
             $current_style->comment = $s['comment'];
             $current_style->save();
             $styleid = $s['id'];
         }
     }
     header('Location: style/' . $styleid . '/deck/' . $deckid . '_' . $deck->slug_title);
 }