diff --git a/insert.php b/insert.php index 6c5e0b5..92e1318 100644 --- a/insert.php +++ b/insert.php @@ -57,8 +57,8 @@ } $edusharing->id = $id; + $edusharing->src = $CFG->wwwroot . '/mod/edusharing/pix/edusharing.png'; - $edusharing->src = $CFG->wwwroot . '/lib/editor/edusharing/images/edusharing.png'; header('Content-type: application/json', true, 200); echo json_encode($edusharing); diff --git a/lang/de/atto_edusharing.php b/lang/de/atto_edusharing.php index d3d898b..2046b3f 100644 --- a/lang/de/atto_edusharing.php +++ b/lang/de/atto_edusharing.php @@ -22,8 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'edu-sharing'; -$string['dialogtitle'] = 'edu-sharing Material'; +$string['pluginname'] = get_config('edusharing', 'application_appname'); +$string['dialogtitle'] = get_config('edusharing', 'application_appname') . ' Material'; $string['settings'] = 'edu-sharing (Atto)'; $string['insert'] = 'EINFÜGEN'; $string['update'] = 'AKTUALISIEREN'; @@ -39,11 +39,11 @@ $string['dimensionsWidth'] = 'Breite'; $string['dimensionsheight'] = 'Höhe'; $string['openRepo'] = 'REPOSITORIUM ÖFFNEN'; -$string['hint1'] = 'Wählen Sie ein edu-sharing Objekt aus dem Repositorium, um es in Moodle einzubinden. Klicken Sie dazu auf "REPOSITORIUM ÖFFNEN".'; +$string['hint1'] = 'Wählen Sie ein '.get_config('edusharing', 'application_appname').' Objekt aus dem Repositorium, um es in Moodle einzubinden. Klicken Sie dazu auf "REPOSITORIUM ÖFFNEN".'; $string['hint2'] = 'Suchen Sie nun das gewünschte Objekt und betätigen Sie die "ÜBERNEHMEN" Schaltfläche.'; $string['skipHint'] = 'Beim nächsten Mal direkt zur Suche springen.'; $string['directoryHint'] = 'Der Ordner wird eingebunden. Elemente des Ordners werden angezeigt, nicht aber weitere Unterordner.'; -$string['privacy:metadata'] = 'Das edu-sharing atto-Plugin speichert keine Benutzerdaten.'; +$string['privacy:metadata'] = 'Das '.get_config('edusharing', 'application_appname').' atto-Plugin speichert keine Benutzerdaten.'; $string['edusharing:visible'] = 'edu-sharing atto-plugin Sichtbarkeit'; diff --git a/lang/en/atto_edusharing.php b/lang/en/atto_edusharing.php index c498843..b6c8494 100644 --- a/lang/en/atto_edusharing.php +++ b/lang/en/atto_edusharing.php @@ -22,8 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'edu-sharing'; -$string['dialogtitle'] = 'edu-sharing material'; +$string['pluginname'] = get_config('edusharing', 'application_appname'); +$string['dialogtitle'] = get_config('edusharing', 'application_appname').' material'; $string['settings'] = 'edu-sharing (Atto)'; $string['insert'] = 'EMBED'; $string['update'] = 'UPDATE'; @@ -39,11 +39,11 @@ $string['dimensionsWidth'] = 'Width'; $string['dimensionsheight'] = 'Height'; $string['openRepo'] = 'OPEN REPOSITORY'; -$string['hint1'] = 'Select an edu-sharing object from the repository to embed it in Moodle. Click on "OPEN REPOSITORY".'; +$string['hint1'] = 'Select an '.get_config('edusharing', 'application_appname').' object from the repository to embed it in Moodle. Click on "OPEN REPOSITORY".'; $string['hint2'] = 'Search for the desired object and click the "APPLY" button.'; $string['skipHint'] = 'Open the search engine right away next time.'; $string['directoryHint'] = 'The folder was embedded. Elements of the folder will be displayed, but not its subfolders.'; -$string['privacy:metadata'] = 'The edu-sharing atto-plugin does not store any user data.'; +$string['privacy:metadata'] = 'The '.get_config('edusharing', 'application_appname').' atto-plugin does not store any user data.'; $string['edusharing:visible'] = 'edu-sharing atto-plugin visibility'; diff --git a/lib.php b/lib.php index 7f91ce9..1217682 100644 --- a/lib.php +++ b/lib.php @@ -80,9 +80,16 @@ function atto_edusharing_params_for_js() { $params['disabled'] = true; return $params; } + + $params['disabled'] = false; $params['repourl'] = trim(get_config('edusharing', 'application_cc_gui_url'), '/'); $params['courseid'] = $COURSE->id; + $params['buttonTitle'] = 'edu-sharing'; + + if (!empty(get_config('edusharing', 'application_appname'))){ + $params['buttonTitle'] = get_config('edusharing', 'application_appname'); + } return $params; } diff --git a/styles.css b/styles.css index e36fc37..a8c56cd 100644 --- a/styles.css +++ b/styles.css @@ -116,7 +116,7 @@ input#edusharing_title:hover + #edusharing_title_pencil { background-color: #efefef; background-repeat: no-repeat; background-size: 16px; - background-image: url('[[pix:atto_edusharing|/icon]]'); + background-image: url('[[pix:edusharing|icon]]'); } .editor_atto img.edusharing_atto { diff --git a/version.php b/version.php index 4551d44..0e9f7f4 100644 --- a/version.php +++ b/version.php @@ -24,14 +24,14 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021093001; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2021100603; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2013110500; // Requires this Moodle version. $plugin->component = 'atto_edusharing'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = array( - 'mod_edusharing' => 2018110801 + 'mod_edusharing' => 2021100601 ); // Human readable version information. -$plugin->release = '5.0'; +$plugin->release = '6.0'; diff --git a/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-debug.js b/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-debug.js index fe201fe..e1efa75 100644 --- a/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-debug.js +++ b/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-debug.js @@ -122,8 +122,9 @@ Y.namespace('M.atto_edusharing').Button = Y.Base.create('button', Y.M.editor_att } this.addButton({ icon: 'icon', - iconComponent: 'atto_edusharing', + iconComponent: 'edusharing', buttonName: 'icon', + title: this.get('buttonTitle'), callback: this._displayDialogue, callbackArgs: 'icon', tags: '.edusharing_atto', diff --git a/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-min.js b/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-min.js index 7bb6a71..008e7c3 100644 --- a/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-min.js +++ b/yui/build/moodle-atto_edusharing-button/moodle-atto_edusharing-button-min.js @@ -1,3 +1,3 @@ -YUI.add("moodle-atto_edusharing-button",function(h,e){var d="atto_edusharing",n='
{{get_string "hint1" component}}

