/** * Get post by local id. */ public function getResource($slug) { if (!remotesync\H5pUtil::h5pExists($slug)) { return NULL; } $localId = remotesync\H5pUtil::getIdBySlug($slug); global $wpdb; $q = $wpdb->prepare("SELECT * FROM {$wpdb->prefix}h5p_contents WHERE id=%s", $localId); $h5p = $wpdb->get_row($q, ARRAY_A); if ($wpdb->last_error) { throw new Exception($wpdb->last_error); } if (!$h5p) { return NULL; } return array("title" => $h5p["title"], "parameters" => $h5p["parameters"], "slug" => $h5p["slug"], "embed_type" => $h5p["embed_type"], "disable" => strval($h5p["disable"]), "content_type" => $h5p["content_type"] ? $h5p["content_type"] : "", "keywords" => $h5p["keywords"] ? $h5p["keywords"] : "", "description" => $h5p["description"] ? $h5p["description"] : "", "license" => $h5p["license"] ? $h5p["license"] : "", "library" => remotesync\H5pUtil::getLibraryNameById($h5p["library_id"])); }
/** * Save a H5P content onto the system. If a content with * the same slug already exists, it will be replaced. */ static function saveH5p($slug, $h5pFileName, $title) { if (H5pUtil::h5pExists($slug)) { H5pUtil::updateH5p($slug, $h5pFileName, $title); } else { H5pUtil::insertH5p($slug, $h5pFileName, $title); } }