예제 #1
0
 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $fields = array();
     $fields['pre_populate_source'] = is_null($this->get('pre_populate_source')) ? null : implode(',', $this->get('pre_populate_source'));
     $fields['validator'] = $fields['validator'] == 'custom' ? null : $this->get('validator');
     if (!FieldManager::saveSettings($id, $fields)) {
         return false;
     }
     SectionManager::removeSectionAssociation($id);
     foreach ($this->get('pre_populate_source') as $field_id) {
         if ($field_id === 'none') {
             continue;
         }
         if (!is_null($field_id) && is_numeric($field_id)) {
             SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
         }
     }
     return true;
 }
 /**
  * Save the settings panel
  *
  * @return bool
  */
 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     if ($this->get('related_field_id') != '') {
         $settings['related_field_id'] = $this->get('related_field_id');
     }
     $settings['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
     $settings['show_association'] = $this->get('show_association') == 'yes' ? 'yes' : 'no';
     $settings['limit'] = max(1, (int) $this->get('limit'));
     $settings['related_field_id'] = implode(',', $this->get('related_field_id'));
     $settings['view'] = $this->get('view');
     $settings['show_created'] = $this->get('show_created') == 'yes' ? 1 : 0;
     $settings['enable_create'] = $this->get('enable_create') == 'yes' ? 1 : 0;
     $settings['enable_edit'] = $this->get('enable_edit') == 'yes' ? 1 : 0;
     $settings['enable_delete'] = $this->get('enable_delete') == 'yes' ? 1 : 0;
     FieldManager::saveSettings($id, $settings);
     SectionManager::removeSectionAssociation($id);
     foreach ($this->get('related_field_id') as $field_id) {
         SectionManager::createSectionAssociation(null, $id, $field_id, $this->get('show_association') == 'yes' ? true : false);
     }
     return true;
 }
예제 #3
0
 /**
  * Permanently remove a section association for this field in the database.
  *
  * @deprecated This function will be removed in a future Symphony release,
  *  Use `SectionManager::removeSectionAssociation` instead.
  * @param integer $child_field_id
  *  the field ID of the linked section's linked field.
  * @return boolean
  */
 public function removeSectionAssociation($child_field_id)
 {
     return SectionManager::removeSectionAssociation($child_field_id);
 }
