/** * Saves one Page * * @param array Page data table * @param array Page Lang depending data table * * @return string The inserted / updated page ID * */ function save($data, $lang_data) { // Dates $data['publish_on'] = $data['publish_on'] ? getMysqlDatetime($data['publish_on'], Settings::get('date_format')) : '0000-00-00'; $data['publish_off'] = $data['publish_off'] ? getMysqlDatetime($data['publish_off'], Settings::get('date_format')) : '0000-00-00'; $data['logical_date'] = $data['logical_date'] ? getMysqlDatetime($data['logical_date'], Settings::get('date_format')) : '0000-00-00'; // Creation date if (!$data['id_page'] or $data['id_page'] == '') { $data['created'] = date('Y-m-d H:i:s'); } else { $data['updated'] = date('Y-m-d H:i:s'); } // Be sure URLs are unique $this->set_unique_urls($lang_data, $data['id_page']); // Clean metas data foreach ($lang_data as $lang => $row) { foreach ($row as $key => $value) { if ($key == 'meta_description') { $lang_data[$lang][$key] = preg_replace('[\\"]', '', $value); } if ($key == 'meta_keywords') { $lang_data[$lang][$key] = preg_replace('/[\\"\\.;]/i ', '', $value); } } } // Base model save method call return parent::save($data, $lang_data); }
/** * Saves the article * * @param array Standard data table * @param array Lang depending data table * * @return int Articles saved ID * */ function save($data, $lang_data) { // New article : Created field if (!$data['id_article']) { $data['created'] = $data['updated'] = date('Y-m-d H:i:s'); } else { $data['updated'] = date('Y-m-d H:i:s'); } // Be sure URLs are unique $this->set_unique_urls($lang_data, $data['id_article']); // Dates $data['publish_on'] = $data['publish_on'] ? getMysqlDatetime($data['publish_on']) : '0000-00-00'; $data['publish_off'] = $data['publish_off'] ? getMysqlDatetime($data['publish_off']) : '0000-00-00'; $data['comment_expire'] = $data['comment_expire'] ? getMysqlDatetime($data['comment_expire']) : '0000-00-00'; $data['logical_date'] = $data['logical_date'] ? getMysqlDatetime($data['logical_date']) : '0000-00-00'; // Article saving return parent::save($data, $lang_data); }
/** * Saves one media data * * @param array standard data array * @param array lang data array * * @return string Inserted / Updated media ID */ public function save($data, $lang_data) { // Dates $data['date'] = $data['date'] ? getMysqlDatetime($data['date'], Settings::get('date_format')) : '0000-00-00'; // Media saving return parent::save($data, $lang_data); }
/** * Updates one page's field * Called through XHR * * Data are get by $_POST : * - field : DB field name * - id_page : Page ID` * - value : Value to set */ public function update_field() { $field = $this->input->post('field'); $id_page = $this->input->post('id_page'); $type = $this->input->post('type'); if ($id_page && $field) { $value = $this->input->post('value'); // Check type of data, for special process if ($type === 'date') { $value = $value ? getMysqlDatetime($value) : '0000-00-00 00:00:00'; } // Update $result = $this->page_model->update(array('id_page' => $id_page), array($field => $value)); if ($result) { // Data $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default')); $menu = $this->menu_model->get($page['id_menu']); $page['title'] = htmlspecialchars_decode($page['title'], ENT_QUOTES); $page['element'] = 'page'; $page['menu'] = $menu; $this->callback[] = array('fn' => 'ION.notification', 'args' => array('success', lang('ionize_message_page_saved'))); $this->callback[] = array('fn' => $page['menu']['name'] . 'Tree.updateElement', 'args' => array($page, 'page')); $this->response(); } } }
/** * Set the correct dates to one article and return it * * @param array $data Article array * @return array */ protected function _set_dates($data) { $data['publish_on'] = isset($data['publish_on']) && $data['publish_on'] ? getMysqlDatetime($data['publish_on'], Settings::get('date_format')) : '0000-00-00'; $data['publish_off'] = isset($data['publish_off']) && $data['publish_off'] ? getMysqlDatetime($data['publish_off'], Settings::get('date_format')) : '0000-00-00'; $data['logical_date'] = isset($data['logical_date']) && $data['logical_date'] ? getMysqlDatetime($data['logical_date'], Settings::get('date_format')) : '0000-00-00'; $data['comment_expire'] = isset($data['comment_expire']) && $data['comment_expire'] ? getMysqlDatetime($data['comment_expire'], Settings::get('date_format')) : '0000-00-00'; return $data; }
/** * Saves one media data * * @param array standard data array * @param array lang data array * * @return string Inserted / Updated media ID */ function save($data, $lang_data) { // Dates $data['date'] = $data['date'] ? getMysqlDatetime($data['date']) : '0000-00-00'; // Media saving return parent::save($data, $lang_data); }
public function update_field() { $field = $this->input->post('field'); $id_article = $this->input->post('id_article'); $type = $this->input->post('type'); if ($id_article && $field) { $value = $this->input->post('value'); // Check the type of data, for special process if ($type === 'date') { $value = $value ? getMysqlDatetime($value) : '0000-00-00 00:00:00'; } // Update $result = $this->article_model->update(array('id_article' => $id_article), array($field => $value)); if ($result) { $this->update_contexts($id_article); $this->success(lang('ionize_message_article_saved')); } else { $this->response(); } } }
/** * Sets the correct dates to the page array * * @param array $data * @return array */ protected function _set_dates($data) { $data['publish_on'] = isset($data['publish_on']) && $data['publish_on'] ? getMysqlDatetime($data['publish_on'], Settings::get('date_format')) : '0000-00-00'; $data['publish_off'] = isset($data['publish_off']) && $data['publish_off'] ? getMysqlDatetime($data['publish_off'], Settings::get('date_format')) : '0000-00-00'; $data['logical_date'] = isset($data['logical_date']) && $data['logical_date'] ? getMysqlDatetime($data['logical_date'], Settings::get('date_format')) : '0000-00-00'; // Creation date if (!$data['id_page'] or $data['id_page'] == '') { $data['created'] = date('Y-m-d H:i:s'); } else { $data['updated'] = date('Y-m-d H:i:s'); } return $data; }