Пример #1
0
        public void libraryUpload(string[] uploadFilePath, string[] contentId)
        {
            if (uploadFilePath != null)
            {
                H5PCore.ajaxError(this.core.t("Could not get posted H5P."), "NO_CONTENT_TYPE", 0);
                return;
            }

            var file = this.saveFileTemporarily(uploadFilePath, true);

            if (!file)
            {
                return;
            }

            if (!this.isValidPackage())
            {
                return;
            }

            var storage = new H5PStorage(h5pF, core);

            storage.savePackage(null, null, true);

            var content = this.core.moveContentDirectory(this.getUploadedH5pFolderPath(), contentId);

            this.storage.removeTemporarilySavedFiles(this.core.getUploadedH5pFolderPath());

            Dictionary <string, dynamic> ht = new Dictionary <string, dynamic>();

            ht.Add("h5p", content.h5pJson());
            ht.Add("content", content.contentJson());
            ht.Add("contentTypes", this.getContentTypeCache());
            H5PCore.ajaxSuccess(ht);
        }
Пример #2
0
        public void action(string endpoint)
        {
            var token      = new string[1];
            var uploadPath = new string[2];
            var contentId  = new string[3];

            switch (endpoint)
            {
            case H5PEditorEndpoints.LIBRARIES:
                H5PCore.ajaxSuccess(this.editor.getLibraries(), true);
                break;

            case H5PEditorEndpoints.SINGLE_LIBRARY:
                //$args = func_get_args();
                //array_shift($args);
                //$library = call_user_func_array(
                //array($this->editor, 'getLibraryData'), $args
                //);
                Dictionary <string, dynamic> library = null;   //Temporary declaration
                H5PCore.ajaxSuccess(library, true);

                break;

            case H5PEditorEndpoints.CONTENT_TYPE_CACHE:
                if (!this.isHubOn())
                {
                    return;
                }
                H5PCore.ajaxSuccess(this.getContentTypeCache(!this.isContentTypeCacheUpdated()), true);
                break;

            case H5PEditorEndpoints.LIBRARY_INSTALL:
                if (!this.isPostRequest())
                {
                    return;
                }

                if (!this.isValidEditorToken(token))
                {
                    return;
                }

                var machineName = new string[2];
                this.libraryInstall(machineName);
                break;

            case H5PEditorEndpoints.LIBRARY_UPLOAD:
                if (!this.isPostRequest())
                {
                    return;
                }

                token      = new string[1];
                uploadPath = new string[2];
                contentId  = new string[3];
                if (!this.isValidEditorToken(token))
                {
                    return;
                }

                this.libraryUpload(uploadPath, contentId);
                break;

            case H5PEditorEndpoints.FILES:
                token     = new string[1];
                contentId = new string[2];
                this.libraryUpload(uploadPath, contentId);
                break;
            }
        }