/**
  * This produces a form for editing the copy and headers in a page
  *
  * @return void
  * @author Dan Chadwick
  **/
 function edit_inline()
 {
     // $d = array(
     // 	'model' => steamcore::get_controls_model( 'pages' ),
     // 	'form_name' => 'pages_edit',
     // 	'form_data' => array(),
     // 	'update' => ($r->count())?$r->current()->id:0
     // 	);
     // $setup = steamcore::array_object( $d );
     //
     // /* Clear events */
     // Event::clear('steamform_'.$setup->form_name.'.complete');
     // Event::clear('steamform_'.$setup->form_name.'.show_form');
     //
     // Event::add('steamform_'.$setup->form_name.'.complete', array('admin_helpers', 'response_complete_listener') );
     // Event::add('steamform_'.$setup->form_name.'.show_form', array('admin_helpers', 'show_form_listener') );
     //
     try {
         $p = Kohana::instance()->uri->segment(2, 'home');
         $p = str_replace('.html', '', $p);
         $m = ORM::factory('page')->where('name', $p)->find();
         $form = Xform::factory()->name('xpage_contents_edit');
         // create the form
         $form->set_form_data('current', $m);
         $form->run();
         // run the form
         // handle form completion
         if (!$form->complete) {
             return $form->render();
         } else {
             $cols = array_keys($m->table_columns);
             foreach ($form->final_data as $k => $v) {
                 if (!in_array($k, $cols)) {
                     continue;
                 }
                 $m->{$k} = $v;
             }
         }
     } catch (Exception $e) {
         throw new Kohana_User_Exception('SteamCore Add Error', $e->getMessage());
     }
     // Assets::instance()->add_javascript('/cache/js/steamform');
     // Assets::instance()->add_javascript('/steamform/index/steamform');
     return $e;
 }
 public static function run_form($name, $model, $id = false, $action = null, $data = null)
 {
     $update = (is_numeric($id) and $id > 0);
     if (is_null($action)) {
         $action = $update ? 'edit' : 'add';
     }
     try {
         if ($update) {
             $model = ORM::factory($model, $id);
             if (!$model->loaded) {
                 throw new Exception("cannot_return_current_values");
             }
         } else {
             $model = ORM::factory($model);
         }
         $form = Xform::factory()->name('x' . $name . '_' . $action)->update($id)->set_form_data('current', $model);
         if (!empty($data) && is_array($data) && count($data)) {
             foreach ($data as $key => $value) {
                 $form->set_form_data($key, $value);
             }
         }
         $form = $form->run();
         if (!$form->complete) {
             // run the show_form event
             Event::run('xform_x' . $name . '_' . $action . '.show_form', $form->render());
         } else {
             // $has = $model->has_many;
             $cols = array_keys($model->table_columns);
             foreach ($form->final_data as $k => $v) {
                 if (!in_array($k, $cols)) {
                     continue;
                 }
                 $model->{$k} = $v;
             }
             $model->save();
             Event::run('steamcore.crud_upload', $model);
             Event::run('steamcore.' . $action . '_complete', $model);
         }
     } catch (Xform_Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #3
0
        if ($customField == false) {
            if (!empty($options)) {
                $form->{$fieldType}($name, $label)->options($options)->setAttributes($attributes);
            } else {
                $form->{$fieldType}($name, $label)->setAttributes($attributes);
            }
        }
    });
});
Xform::macro('custom_fields', function ($fields) {
    return Xform::template('div', function ($form) use($fields) {
        foreach ($fields as $name => $attr) {
            $form->custom_field($name, $attr, false);
        }
    });
});
Xform::macro('ng_custom_fields', function ($fields, $angularRootItem = 'item') {
    return Xform::template('div', function ($form) use($fields, $angularRootItem) {
        foreach ($fields as $name => $attr) {
            if (is_array($attr)) {
                if (!isset($attr['attr'])) {
                    $attr['attr'] = array();
                }
                if (!isset($attr['attr']['ng-model'])) {
                    $attr['attr']['ng-model'] = $angularRootItem . '.' . $name;
                }
            }
            $form->custom_field($name, $attr);
        }
    });
});
예제 #4
0
<?php 
// Open Form
Xform::form('route', 'domaine.create');
// Hidden
Xform::startRow('hidden');
Xform::addText('_token', 'x', Session::getToken(), 2);
Xform::addText('id', 'ID', $datas->id, 2);
Xform::addText('backUrl', '', $param['backUrl']);
Xform::addText('user_id', 'USER_ID', Auth::user()->id, 1);
Xform::endRow();
// Get Fields
Xform::startRow();
Xform::addText('nom', 'Nom du domaine', $datas->nom, 5);
Xform::endRow();
Xform::startRow();
Xform::addText('url', 'Url', $datas->url, 5);
Xform::endRow();
Xform::startRow();
Xform::addSelect('typedomaine_id', Typedomaine::lists('libelle', 'id'), 'Type', $datas->typedomaine_id, 2);
Xform::endRow();
// Buttons
Xform::addSubmit();
Xform::addCancel($param['backUrl']);
// Message bottom
//Xform::addMessage('Ceci est un message');
?>

    <!-- Close Form -->
    {{ Xform::show($errors,'left') }}

