/** gọi model xử lý content */ require_once dirname(__FILE__) . '/content/content_model.php'; require_once dirname(__FILE__) . '/taxonomy/taxonomy_model.php'; $key = hm_get('key'); $id = hm_get('id'); $action = hm_get('action'); switch ($action) { case 'data': $status = hm_get('status', 'public'); $perpage = hm_get('perpage', '30'); echo content_show_data($key, $status, $perpage); break; case 'add': /** Thực hiện thêm content */ $args = array('content_key' => $key); echo content_ajax_add($args); break; case 'add_chapter': /** Thực hiện thêm chapter */ echo content_ajax_add_chapter($id); break; case 'edit': /** Thực hiện sửa content */ echo content_ajax_edit($id); break; case 'draft': /** Thực hiện xóa content */ echo content_update_val(array('id' => hm_post('id'), 'value' => array('status' => MySQL::SQLValue('draft')))); break; case 'delete_permanently': /** Thực hiện xóa vĩnh viễn content */
function content_ajax_edit($id) { global $hmcontent; $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET); hook_action('content_ajax_edit'); $tableName = DB_PREFIX . "content"; $whereArray = array('id' => MySQL::SQLValue($id)); $hmdb->SelectRows($tableName, $whereArray); if ($hmdb->HasRecords()) { $row = $hmdb->Row(); $content_key = $row->key; /** lưu bản revision content vào database */ content_create_revision($id); /** Hoàn thành lưu bản chỉnh sửa - Lưu bản cập nhật mới*/ $args = array('content_key' => $content_key, 'id_update' => $id); return content_ajax_add($args); } }