function ajaxChapterCreator(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     $chapter = isset($data[Chapter::ATTR_ID]) ? Chapter::findOrNew($data[Chapter::ATTR_ID]) : new Chapter();
     $chapter->production_id = $data[Chapter::ATTR_PRODUCTION_ID];
     $chapter->name = $data[Chapter::ATTR_NAME];
     $chapter->video = str_replace(array("\n", "\t", "\r", " "), "", $data[Chapter::ATTR_VIDEO]);
     $chapter->videocloud_id = VideoCloudAccount::getCurrentAccountId();
     $chapter->quality = $data[Chapter::ATTR_QUALITY];
     $chapter->languages = $data[Chapter::ATTR_LANGUAGES];
     $chapter->subtitles = isset($data[Chapter::ATTR_SUBTITLES]) ? $data[Chapter::ATTR_SUBTITLES] : null;
     $chapter->type = $data[Chapter::ATTR_TYPE];
     $chapter->state = $data[Chapter::ATTR_STATE];
     $chapter->save();
     return json_encode(array(Chapter::ATTR_ID => $chapter->id, Chapter::ATTR_NAME => $chapter->name, Chapter::ATTR_VIDEO => htmlentities($chapter->video), Chapter::ATTR_QUALITY => $chapter->quality, Chapter::ATTR_LANGUAGES => Util::formatResultArray($data[Chapter::ATTR_LANGUAGES], ",", "\"", "\""), Chapter::ATTR_SUBTITLES => Util::formatResultArray($chapter->subtitles, ",", "\"", "\""), Chapter::ATTR_STATE => $chapter->state));
 }