예제 #4
0
 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $fields = array();
     if ($this->get('static_options') != '') {
         $fields['static_options'] = $this->get('static_options');
     }
     if ($this->get('dynamic_options') != '') {
         $fields['dynamic_options'] = $this->get('dynamic_options');
     }
     $fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
     $fields['sort_options'] = $this->get('sort_options') == 'yes' ? 'yes' : 'no';
     if (!FieldManager::saveSettings($id, $fields)) {
         return false;
     }
     SectionManager::removeSectionAssociation($id);
     // Dynamic Options isn't an array like in Select Box Link
     $field_id = $this->get('dynamic_options');
     if (!is_null($field_id) && is_numeric($field_id)) {
         SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
     }
     return true;
 }
 public function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $fields = array();
     $fields['field_id'] = $id;
     if ($this->get('related_field_id') != '') {
         $fields['related_field_id'] = $this->get('related_field_id');
     }
     $fields['related_field_id'] = implode(',', $this->get('related_field_id'));
     $fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
     $fields['hide_when_prepopulated'] = $this->get('hide_when_prepopulated') == 'yes' ? 'yes' : 'no';
     $fields['limit'] = max(0, (int) $this->get('limit'));
     if (!FieldManager::saveSettings($id, $fields)) {
         return false;
     }
     SectionManager::removeSectionAssociation($id);
     foreach ($this->get('related_field_id') as $field_id) {
         SectionManager::createSectionAssociation(null, $id, (int) $field_id, $this->get('show_association') == 'yes' ? true : false, $this->get('association_ui'), $this->get('association_editor'));
     }
     return true;
 }
 /**
  * @see http://symphony-cms.com/learn/api/2.3/toolkit/field/#commit
  */
 function commit()
 {
     // Prepare commit
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     // Set up fields
     $fields = array();
     $fields['field_id'] = $id;
     $fields['subsection_id'] = $this->get('subsection_id');
     $fields['create'] = $this->get('create') ? 1 : 0;
     $fields['remove'] = $this->get('remove') ? 1 : 0;
     $fields['allow_multiple'] = $this->get('allow_multiple') ? 1 : 0;
     $fields['edit'] = $this->get('edit') ? 1 : 0;
     $fields['sort'] = $this->get('sort') ? 1 : 0;
     $fields['drop'] = $this->get('drop') ? 1 : 0;
     $fields['show_search'] = $this->get('show_search') ? 1 : 0;
     $fields['show_preview'] = $this->get('show_preview') ? 1 : 0;
     // Clean up filter values
     if ($this->get('filter_tags') != '') {
         $tags = explode(",", $this->get('filter_tags'));
         foreach ($tags as &$tag) {
             $tag = trim($this->cleanValue($tag));
             $list[] = $tag;
         }
         $fields['filter_tags'] = implode(', ', $list);
     }
     // Item caption
     $fields['caption'] = $this->get('caption');
     if ($this->get('caption') == '') {
         // Fetch fields in subsection
         $subsection_fields = Symphony::Database()->fetch("SELECT element_name, type\n\t\t\t\t\tFROM tbl_fields\n\t\t\t\t\tWHERE parent_section = '" . $this->get('subsection_id') . "'\n\t\t\t\t\tORDER BY sortorder ASC\n\t\t\t\t\tLIMIT 10");
         // Generate default caption
         $text = $file = '';
         foreach ($subsection_fields as $subfield) {
             if ($text != '' && $file != '') {
                 break;
             }
             if (strpos($subfield['type'], 'upload') === false) {
                 if ($text == '') {
                     $text = '{$' . $subfield['element_name'] . '}';
                 }
             } else {
                 if ($file == '') {
                     $file = '{$' . $subfield['element_name'] . '}';
                 }
             }
         }
         // Caption markup
         if ($text != '' && $file != '') {
             $fields['caption'] = $text . '<br /> <em>' . $file . '</em>';
         } else {
             $fields['caption'] = $text . $file;
         }
     }
     // Drop text
     $fields['droptext'] = $this->get('droptext');
     // XML Output
     $fields['recursion_levels'] = intval($this->get('recursion_levels'));
     if (empty($fields['recursion_levels'])) {
         $fields['recursion_levels'] = 0;
     }
     // Make sure it is 0, not null
     // Delete old field settings
     Symphony::Database()->query("DELETE FROM `tbl_fields_" . $this->handle() . "` WHERE `field_id` = '{$id}' LIMIT 1");
     // Save new field setting
     $settings = Symphony::Database()->insert($fields, 'tbl_fields_' . $this->handle());
     // Remove old secion association
     SectionManager::removeSectionAssociation($id);
     // Save new section association
     $association = $this->createSectionAssociation(null, $this->get('subsection_id'), $id, $id, false);
     if ($settings && $association) {
         return true;
     } else {
         return false;
     }
 }
예제 #7
0
 /**
  * Given a Field ID, delete a Field from Symphony. This will remove the field from
  * the fields table, all of the data stored in this field's `tbl_entries_data_$id` any
  * existing section associations. This function additionally call the Field's `tearDown`
  * method so that it can cleanup any additional settings or entry tables it may of created.
  *
  * @param integer $id
  *  The ID of the Field that should be deleted
  * @return boolean
  */
 public static function delete($id)
 {
     $existing = self::fetch($id);
     $existing->tearDown();
     Symphony::Database()->delete('tbl_fields', " `id` = '{$id}'");
     Symphony::Database()->delete('tbl_fields_' . $existing->handle(), " `field_id` = '{$id}'");
     SectionManager::removeSectionAssociation($id);
     Symphony::Database()->query('DROP TABLE `tbl_entries_data_' . $id . '`');
     return true;
 }
 public function commit()
 {
     if (!Field::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     // set field instance values
     $fields = array();
     $fields['field_id'] = $id;
     if (!is_null($this->get('related_field_id'))) {
         $fields['related_field_id'] = implode(',', $this->get('related_field_id'));
     }
     $fields['allow_multiple_selection'] = $this->get('allow_multiple_selection') ? $this->get('allow_multiple_selection') : 'no';
     $fields['show_association'] = $this->get('show_association') == 'yes' ? 'yes' : 'no';
     $fields['limit'] = max(1, (int) $this->get('limit'));
     $fields['field_type'] = $this->get('field_type') ? $this->get('field_type') : 'select';
     // save/replace field instance
     if (!FieldManager::saveSettings($id, $fields)) {
         return false;
     }
     // build associations
     SectionManager::removeSectionAssociation($id);
     foreach ($this->get('related_field_id') as $field_id) {
         SectionManager::createSectionAssociation(NULL, $id, $field_id, $this->get('show_association') == 'yes' ? true : false);
     }
     return true;
 }