コード例 #1
0
 public function act_field_customization()
 {
     global $conf;
     include_once APPROOT . 'mod/admin/lib_form_customization.inc';
     $this->entity_select = $_REQUEST['entity_select'];
     $this->sub_act = isset($_REQUEST['sub_act']) ? $_REQUEST['sub_act'] : 'label';
     $_REQUEST['sub_act'] = $this->sub_act;
     $this->browse_needed = false;
     if ($this->entity_select == 'event' || $this->entity_select == 'person' || $this->entity_select == 'supporting_docs_meta') {
         $this->browse_needed = true;
     }
     if ($this->entity_select == 'biographic_details' && $conf['menus']['biography_list']) {
         $this->browse_needed = true;
     }
     include_once APPROOT . 'mod/admin/customization_form.inc';
     //include select entity form
     $this->customization_form = $customization_form;
     //if the locale is changed need to display extra column in label customization
     //if(is_locale_changed())
     $this->locale = $conf['locale'];
     include_once APPROOT . 'inc/i18n/lib_l10n.inc';
     $this->locales = l10n_get_locals();
     if (isset($this->entity_select)) {
         if ($this->sub_act == 'help') {
             if ($_POST['save_help']) {
                 form_customization_update_help($_POST, $this->entity_select);
             }
             $this->help_texts = Browse::getHelpText($this->entity_select, $this->locales);
             return;
         } elseif ($this->sub_act == 'order' && isset($_POST['itemsorder'])) {
             form_customization_update_fields_order($this->entity_select);
         } else {
             //if update is sent save data
             //OES-28. By pressing enter forms submited. if there no reset nor update - entered data will be lost.
             //so better to save changes. update by default
             //if($_POST['update']){
             if ('POST' == $_SERVER['REQUEST_METHOD']) {
                 form_customization_process_entity_form($this->entity_select);
             }
             /* if (isset($_POST['reset'])) {
                form_customization_reset_all($this->entity_select);
                } */
             // OES-28
             /* $reset_fields = form_customization_get_reset_fields();
                foreach ($reset_fields as $post_value => $table_field) {
                if (isset($_POST[$post_value])) {
                form_customization_reset_field($this->entity_select, $table_field);
                }
                } */
         }
         //include field form
         include_once APPROOT . 'mod/admin/entity_form.inc';
         $this->entity_form = $entity_form;
         if ($this->sub_act == 'label') {
             $this->res = Browse::getFieldsTranslations($this->entity_select, $this->locales);
         } else {
             $this->res = form_customization_get_field_table($this->entity_select);
         }
         if ($this->sub_act == 'visibility') {
             $fields_form = generate_formarray($this->entity_select, "new");
             $fields_form2 = array();
             foreach ($fields_form as $k => $f) {
                 if ($f["type"] == 'mt_tree' || $f['type'] == 'mt_select' || $f['type'] == 'radio') {
                     $fields_form2[$k] = $f;
                 }
             }
             $this->fields_form = $fields_form2;
             $res = Browse::getFields($this->entity_select);
             $fields = array();
             $field_numbers = array();
             foreach ($res as $record) {
                 if ($record['enabled'] == 'y' && $record['visible_new'] == 'y' && ($record['field_type'] == 'mt_tree' || $record['field_type'] == 'mt_select' || $record['field_type'] == 'radio')) {
                     $fields[$record['field_number']] = $record;
                 }
                 $field_numbers[] = $record['field_number'];
             }
             $this->fields_for_hide = $fields;
             $browse = new Browse();
             $sql = "SELECT * from data_dict_visibility where field_number in ('" . implode("','", $field_numbers) . "') order by field_number,field_number2";
             $this->visibility_fields = $browse->ExecuteQuery($sql);
         }
     }
 }