コード例 #1
0
ファイル: feedback.php プロジェクト: greor/satin-spb
 public function action_save()
 {
     $this->auto_send_cache_headers = FALSE;
     $orm = ORM::factory('feedback')->where('page_id', '=', $this->page_id)->find();
     if (!$orm->loaded()) {
         throw new HTTP_Exception_404();
     }
     $form_orm = $orm->form;
     if (!$form_orm->loaded()) {
         throw new HTTP_Exception_404();
     }
     $helper_form = new Helper_Form();
     $form_fields = $helper_form->get_fields($form_orm);
     $post = $this->request->post();
     $errors = $this->check_form($post, $form_fields);
     if (empty($errors)) {
         $data = $this->parse_post($post);
         $text = __('Message created') . ': ' . date('Y-m-d H:i:s') . "\r\n";
         $text .= __('Form') . ': ' . $form_orm->title . "\r\n--------------------------\r\n";
         $email = '';
         foreach ($data as $_key => $_value) {
             $_field = $this->get_field($form_fields, $_key);
             if ($_field) {
                 if ($_field['type'] == 'textarea') {
                     $text .= $_field['title'] . "\r\n" . $_value . "\r\n";
                 } else {
                     $text .= $_field['title'] . ': ' . $_value . "\r\n";
                 }
             }
         }
         $values = array('site_id' => SITE_ID, 'form_id' => $form_orm->id, 'email' => $form_orm->email, 'text' => $text);
         try {
             $orm = ORM::factory('Form_Response')->values($values)->save();
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('');
             if (!empty($errors['_external'])) {
                 $errors = array_merge($errors, $errors['_external']);
                 unset($errors['_external']);
             }
         }
     }
     $this->json = array('errors' => $errors);
 }
コード例 #2
0
ファイル: admin.php プロジェクト: Aranjedeath/EnsofobiWebdd
<?php

$form = new Helper_Form();
$form->profileType = $fields["profile_type_id"];
$user_form = $form->renderForm($fields, "Save");
echo View::factory("layout/documentHeaderAdmin");
?>
<body>
<div class="height-wrapper">
    <?php 
echo View::factory("layout/headerNavigationAdmin");
?>
    <div id="main" role="main" class="container-fluid">
    <div class="contained">
        <!-- left aside -->
        <?php 
echo View::factory("layout/leftAsideAdmin")->bind("avatar", $fields["avatar"])->bind("first_name", $fields["first_name_1"]);
?>
        <!-- main content -->
        <div id="page-content">
            <h5>User Workspace</h5>
            <div id="workspace">
                <div class="workspaceNode" id="workspace-1" style="display:block;"><?php 
echo View::factory("components/fobiFeed")->bind("fields", $fields);
?>
</div>
                <div class="workspaceNode" id="workspace-2"><?php 
echo View::factory("forms/myprofileinfo")->bind("myProfile", $fields)->bind("user_form", $user_form);
?>
</div>
                <div class="workspaceNode" id="workspace-3"><?php 
コード例 #3
0
<?php

defined('SYSPATH') or die('No direct script access.');
$form = new Helper_Form();
$profileTypes = array("business" => 1, "organization" => 2, "art" => 3);
$fields = array();
$form->profileType = $profileTypes[$profileType];
$formLocal = $form->renderForm($fields, "Register Profile");
echo "<form class='mvcform' method='post'>";
echo $formLocal;
echo "<label>&nbsp;</label>" . Form::button('save', "Register", array('type' => 'submit')) . "</form>";
コード例 #4
0
ファイル: structure.php プロジェクト: greor/satin-spb
 public function action_edit()
 {
     $request = $this->request->current();
     $this->form_id = $id = (int) $this->request->current()->param('id');
     $helper_orm = ORM_Helper::factory('form');
     $orm = $helper_orm->orm();
     if ((bool) $id) {
         $orm->and_where('id', '=', $id)->find();
         if (!$orm->loaded() or !$this->acl->is_allowed($this->user, $orm, 'edit')) {
             throw new HTTP_Exception_404();
         }
         $this->title = __('Edit form');
     } else {
         if (!$this->acl->is_allowed($this->user, $orm, 'add')) {
             throw new HTTP_Exception_404();
         }
         $this->title = __('Add form');
     }
     if (empty($this->back_url)) {
         $query_array = array('owner' => $this->owner);
         $query_array = Paginator::query($request, $query_array);
         $this->back_url = Route::url('admin', array('controller' => $this->controller_name['structure'], 'query' => Helper_Page::make_query_string($query_array)));
     }
     if ($this->is_cancel) {
         $request->redirect($this->back_url);
     }
     $errors = array();
     $submit = Request::$current->post('submit');
     if ($submit) {
         try {
             if ($orm->loaded()) {
                 $orm->updater_id = $this->user->id;
                 $orm->updated = date('Y-m-d H:i:s');
             } else {
                 $orm->owner = $this->owner;
                 $orm->site_id = SITE_ID;
                 $orm->creator_id = $this->user->id;
             }
             $values = $this->request->current()->post();
             $values['public_date'] = $this->value_multiple_date($values, 'public_date');
             $values['close_date'] = $this->value_multiple_date($values, 'close_date');
             $helper_orm->save($values + $_FILES);
             $this->_save_rows($orm);
         } catch (ORM_Validation_Exception $e) {
             $errors = $this->errors_extract($e);
         }
     }
     // If add action then $submit = NULL
     if (!empty($errors) or $submit != 'save_and_exit') {
         if (!$orm->loaded()) {
             $orm->text_show_top = Kohana::$config->load('forms.default.text_show_top');
         }
         $helper_form = new Helper_Form();
         $fields = $helper_form->get_fields($orm);
         $this->template->set_filename('forms/structure/edit')->set('errors', $errors)->set('helper_orm', $helper_orm)->set('fields_types', Kohana::$config->load('_forms.type'))->set('fields_std', Kohana::$config->load('forms.fields_std'))->set('fields', $fields);
         if ($this->acl->is_allowed($this->user, $orm, 'add')) {
             $this->left_menu_form_add();
         }
         $this->sub_title = __('Forms (structure)');
         $this->breadcrumbs[] = array('title' => $this->title);
     } else {
         $request->redirect($this->back_url);
     }
 }