コード例 #1
0
 public function upload()
 {
     $this->load->library('form_builder');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_groups_model');
     $this->load->module_model(FUEL_FOLDER, 'fuel_navigation_model');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST)) {
         $params = $this->input->post();
         if (!empty($_FILES['file']['name'])) {
             $error = FALSE;
             $file_info = $_FILES['file'];
             $params['file_path'] = $file_info['tmp_name'];
             $params['var'] = $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav';
             $params['language'] = $this->input->post('language', TRUE);
             if (!$this->fuel->navigation->upload($params)) {
                 $error = TRUE;
             }
             if ($error) {
                 add_error(lang('error_upload'));
             } else {
                 // change list view page state to show the selected group id
                 $this->fuel->admin->set_notification(lang('navigation_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_url('navigation?group_id=' . $params['group_id']));
             }
         } else {
             add_error(lang('error_upload'));
         }
     }
     $fields = array();
     $nav_groups = $this->fuel_navigation_groups_model->options_list('id', 'name', array('published' => 'yes'), 'id asc');
     if (empty($nav_groups)) {
         $nav_groups = array('1' => 'main');
     }
     // load custom fields
     $this->form_builder->load_custom_fields(APPPATH . 'config/custom_fields.php');
     $fields['group_id'] = array('type' => 'select', 'options' => $nav_groups, 'module' => 'navigation_group');
     $fields['file'] = array('type' => 'file', 'accept' => '');
     $fields['variable'] = array('label' => 'Variable', 'value' => $this->input->post('variable') ? $this->input->post('variable', TRUE) : 'nav', 'size' => 10);
     $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'first_option' => lang('label_select_one'));
     $fields['clear_first'] = array('type' => 'enum', 'options' => array('yes' => 'yes', 'no' => 'no'));
     $fields['__fuel_module__'] = array('type' => 'hidden');
     $fields['__fuel_module__']['value'] = $this->module;
     $fields['__fuel_module__']['class'] = '__fuel_module__';
     $fields['__fuel_module_uri__'] = array('type' => 'hidden');
     $fields['__fuel_module_uri__']['value'] = $this->module_uri;
     $fields['__fuel_module_uri__']['class'] = '__fuel_module_uri__';
     $this->form_builder->set_fields($fields);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $this->form_builder->set_field_values($_POST);
     $vars['instructions'] = lang('navigation_import_instructions');
     $vars['form'] = $this->form_builder->render();
     $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri);
     $crumbs = array($this->module_uri => $this->module_name, lang('action_upload'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('upload', $vars, Fuel_admin::DISPLAY_NO_ACTION);
 }
コード例 #2
0
ファイル: Fuel_hooks.php プロジェクト: randombrad/FUEL-CMS
 function dev_password()
 {
     $CI =& get_instance();
     if ($CI->config->item('dev_password', 'fuel') and !$CI->fuel_auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
         $CI->load->library('session');
         if (!$CI->session->userdata('dev_password')) {
             redirect('fuel/login/dev');
         }
     }
 }
コード例 #3
0
ファイル: Fuel_hooks.php プロジェクト: huayuxian/FUEL-CMS
 public function offline()
 {
     if (!USE_FUEL_ROUTES) {
         $CI =& get_instance();
         if ($CI->fuel->config('offline') and !$CI->fuel->auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
             echo $CI->fuel->pages->render('offline', array(), array(), TRUE);
             exit;
         }
     }
 }
コード例 #4
0
ファイル: logout.php プロジェクト: kieranklaassen/FUEL-CMS
 function index()
 {
     $this->load->library('session');
     $this->session->sess_destroy();
     $this->load->module_library(FUEL_FOLDER, 'fuel_auth');
     $this->load->helper('cookie');
     $this->fuel_auth->logout();
     $config = array('name' => $this->fuel_auth->get_fuel_trigger_cookie_name(), 'path' => WEB_PATH);
     delete_cookie($config);
     redirect(fuel_uri('login'));
 }
コード例 #5
0
ファイル: my_profile.php プロジェクト: randombrad/FUEL-CMS
 function edit()
 {
     $user = $this->fuel_auth->user_data();
     $id = $user['id'];
     if (!empty($_POST)) {
         if ($id) {
             if ($this->users_model->save()) {
                 $this->session->set_flashdata('success', lang('data_saved'));
                 redirect(fuel_uri('my_profile/edit/'));
             }
         }
     }
     $this->_form($id);
 }
コード例 #6
0
ファイル: my_profile.php プロジェクト: magicjoey/FUEL-CMS
 public function edit()
 {
     $user = $this->fuel->auth->user_data();
     $id = $user['id'];
     if (!empty($_POST)) {
         if ($id) {
             if ($this->fuel_users_model->save()) {
                 $this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_uri('my_profile/edit/'));
             }
         }
     }
     $this->_form($id);
 }