{{ closeContent() }}
예제 #5
0
파일: edit.php 프로젝트: rodrane/ravel
echo Xform::make('div', function ($form) {
    $form->box_panel(trans('ravel::content.update_page'), function ($form) {
        $form->div(function ($div) {
            $div->text('title', trans('ravel::content.title'))->ng_model('item.title', 'ng-model')->class('large-input');
            $div->textarea('excerpt', trans('ravel::content.excerpt'))->ng_model('item.excerpt', 'ng-model')->class('excerpt-textarea');
            $div->textarea('content', trans('ravel::content.content'))->ng_model('item.content', 'ng-model')->class('content-textarea')->ckeditor('', 'ck-editor');
            $customfields = Config::get('ravel::content.custom_fields.page');
            $div->ng_custom_fields($customfields);
            $div->setClass('column span8');
        });
        $form->div(function ($div) {
            $div->div(function ($div) {
                $div->ng_datepicker('publish_date', trans('ravel::content.publish_date'), 'item.publish_date');
                $options = array('draft' => 'Draft', 'Submitted' => 'Submitted');
                if (is_moderator()) {
                    $options['published'] = 'published';
                }
                //status of the page
                $div->select('status', trans('ravel::content.status'))->options($options)->ng_model('item.status', 'ng-model');
                //author name can be set to display any name
                $div->text('author', trans('ravel::content.show_author_as'))->ng_model('item.author_name', 'ng-model');
                //allow comments submission to this page
                $div->fieldset(function ($div) {
                    $div->legend(trans('ravel::content.comment_settings'));
                    $div->checkbox('allow_comments')->ng_model('item.allow_comments', 'ng-model')->ng_checked('item.allow_comments', 'ng-checked');
                    $div->span(trans('ravel::content.allow_comments'));
                    $div->div(function ($div) {
                        $div->number('comment_end', trans('ravel::content.comment_submission_end'))->ng_model('item.comment_end', 'ng-model')->class('text-input very-small-input')->min(1);
                        $div->span(trans('ravel::content.comment_days'));
                        $div->setRootAttr('ng-show', 'item.allow_comments');
                    });
                });
                $div->fieldset(function ($div) {
                    $div->legend(trans('ravel::content.security'));
                    $div->checkbox('locked_content')->ng_model('item.content_locked', 'ng-model')->ng_checked('item.content_locked', 'ng-checked');
                    $div->span(trans('ravel::content.enable'));
                    $div->div(function ($div) {
                        $div->password('content_password', trans('ravel::content.content_locked'))->ng_model('item.content_password');
                        $div->setRootAttr('ng-show', 'item.content_locked');
                    });
                });
                $div->br();
                $div->hr();
                $div->div(function ($div) {
                    $div->span(trans('ravel::content.content_language'));
                    $div->span(langflag(current_lang()));
                });
                $div->br();
                $div->br();
                $div->button(trans('ravel::content.save'))->class('button')->ng_click('submit()', 'ng-click');
                $div->button(trans('ravel::content.cancel'))->class('button')->ng_click('cancel()', 'ng-click');
                $div->button(trans('ravel::form.delete'))->class('button')->ng_click('delete()', 'ng-click');
                $div->setClass('column-panel');
            });
            $div->setClass('column span4');
        });
        $form->div()->class('clear');
    });
});
예제 #6
0
 /**
  * send url to reset credential
  *
  * @param object $setup 
  * @return void
  * @author Andy Bennett
  */
 public function forgotten_identity()
 {
     try {
         $form = Xform::factory()->name('xauth_forgotten_identity')->run();
         if ($form->complete) {
             // run the show_form event
             Event::run('steamauth.forgotten_identity_complete', $form);
         } else {
             // run the show_form event
             Event::run('steamauth.forgotten_identity_form', $form->render());
         }
     } catch (Exception $e) {
         Kohana::log('error', __FILE__ . ':' . __METHOD__ . ':' . $e->getMessage());
     }
 }