{{get_string "hint2" component}}
{{get_string "cancel" component}}
';function u(e){this.name="",this.object_url="",this.course=e,this.id="",this.object_version="0"}h.namespace("M.atto_edusharing").Button=h.Base.create("button",h.M.editor_atto.EditorPlugin,[],{initializer:function(){var e,i;this.get("disabled")||(this.addButton({icon:"icon",iconComponent:"atto_edusharing",buttonName:"icon",callback:this._displayDialogue,callbackArgs:"icon",tags:".edusharing_atto",tagMatchRequiresAll:!1}),(e=this.get("host").textarea.ancestor("form"))&&e.on("submit",this.eduSubmit,this),this.getExistingObjects(),i=this,window.addEventListener("message",function(e){if("APPLY_NODE"==e.data.event){var t=e.data.data;window.win.close(),i.updateDialog(t)}},!1))},getUrlVars:function(e){var n={};return e.startsWith("?")||(e="?"+e),e.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(e,t,i){n[t]=i}),n},getExistingObjects:function(){var e,t,i,n,s,r=this.get("host").textarea.get("value"),a=document.createElement("div");for(a.innerHTML=r,e=[a];0")).append(r),s.set("bodyContent",a),this.handleUpdate()||(h.one("#edusharing_hint_logo").setAttribute("src",this.get("repourl")+"/assets/images/logo.svg"),o=this,YUI().use("cookie",function(e){e.Cookie.get("edusharing_hint_hide")?(o.open_repo(),YUI().use("node",function(e){e.one("#edusharing_hint_check").setAttribute("checked","checked")})):YUI().use("node",function(e){e.one("#edusharing_hint_check").removeAttribute("checked")})})),s.show(),this.markUpdated()},_getFormContent:function(e){var t=h.Handlebars.compile(n),i=h.Node.create(t({component:d,clickedicon:e}));return this._form=i,this._form.one("#edusharing_submit").on("click",this._doInsert,this),this._form.one("#edusharing_hint_check").setAttribute("checked","checked"),this._form.one("#edusharing_hint_check").on("change",this.edusharing_hint_check_change,this),this._form.one("#edusharing_open_repo").on("click",this.open_repo,this),this._form.one("#edusharing_hint_close").on("click",this.closeDialog,this),this._form.one("#edusharing_dialog_cancel").on("click",this.closeDialog,this),this._form.one("#edusharing_width").on("change",this.recalculateDimensions,this),this._form.one("#edusharing_width").on("keyup",this.recalculateDimensions,this),this._form.one("#edusharing_height").on("change",this.recalculateDimensions,this),this._form.one("#edusharing_height").on("keyup",this.recalculateDimensions,this),this._form.one("#edusharing_title").on("keyup",this.recalculateTitleWidth,this),i},recalculateTitleWidth:function(){h.one("#edusharing_title_helper").setContent(h.one("#edusharing_title").get("value")),h.one("#edusharing_title").setStyle("width",h.one("#edusharing_title_helper").get("offsetWidth")+10+"px")},closeDialog:function(e){e.preventDefault(), -this.getDialogue({focusAfterHide:null}).hide()},open_repo:function(){var e,t,i;window.win=window.open(),window.win.document.write("Loading edu-sharing ticket..."),e=M.cfg.wwwroot+"/lib/editor/atto/plugins/edusharing/fetch.php",t=this.get("repourl"),i=this.get("courseid"),fetch(e,{method:"post",mode:"cors",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({useCase:"getTicket",courseid:i})}).then(function(e){if(200<=e.status&&e.status<300)return e.text();throw new Error(e.statusText)}).then(function(e){t+="/components/search?reurl=WINDOW&applyDirectories=true&ticket="+e,window.win.location.href=t})},recalculateDimensions:function(e){"edusharing_height"==e._currentTarget.id?h.one("#edusharing_width").set("value",Math.round(h.one("#edusharing_height").get("value")*h.one("#edusharing_ratio").get("value"))):h.one("#edusharing_height").set("value",Math.round(h.one("#edusharing_width").get("value")/h.one("#edusharing_ratio").get("value")))},edusharing_hint_check_change:function(t){YUI().use("cookie",function(e){t.target._stateProxy.checked?e.Cookie.set("edusharing_hint_hide",!0,{expires:new Date("January 12, 2025")}):e.Cookie.remove("edusharing_hint_hide")})},_doInsert:function(e){var t,i,n,s,r,a;e.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),this.editor.focus(),(t=this.getNode()).resid?((i=this.getSelectedElement()).setAttribute("title",t.title),n="","none"!=t.alignment&&(n="float:"+t.alignment),"folder"==t.mediatype&&(n="display:block;"),i.setAttribute("style",n),"ref"==this.getType(t.mediatype)?(s=new URL(i.attributes.href.value),i.innerHTML=t.title,s.searchParams.set("title",t.title),s.searchParams.set("caption",t.caption),i.setAttribute("href",s.toString())):((s=new URL(i.attributes.src.value)).searchParams.set("title",t.title),s.searchParams.set("caption",t.caption),s.searchParams.set("width",t.width),s.searchParams.set("height",t.height),i.setAttribute("alt",t.title),i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttribute("src",s.toString()))):(n="","none"!=t.alignment&&(n="float:"+t.alignment+";"),"folder"==t.mediatype&&(n="display:block;"),r="0",0==t.showlatest&&"undefined"!=t.version&&(r=t.version),a='class="edusharing_atto" style="'+n+'" title="'+t.title+'" contenteditable="false" ',s=t.previewurl+"&caption="+t.caption+"&object_url="+t.objecturl+"&mediatype="+t.mediatype+"&mimetype="+t.mimetype+"&window_version="+r+"&title="+t.title,(s=new URL(t.previewurl)).searchParams.set("caption",t.caption),s.searchParams.set("object_url",t.objecturl),s.searchParams.set("mediatype",t.mediatype),s.searchParams.set("mimetype",t.mimetype),s.searchParams.set("window_version",r),s.searchParams.set("title",t.title),"ref"==t.type?a=" '+t.title+" ":(a+='src="'+s.toString()+"&width="+t.width+"&height="+t.height+'"',a=''+t.title+'",a+="

"+t.caption+"

"),this.get("host").insertContentAtFocusPoint(a)),this.markUpdated()},getType:function(e){var t="ref";switch(!0){case-1{{get_string "hint1" component}}

{{get_string "hint2" component}}
{{get_string "cancel" component}}
';function l(e){this.name="",this.object_url="",this.course=e,this.id="",this.object_version="0"}h.namespace("M.atto_edusharing").Button=h.Base.create("button",h.M.editor_atto.EditorPlugin,[],{initializer:function(){var e,i;this.get("disabled")||(this.addButton({icon:"icon",iconComponent:"edusharing",buttonName:"icon",title:this.get("buttonTitle"),callback:this._displayDialogue,callbackArgs:"icon",tags:".edusharing_atto",tagMatchRequiresAll:!1}),(e=this.get("host").textarea.ancestor("form"))&&e.on("submit",this.eduSubmit,this),this.getExistingObjects(),i=this,window.addEventListener("message",function(e){if("APPLY_NODE"==e.data.event){var t=e.data.data;window.win.close(),i.updateDialog(t)}},!1))},getUrlVars:function(e){var n={};return e.startsWith("?")||(e="?"+e),e.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(e,t,i){n[t]=i}),n},getExistingObjects:function(){var e,t,i,n,s,r=this.get("host").textarea.get("value"),a=document.createElement("div");for(a.innerHTML=r,e=[a];0")).append(r),s.set("bodyContent",a),this.handleUpdate()||(h.one("#edusharing_hint_logo").setAttribute("src",this.get("repourl")+"/assets/images/logo.svg"),o=this,YUI().use("cookie",function(e){e.Cookie.get("edusharing_hint_hide")?(o.open_repo(),YUI().use("node",function(e){e.one("#edusharing_hint_check").setAttribute("checked","checked")})):YUI().use("node",function(e){e.one("#edusharing_hint_check").removeAttribute("checked")})})),s.show(),this.markUpdated()},_getFormContent:function(e){var t=h.Handlebars.compile(n),i=h.Node.create(t({component:d,clickedicon:e}));return this._form=i,this._form.one("#edusharing_submit").on("click",this._doInsert,this),this._form.one("#edusharing_hint_check").setAttribute("checked","checked"),this._form.one("#edusharing_hint_check").on("change",this.edusharing_hint_check_change,this),this._form.one("#edusharing_open_repo").on("click",this.open_repo,this),this._form.one("#edusharing_hint_close").on("click",this.closeDialog,this),this._form.one("#edusharing_dialog_cancel").on("click",this.closeDialog,this),this._form.one("#edusharing_width").on("change",this.recalculateDimensions,this),this._form.one("#edusharing_width").on("keyup",this.recalculateDimensions,this),this._form.one("#edusharing_height").on("change",this.recalculateDimensions,this),this._form.one("#edusharing_height").on("keyup",this.recalculateDimensions,this),this._form.one("#edusharing_title").on("keyup",this.recalculateTitleWidth,this),i},recalculateTitleWidth:function(){h.one("#edusharing_title_helper").setContent(h.one("#edusharing_title").get("value")),h.one("#edusharing_title").setStyle("width",h.one("#edusharing_title_helper").get("offsetWidth")+10+"px")}, +closeDialog:function(e){e.preventDefault(),this.getDialogue({focusAfterHide:null}).hide()},open_repo:function(){var e,t,i;window.win=window.open(),window.win.document.write("Loading edu-sharing ticket..."),e=M.cfg.wwwroot+"/lib/editor/atto/plugins/edusharing/fetch.php",t=this.get("repourl"),i=this.get("courseid"),fetch(e,{method:"post",mode:"cors",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({useCase:"getTicket",courseid:i})}).then(function(e){if(200<=e.status&&e.status<300)return e.text();throw new Error(e.statusText)}).then(function(e){t+="/components/search?reurl=WINDOW&applyDirectories=true&ticket="+e,window.win.location.href=t})},recalculateDimensions:function(e){"edusharing_height"==e._currentTarget.id?h.one("#edusharing_width").set("value",Math.round(h.one("#edusharing_height").get("value")*h.one("#edusharing_ratio").get("value"))):h.one("#edusharing_height").set("value",Math.round(h.one("#edusharing_width").get("value")/h.one("#edusharing_ratio").get("value")))},edusharing_hint_check_change:function(t){YUI().use("cookie",function(e){t.target._stateProxy.checked?e.Cookie.set("edusharing_hint_hide",!0,{expires:new Date("January 12, 2025")}):e.Cookie.remove("edusharing_hint_hide")})},_doInsert:function(e){var t,i,n,s,r,a;e.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),this.editor.focus(),(t=this.getNode()).resid?((i=this.getSelectedElement()).setAttribute("title",t.title),n="","none"!=t.alignment&&(n="float:"+t.alignment),"folder"==t.mediatype&&(n="display:block;"),i.setAttribute("style",n),"ref"==this.getType(t.mediatype)?(s=new URL(i.attributes.href.value),i.innerHTML=t.title,s.searchParams.set("title",t.title),s.searchParams.set("caption",t.caption),i.setAttribute("href",s.toString())):((s=new URL(i.attributes.src.value)).searchParams.set("title",t.title),s.searchParams.set("caption",t.caption),s.searchParams.set("width",t.width),s.searchParams.set("height",t.height),i.setAttribute("alt",t.title),i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttribute("src",s.toString()))):(n="","none"!=t.alignment&&(n="float:"+t.alignment+";"),"folder"==t.mediatype&&(n="display:block;"),r="0",0==t.showlatest&&"undefined"!=t.version&&(r=t.version),a='class="edusharing_atto" style="'+n+'" title="'+t.title+'" contenteditable="false" ',s=t.previewurl+"&caption="+t.caption+"&object_url="+t.objecturl+"&mediatype="+t.mediatype+"&mimetype="+t.mimetype+"&window_version="+r+"&title="+t.title,(s=new URL(t.previewurl)).searchParams.set("caption",t.caption),s.searchParams.set("object_url",t.objecturl),s.searchParams.set("mediatype",t.mediatype),s.searchParams.set("mimetype",t.mimetype),s.searchParams.set("window_version",r),s.searchParams.set("title",t.title),"ref"==t.type?a=" '+t.title+" ":(a+='src="'+s.toString()+"&width="+t.width+"&height="+t.height+'"',a=''+t.title+'",a+="

"+t.caption+"

"),this.get("host").insertContentAtFocusPoint(a)),this.markUpdated()},getType:function(e){var t="ref";switch(!0){case-1