コード例 #7
0
 function edit()
 {
     $user = $this->fuel_auth->user_data();
     $id = $user['id'];
     if (!empty($_POST)) {
         if (!empty($_POST['new_password']) && isset($_POST['confirm_password'])) {
             $this->users_model->get_validation()->add_rule('password', 'is_equal_to', 'Your password confirmation needs to match', array($_POST['new_password'], $_POST['confirm_password']));
         }
         $this->users_model->add_validation('email', array(&$this->users_model, 'is_editable_email'), 'The email is empty or already exists', $id);
         if ($id) {
             if ($this->users_model->save()) {
                 $this->session->set_flashdata('success', $this->lang->line('data_saved'));
                 redirect(fuel_uri('my_profile/edit/'));
             }
         }
     }
     $this->_form($id);
 }
コード例 #8
0
ファイル: my_profile.php プロジェクト: scotton34/sample
 public function edit()
 {
     $user = $this->fuel->auth->user_data();
     $id = $user['id'];
     if (!empty($_POST)) {
         if ($id) {
             // make sure they are only
             if ($id != $this->fuel->auth->user_data('id')) {
                 show_error(lang('error_no_permissions'));
             }
             $save = $this->input->post(NULL, TRUE);
             $save['id'] = $id;
             if ($this->fuel_users_model->save($save)) {
                 $this->fuel->admin->set_notification(lang('data_saved'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_uri('my_profile/edit/'));
             }
         }
     }
     $this->_form($id);
 }
コード例 #9
0
ファイル: pages.php プロジェクト: kieranklaassen/FUEL-CMS
 function edit($id = NULL)
 {
     if (empty($id)) {
         show_404();
     }
     $posted = $this->_process();
     if ($this->input->post('id')) {
         if (!$this->fuel_auth->has_permission($this->permission, 'publish')) {
             unset($_POST['published']);
         }
         if ($this->model->save($posted)) {
             $this->_process_uploads();
             $this->_save_page_vars($id, $posted);
             $data = $this->model->find_one_array(array($this->model->table_name() . '.id' => $id));
             $msg = lang('module_edited', $this->module_name, $data[$this->display_field]);
             $this->logs_model->logit($msg);
             redirect(fuel_uri('pages/edit/' . $id));
         }
     }
     $this->_form($id);
 }
コード例 #10
0
ファイル: assets.php プロジェクト: nonconforme/FUEL-CMS
 public function edit($dir = NULL, $field = NULL, $redirect = TRUE)
 {
     redirect(fuel_uri('assets/create/' . $dir));
 }
コード例 #11
0
ファイル: pages.php プロジェクト: prgoncalves/Beatcrumb-web
 public function upload()
 {
     $this->load->helper('file');
     $this->load->helper('security');
     $this->load->library('form_builder');
     $this->load->library('upload');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST) and !empty($_FILES)) {
         $params['upload_path'] = sys_get_temp_dir();
         $params['allowed_types'] = 'php|html|txt';
         // to ensure we check the proper mime types
         $this->upload->initialize($params);
         // Hackery to ensure that a proper php mimetype is set.
         // Would set in mimes.php config but that may be updated with the next version of CI which does not include the text/plain
         $this->upload->mimes['php'] = array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/html', 'text/x-php', 'application/x-httpd-php-source', 'text/plain');
         if ($this->upload->do_upload('file')) {
             $upload_data = $this->upload->data();
             $error = FALSE;
             // read in the file so we can filter it
             $file = read_file($upload_data['full_path']);
             // sanitize the file before saving
             $id = $this->input->post('id', TRUE);
             $pagevars = $this->fuel->pages->import($id);
             if (!empty($pagevars)) {
                 $layout = $this->fuel->layouts->get($pagevars['layout']);
                 unset($pagevars['layout']);
                 foreach ($pagevars as $key => $val) {
                     $where['page_id'] = $id;
                     $where['name'] = $key;
                     $page_var = $this->fuel_pagevariables_model->find_one_array($where);
                     $save['id'] = empty($page_var['id']) ? NULL : $page_var['id'];
                     $save['name'] = $key;
                     $save['page_id'] = $id;
                     $save['value'] = $val;
                     if (!$this->fuel_pagevariables_model->save($save)) {
                         add_error(lang('error_upload'));
                     }
                 }
                 // resave to prevent import popup on next page
                 $page = $this->fuel_pages_model->find_by_key($id, 'array');
                 $page['last_modified'] = date('Y-m-d H:i:s', time() + 1);
                 // to prevent window from popping up after upload
                 $this->model->save($page);
                 if (!has_errors()) {
                     // change list view page state to show the selected group id
                     $this->fuel->admin->set_notification(lang('pages_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS);
                     redirect(fuel_url('pages/edit/' . $id));
                 }
             } else {
                 add_error(lang('error_upload'));
             }
         } else {
             $error_msg = $this->upload->display_errors('', '');
             add_error($error_msg);
         }
     }
     $fields = array();
     $pages = $this->model->options_list('id', 'location', array('published' => 'yes'), 'location');
     $fields['id'] = array('label' => lang('form_label_name'), 'type' => 'select', 'options' => $pages, 'class' => 'add_edit pages');
     $fields['file'] = array('type' => 'file', 'accept' => '');
     $this->form_builder->hidden = array();
     $this->form_builder->set_fields($fields);
     $this->form_builder->set_field_values($_POST);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $vars['instructions'] = lang('pages_upload_instructions');
     $vars['form'] = $this->form_builder->render();
     $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri);
     //$vars['back_action'] = fuel_uri($this->module_uri);
     $crumbs = array($this->module_uri => $this->module_name, '' => lang('action_upload'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('upload', $vars, '', FUEL_FOLDER);
 }
コード例 #12
0
/**
 * Creates the admin URL for FUEL (e.g. http://localhost/MY_PROJECT/fuel/admin)
 *
 * @access	public
 * @param	string
 * @param	boolean
 * @return	string
 */
function fuel_url($uri = '', $query_string = FALSE)
{
    $CI =& get_instance();
    $uri = fuel_uri($uri, $query_string);
    return site_url($uri);
}
コード例 #13
0
ファイル: validate.php プロジェクト: randombrad/FUEL-CMS
 function _get_pages()
 {
     $pages_input = $this->input->post('pages_input', TRUE);
     $extra_pages = array();
     if (!empty($pages_input) and $pages_input != lang('validate_pages_input')) {
         $extra_pages = explode("\n", $pages_input);
         foreach ($extra_pages as $key => $page) {
             $extra_pages[$key] = site_url(trim($page));
         }
     }
     $post_pages = !empty($_POST['pages']) ? $this->input->post('pages', TRUE) : array();
     $pages = array_merge($post_pages, $extra_pages);
     if (empty($pages)) {
         $pages = $this->input->post('pages_serialized');
         if (empty($pages)) {
             redirect(fuel_uri('tools/validate'));
         } else {
             $pages = unserialize(base64_decode($pages));
         }
     }
     return $pages;
 }
コード例 #14
0
ファイル: module.php プロジェクト: kieranklaassen/FUEL-CMS
 function restore()
 {
     if ($this->input->post('version') and $this->input->post('ref_id')) {
         if (!$this->model->restore($this->input->post('ref_id'), $this->input->post('version'))) {
             $msg = lang('module_restored', $this->module_name);
             $this->logs_model->logit($msg);
             $this->session->set_flashdata('error', $this->model->get_validation()->get_last_error());
         } else {
             $this->session->set_flashdata('success', $this->lang->line('module_restored_success'));
         }
         redirect(fuel_uri($this->module_uri . '/edit/' . $this->input->post('ref_id')));
     } else {
         show_404();
     }
 }
コード例 #15
0
ファイル: login.php プロジェクト: ressphere/cb_iloveproperty
 public function pwd_reset()
 {
     if (!$this->fuel->config('allow_forgotten_password')) {
         show_404();
     }
     $this->js_controller_params['method'] = 'add_edit';
     if (!empty($_POST)) {
         if ($this->input->post('email')) {
             $user = $this->fuel_users_model->find_one_array(array('email' => $this->input->post('email')));
             if (!empty($user['email'])) {
                 $users = $this->fuel->users;
                 $new_pwd = $this->fuel->users->reset_password($user['email']);
                 if ($new_pwd !== FALSE) {
                     $url = 'reset/' . md5($user['email']) . '/' . md5($new_pwd);
                     $msg = lang('pwd_reset_email', fuel_url($url));
                     $params['to'] = $this->input->post('email');
                     $params['subject'] = lang('pwd_reset_subject');
                     $params['message'] = $msg;
                     $params['use_dev_mode'] = FALSE;
                     if ($this->fuel->notification->send($params)) {
                         $this->session->set_flashdata('success', lang('pwd_reset'));
                         $this->fuel->logs->write(lang('auth_log_pass_reset_request', $user['email'], $this->input->ip_address()), 'debug');
                     } else {
                         $this->session->set_flashdata('error', lang('error_pwd_reset'));
                         $this->fuel->logs->write($this->fuel->notification->last_error(), 'debug');
                     }
                     redirect(fuel_uri('login'));
                 } else {
                     $this->fuel_users_model->add_error(lang('error_invalid_email'));
                 }
             } else {
                 $this->fuel_users_model->add_error(lang('error_invalid_email'));
             }
         } else {
             $this->fuel_users_model->add_error(lang('error_empty_email'));
         }
     }
     $this->form_builder->set_validator($this->fuel_users_model->get_validation());
     // build form
     $fields['Reset Password'] = array('type' => 'section', 'label' => lang('login_reset_pwd'));
     $fields['email'] = array('required' => TRUE, 'size' => 30, 'placeholder' => 'email', 'display_label' => FALSE);
     $this->form_builder->show_required = FALSE;
     $this->form_builder->set_fields($fields);
     $vars['form'] = $this->form_builder->render();
     // notifications template
     $vars['error'] = $this->fuel_users_model->get_errors();
     $vars['notifications'] = $this->load->view('_blocks/notifications', $vars, TRUE);
     $vars['page_title'] = lang('fuel_page_title');
     $this->load->view('pwd_reset', $vars);
 }
コード例 #16
0
ファイル: login.php プロジェクト: roliandra/WebInterface-Fuel
 function pwd_reset()
 {
     if (!$this->config->item('allow_forgotten_password', 'fuel')) {
         show_404();
     }
     $this->js_controller_params['method'] = 'add_edit';
     if (!empty($_POST)) {
         if ($this->input->post('email')) {
             $user = $this->users_model->find_one_array(array('email' => $this->input->post('email')));
             if (!empty($user['email'])) {
                 $new_pwd = $this->users_model->reset_password($user['email']);
                 if ($new_pwd !== FALSE) {
                     // send email to user
                     $this->load->library('email');
                     $config['wordwrap'] = TRUE;
                     $this->email->initialize($config);
                     $this->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel'));
                     $this->email->to($this->input->post('email'));
                     $this->email->subject(lang('pwd_reset_subject'));
                     $url = 'reset/' . md5($user['email']) . '/' . md5($new_pwd);
                     $msg = lang('pwd_reset_email', fuel_url($url));
                     $this->email->message($msg);
                     if ($this->email->send()) {
                         $this->session->set_flashdata('success', lang('pwd_reset'));
                     } else {
                         $this->session->set_flashdata('error', lang('error_pwd_reset'));
                     }
                     redirect(fuel_uri('login'));
                 } else {
                     $this->users_model->add_error(lang('error_invalid_email'));
                 }
             } else {
                 $this->users_model->add_error(lang('error_invalid_email'));
             }
         } else {
             $this->users_model->add_error(lang('error_empty_email'));
         }
     }
     $this->form_builder->set_validator($this->users_model->get_validation());
     // build form
     $fields['Reset Password'] = array('type' => 'section', 'label' => lang('login_reset_pwd'));
     $fields['email'] = array('required' => true, 'size' => 30);
     $this->form_builder->show_required = false;
     $this->form_builder->set_fields($fields);
     $vars['form'] = $this->form_builder->render();
     // notifications template
     $vars['error'] = $this->users_model->get_errors();
     $vars['notifications'] = $this->load->view('_blocks/notifications', $vars, TRUE);
     $vars['page_title'] = lang('fuel_page_title');
     $this->load->view('pwd_reset', $vars);
 }
コード例 #17
0
ファイル: users.php プロジェクト: randombrad/FUEL-CMS
 function _send_email($id)
 {
     if (!empty($id) and !has_errors() and isset($_POST['send_email']) and (!empty($_POST['password']) or !empty($_POST['new_password']))) {
         $password = !empty($_POST['password']) ? $this->input->post('password') : $this->input->post('new_password');
         // send email to user
         $this->load->library('email');
         $config['wordwrap'] = TRUE;
         $this->email->initialize($config);
         $this->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel'));
         $this->email->to($this->input->post('email'));
         $this->email->subject(lang('new_user_email_subject'));
         $msg = lang('new_user_email', $this->input->post('user_name'), $password);
         $this->email->message($msg);
         if ($this->email->send()) {
             $this->session->set_flashdata('success', lang('new_user_created_notification', $this->input->post('email')));
             redirect(fuel_uri($this->module_uri . '/edit/' . $id));
         } else {
             add_error(lang('error_sending_email'));
         }
     }
 }
コード例 #18
0
ファイル: module.php プロジェクト: nonconforme/FUEL-CMS
 function restore()
 {
     if (!$this->fuel->auth->has_permission($this->permission, 'edit')) {
         show_error(lang('error_no_permissions'));
     }
     if (!empty($_POST['fuel_restore_version']) and !empty($_POST['fuel_restore_ref_id'])) {
         if (!$this->model->restore($this->input->post('fuel_restore_ref_id'), $this->input->post('fuel_restore_version'))) {
             $msg = lang('module_restored', $this->module_name);
             $this->fuel->logs->write($msg);
             $this->fuel->admin->set_notification($this->model->get_validation()->get_last_error(), Fuel_admin::NOTIFICATION_ERROR);
         } else {
             if (!$this->session->flashdata('success')) {
                 $this->fuel->admin->set_notification(lang('module_restored_success'), Fuel_admin::NOTIFICATION_SUCCESS);
             }
             $this->_clear_cache();
         }
         redirect(fuel_uri($this->module_uri . '/edit/' . $this->input->post('fuel_restore_ref_id', TRUE)));
     } else {
         show_404();
     }
 }
コード例 #19
0
ファイル: Fuel_admin.php プロジェクト: kbjohnson90/FUEL-CMS
 /**
  * Sets the last page that was visited in the admin
  *
  * @access	public
  * @param	string	The URI path of a page (optional)
  * @return	void
  */
 public function set_last_page($page = NULL)
 {
     if (!isset($page)) {
         $page = uri_path(FALSE);
     }
     $invalid = array(fuel_uri('recent'));
     if (!is_ajax() and empty($_POST) and !in_array($page, $invalid) and !$this->is_inline()) {
         $this->fuel->auth->set_user_data('fuel_last_page', $page);
     }
 }
コード例 #20
0
ファイル: assets.php プロジェクト: kieranklaassen/FUEL-CMS
 function delete($id = NULL)
 {
     if (!$this->fuel_auth->has_permission($this->permission, 'delete')) {
         show_error(lang('error_no_permissions'));
     }
     if (!empty($_POST['id'])) {
         $posted = explode('|', $this->input->post('id'));
         foreach ($posted as $id) {
             $this->model->delete(uri_safe_decode($id));
         }
         $this->session->set_flashdata('success', $this->lang->line('data_deleted'));
         $this->_clear_cache();
         $this->logs_model->logit('Multiple module ' . $this->module . ' data deleted');
         redirect(fuel_uri($this->module_uri));
     } else {
         $this->js_controller_params['method'] = 'deleteItem';
         $vars = array();
         if (!empty($_POST['delete']) and is_array($_POST['delete'])) {
             $data = array();
             foreach ($this->input->post('delete') as $key => $val) {
                 $d = $this->model->find_by_key(uri_safe_decode($key), 'array');
                 if (!empty($d)) {
                     $data[] = $d[$this->display_field];
                 }
             }
             $vars['id'] = implode('|', array_keys($_POST['delete']));
             $vars['title'] = implode(', ', $data);
         } else {
             $data = $this->model->find_by_key(uri_safe_decode($id));
             $vars['id'] = $id;
             if (isset($data[$this->display_field])) {
                 $vars['title'] = $data[$this->display_field];
             }
         }
         if (empty($data) or !empty($data['server_path']) and empty($data['name'])) {
             show_404();
         }
         $vars['error'] = $this->model->get_errors();
         $vars['notifications'] = $this->load->module_view(FUEL_FOLDER, '_blocks/notifications', $vars, TRUE);
         $this->_render($this->views['delete'], $vars);
     }
 }
コード例 #21
0
 protected function _last_page($key = NULL)
 {
     if (!isset($key)) {
         $key = uri_path(FALSE);
     }
     $invalid = array(fuel_uri('recent'));
     $session_key = $this->fuel_auth->get_session_namespace();
     $user_data = $this->fuel_auth->user_data();
     if (!is_ajax() and empty($_POST) and !in_array($key, $invalid)) {
         $user_data['last_page'] = $key;
         $this->session->set_userdata($session_key, $user_data);
     }
 }
コード例 #22
0
ファイル: blocks.php プロジェクト: ressphere/cb_iloveproperty
 public function upload($inline = FALSE)
 {
     $this->load->helper('file');
     $this->load->helper('security');
     $this->load->library('form_builder');
     $this->load->library('upload');
     $this->js_controller_params['method'] = 'upload';
     if (!empty($_POST) and !empty($_FILES)) {
         $params['upload_path'] = sys_get_temp_dir();
         $params['allowed_types'] = 'php|html|txt';
         // to ensure we check the proper mime types
         $this->upload->initialize($params);
         // Hackery to ensure that a proper php mimetype is set.
         // Would set in mimes.php config but that may be updated with the next version of CI which does not include the text/plain
         $this->upload->mimes['php'] = array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source', 'text/plain');
         if ($this->upload->do_upload('file')) {
             $upload_data = $this->upload->data();
             $error = FALSE;
             // read in the file so we can filter it
             $file = read_file($upload_data['full_path']);
             // sanitize the file before saving
             $file = $this->_sanitize($file);
             $id = $this->input->post('id', TRUE);
             $name = $this->input->post('name', TRUE);
             $language = $this->input->post('language', TRUE);
             if (empty($name)) {
                 $name = current(explode('.', $file_info['name']));
             }
             if ($id) {
                 $save['id'] = $id;
             }
             $save['name'] = $name;
             $save['view'] = $file;
             $save['language'] = $language;
             $save['date_added'] = datetime_now();
             $save['last_modified'] = date('Y-m-d H:i:s', time() + 1);
             // to prevent window from popping up after upload
             $id = $this->model->save($save);
             if (!$id) {
                 add_error(lang('error_upload'));
             } else {
                 // change list view page state to show the selected group id
                 $this->fuel->admin->set_notification(lang('blocks_success_upload'), Fuel_admin::NOTIFICATION_SUCCESS);
                 redirect(fuel_url('blocks/edit/' . $id));
             }
         } else {
             $error_msg = $this->upload->display_errors('', '');
             add_error($error_msg);
         }
     }
     $fields = array();
     $blocks = $this->model->options_list('id', 'name', array('published' => 'yes'), 'name');
     $fields['name'] = array('label' => lang('form_label_name'), 'type' => 'inline_edit', 'options' => $blocks, 'module' => 'blocks');
     $fields['file'] = array('type' => 'file', 'accept' => '', 'required' => TRUE);
     $fields['id'] = array('type' => 'hidden');
     $fields['language'] = array('type' => 'hidden');
     $field_values = $_POST;
     $common_fields = $this->_common_fields($field_values);
     $fields = array_merge($fields, $common_fields);
     $this->form_builder->hidden = array();
     $this->form_builder->set_fields($fields);
     $this->form_builder->set_field_values($_POST);
     $this->form_builder->submit_value = '';
     $this->form_builder->use_form_tag = FALSE;
     $vars['instructions'] = lang('blocks_upload_instructions');
     $vars['form'] = $this->form_builder->render();
     $vars['back_action'] = ($this->fuel->admin->last_page() and $this->fuel->admin->is_inline()) ? $this->fuel->admin->last_page() : fuel_uri($this->module_uri);
     //$vars['back_action'] = fuel_uri($this->module_uri);
     $crumbs = array($this->module_uri => $this->module_name, lang('action_upload'));
     $this->fuel->admin->set_titlebar($crumbs);
     $this->fuel->admin->render('upload', $vars, Fuel_admin::DISPLAY_NO_ACTION);
 }
コード例 #23
0
ファイル: Fuel_hooks.php プロジェクト: scotton34/sample
 public function offline()
 {
     if (!USE_FUEL_ROUTES) {
         $CI =& get_instance();
         // Already in offline page
         if (preg_match('#^offline(/?)$#', uri_path(FALSE))) {
             return;
         }
         if ($CI->fuel->config('offline') and !$CI->fuel->auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
             // By pass offline page if password inputed.
             $CI->load->library('session');
             if ($CI->session->userdata('dev_password')) {
                 return;
             }
             // Display allowed page
             $allowed_uri = $CI->fuel->config('offline_allowed_uri');
             if (!empty($allowed_uri)) {
                 foreach ($allowed_uri as $uri_item) {
                     if (preg_match('#^' . $uri_item . '(/?)$#', uri_path(FALSE))) {
                         return;
                     }
                 }
             }
             // Instead of using render, changed to redirect
             redirect('offline');
             //echo $CI->fuel->pages->render('offline', array(), array(), TRUE);
             //exit();
         }
     }
 }