예제 #7
0
 /**
  * comment
  *
  * @return void
  * @author Andy Bennett
  */
 public function comment($post = null)
 {
     if (is_null($post)) {
         $ra = Router::$arguments;
         $post = $ra[1];
     }
     $root = ORM::factory('blogpost', $post);
     $update = (is_numeric($post) and $post > 0);
     $model = 'blogpost';
     $name = '';
     try {
         $model = ORM::factory($model);
         $form = Xform::factory()->name('xblog_comment')->update(false)->set_form_data('post_id', $post)->run();
         if (!$form->complete) {
             // run the show_form event
             return $form->render();
         } else {
             // Submit the form
             if (property_exists($form->final_data, 'status')) {
                 $model->status = $form->final_data->status;
             }
             $model->name = $form->final_data->name;
             $model->website = $form->final_data->website;
             $model->email = $form->final_data->email;
             $model->copy = $form->final_data->copy;
             $model->date_added = date("Y-m-d H:i:s");
             $model->blog_id = $root->blog_id;
             $model->user_id = User::instance()->id;
             $post_parent = $post;
             // We may want this to be a reply of a reply
             $post_id = Input::instance()->post('form_post_id', false);
             if (is_numeric($post_id) and $post_id > 0) {
                 $post_parent = $post_id;
             }
             // Update the last activity time for the root node
             $root->date_last_activity = date("Y-m-d H:i:s");
             $root->save();
             $model->insert_as_last_child($post_parent);
             $u = URI::instance()->string();
             url::redirect($u);
         }
     } catch (Xform_Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #8
0
파일: edit.php 프로젝트: rodrane/ravel
echo Xform::make(function ($form) use($ravel_list_layouts, $ravel_item_layouts) {
    $form->share('ravel_list_layouts', $ravel_item_layouts);
    $form->share('ravel_list_layouts', $ravel_list_layouts);
    $form->box_panel(trans('ravel::content.new_category'), function ($form) {
        $form->div(function ($form) {
            $form->div(function ($form) {
                $form->div(function ($form) {
                    $form->div(function ($form) {
                        $form->input_text('name', trans('ravel::content.category_name'), null, array('required' => true, 'ng-model' => 'item.name'));
                        $ravel_item_layouts = $form->get('ravel_item_layouts');
                        $ravel_list_layouts = $form->get('ravel_list_layouts');
                        $form->select('list_layout', trans('ravel::content.list_layout'))->options($ravel_list_layouts, null)->ng_model('item.list_layout', 'ng-model');
                        $form->select('item_layout', trans('ravel::content.item_layout'))->options($ravel_item_layouts, null)->ng_model('item.item_layout', 'ng-model');
                        $form->setClass('span6');
                    });
                    $form->setClass('span12');
                });
                $form->setClass('row-fluid');
            });
            $form->setClass('column span8');
        });
        $form->div(function ($div) {
            $div->div(function ($div) {
                $div->button(trans('ravel::form.save'))->class('button')->ng_click('submit()', 'ng-click');
                $div->button(trans('ravel::form.cancel'))->class('button')->ng_click('cancel()', 'ng-click');
                $div->button(trans('ravel::form.delete'))->class('button')->ng_click('delete()', 'ng-click');
                $div->setClass('column-panel');
            });
            $div->setClass('column span4');
        });
        $form->div()->class('clear');
    });
    $form->setRootAttr('ng-submit', 'save()');
});
예제 #9
0
    <?php 
// Open Form
Xform::form('route', 'test.create');
// Hidden
Xform::startRow('hidden');
Xform::addText('_token', 'x', Session::getToken(), 2);
Xform::addText('id', 'ID', $datas->id, 2);
Xform::addText('backUrl', '', $param['backUrl']);
Xform::endRow();
// Get Fields
Xform::startRow();
Xform::addText('nom', 'Nom', $datas->nom, 8);
Xform::endRow();
Xform::startRow();
Xform::addDate('birthday', 'Date de naissance', $datas->birthday, 6);
Xform::addText('valeur', 'Valeur', $datas->valeur, 3);
Xform::addCheckBox('actif', 'Présent', $datas->actif, 2);
Xform::endRow();
// Buttons
Xform::addSubmit();
Xform::addCancel($param['backUrl']);
Xform::addButton('home', 'ceci est un bouton a moi !', 'home', 'blue');
// Message bottom
//Xform::addMessage('Ceci est un message');
?>

        <!-- Close Form -->
        {{ Xform::show($errors,'left') }}

{{ closeContent() }}
예제 #10
0
Xform::addText('backUrl', '', $param['backUrl']);
Xform::addText('compet_id', 'COMPET_ID', $param['compet_id'], 1);
Xform::endRow();
?>

    @foreach($tours as $tour)

        <?php 
$t = $tour->num;
// Hidden
Xform::startRow('hidden');
Xform::addText('id[' . $t . ']', 'ID', $tour->id, 2);
Xform::endRow();
// Get Fields
Xform::startRow();
Xform::addDate('datetour[' . $t . ']', 'Date', $tour->datetour, 2);
Xform::addSelect('formulecompet_id[' . $t . ']', $tour->compet->typecompet->listFormules(), 'Formule de jeu', $tour->formulecompet_id, 3);
Xform::endRow();
?>

    @endforeach

    <?php 
// Buttons
Xform::addSubmit();
?>

    <!-- Close Form -->
    {{ Xform::show($errors,'left') }}

{{ closeContent() }}
예제 #11
0
파일: create.php 프로젝트: rodrane/ravel
echo Xform::make(function ($form) use($usergroups, $errors) {
    // $usrgroups = array();
    // foreach($usergroups as $group)
    // {
    // 	$id = $group->id;
    // 	$usrgroups[$id] = $group->group;
    // }
    //$form->share('user',$user);
    $form->share('usergroups', $usergroups);
    $form->share_errors($errors);
    $form->box_panel(trans('ravel::user.new_user_form_legend'), function ($form) {
        $form->div(function ($form) {
            $form->div(function ($form) {
                $form->div(function ($form) {
                    $form->div(function ($form) {
                        //columnA
                        $user = $form->get('user');
                        $form->input_text('username', trans('ravel::user.username'), is_null($user) ? Input::old("username") : $user->username, array('required' => true, 'ng-model' => 'item.username'));
                        $form->input_text('email', trans('ravel::user.email'), is_null($user) ? Input::old("email") : $user->email, array('required' => true, 'ng-model' => 'item.email'));
                        $usergroups = $form->get('usergroups');
                        $selectedUsergroup = is_null($user) ? Input::old("usergroup_id") : $user->usergroup_id;
                        //is_null(Input::get("usergroup_id")) ? Input::old("usergroup_id") : Input::get("usergroup_id");
                        $form->select('usergroup_id', trans('ravel::user.usergroup'))->options($usergroups, $selectedUsergroup)->ng_model('item.usergroup_id', 'ng-model')->ui_select2(null, 'ui-select2');
                        $form->setClass('span6');
                    });
                    $form->div(function ($form) {
                        //columnB
                        $form->input_password('password', trans('ravel::user.password'), array('ng-model' => 'item.password'));
                        $form->input_password('password_confirmation', trans('ravel::user.confirmpassword'), array('ng-model' => 'item.password_confirmation'));
                        $form->setClass('span6');
                    });
                    $form->setClass('span12');
                });
                $form->setClass('row-fluid');
            });
            $form->setClass('column span8');
        });
        $form->div(function ($div) {
            $div->div(function ($div) {
                $div->button(trans('ravel::form.save'))->class('button')->ng_click('submit()', 'ng-click');
                $div->button(trans('ravel::form.cancel'))->class('button')->ng_click('cancel()', 'ng-click');
                $div->setClass('column-panel');
            });
            $div->setClass('column span4');
        });
        $form->div()->class('clear');
    });
    $form->setRootAttr('ng-submit', 'save()');
});