Exemple #1
0
 /**
  * Add one value to one "List type" Extend.
  * Used by Link
  *
  */
 public function add_value_to_extend_field()
 {
     $value = $this->input->post('value');
     $id_extend = $this->input->post('id_extend');
     $parent = $this->input->post('parent');
     $id_parent = $this->input->post('id_parent');
     $lang = $this->input->post('lang') ? $this->input->post('lang') : NULL;
     if ($id_extend && $parent && $id_parent) {
         $this->extend_field_model->add_value_to_extend_field($id_extend, $parent, $id_parent, $value, $lang);
     } else {
         log_message('error', print_r(get_class($this) . '->add_value_to_extend_field() : Some value missing ($id_extend, $parent, $id_parent)', TRUE));
     }
     $this->response();
 }
Exemple #2
0
 /**
  * Adds one media to one extend field
  *
  */
 public function add_media_to_extend()
 {
     $path = $this->input->post('path');
     $parent = $this->input->post('parent');
     $id_parent = $this->input->post('id_parent');
     $id_extend = $this->input->post('id_extend');
     $lang = $this->input->post('lang');
     if (!$lang) {
         $lang = NULL;
     }
     // Clear the cache
     Cache()->clear_cache();
     // Get the the cleaned path
     $path = $this->get_path_from_posted($path);
     // DB Insert
     $id_media = $this->media_model->insert_media($path);
     // Get the media
     $media = $this->media_model->get($id_media);
     // Preparing Event data
     $event_data = array('element' => $parent, 'id_element' => $id_parent, 'id_extend_field' => $id_extend, 'media' => $media);
     // Add Media to extend field values
     if (!$this->extend_field_model->add_value_to_extend_field($id_extend, $parent, $id_parent, $id_media, $lang)) {
         // Event
         Event::fire('Media.link.extend.error', $event_data);
         $this->error(lang('ionize_message_media_already_attached'));
     } else {
         // Event
         Event::fire('Media.link.extend.success', $event_data);
         // Delete thumbs
         $type = $this->media_model->get_type($path);
         if ($type == 'picture') {
             $this->medias->delete_thumbs($media);
         }
         $this->success(lang('ionize_message_media_attached'));
     }
 }