Пример #1
0
 /**
  * Edit or add a source
  */
 public function edit_source()
 {
     if ($this->EE->session->userdata['group_id'] != 1) {
         $this->_forbidden();
     }
     $this->EE->load->library('table');
     $source_id = $this->EE->input->get('source_id');
     $source = NULL;
     if (!empty($source_id) && is_numeric($source_id)) {
         try {
             $source_row = $this->EE->assets_lib->get_source_row_by_id($source_id);
             $source = $this->EE->assets_lib->instantiate_source_type((object) array('source_type' => $source_row->source_type, 'source_id' => $source_id));
             $this->_set_page_title(lang('edit_source'));
         } catch (Exception $exception) {
             // not loaded, $source remains null
         }
     } else {
         $this->_set_page_title(lang('add_new_source'));
     }
     $vars = array();
     $vars['is_new'] = is_null($source);
     $vars['source'] = $source;
     $vars['base'] = $this->base;
     $vars['source_types'] = $this->EE->assets_lib->get_all_source_types();
     $vars['setting_fields'] = $this->EE->assets_lib->get_source_settings_field_list();
     $js = "var Assets = {};" . Assets_helper::get_actions_js() . "\n" . 'Assets.siteUrl = "' . Assets_helper::get_site_url() . '";';
     $js .= Assets_helper::get_lang_js('rs_select_region');
     Assets_helper::insert_js($js);
     Assets_helper::include_garnish();
     Assets_helper::include_js('assets.js', 'settings.js');
     Assets_helper::include_css('settings.css');
     return $this->EE->load->view('mcp/edit_source', $vars, TRUE);
 }