Commit ce1d286a authored by Kevin Cristiano's avatar Kevin Cristiano 🌎
Browse files

Merge branch 'master' into 'master'

CiviCRM Content Block

See merge request !1
parents d7b5b38b 9c84f121
{
"presets": [
[ "env", {
"modules": false,
"targets": {
"browsers": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 iOS versions",
"last 1 Android version",
"last 1 ChromeAndroid version",
"ie 11"
]
}
} ]
],
"plugins": [
[ "transform-react-jsx", {
"pragma": "wp.element.createElement"
} ],
["transform-object-rest-spread"]
]
}
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-server-side-render'), 'version' => '2977fd9b98028bc2e469775fb450c857');
\ No newline at end of file
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t){!function(){e.exports=this.wp.element}()},function(e,t){!function(){e.exports=this.wp.i18n}()},function(e,t){!function(){e.exports=this.wp.components}()},function(e,t,n){var r=n(13),i=n(14),c=n(15);e.exports=function(e){return r(e)||i(e)||c()}},function(e,t,n){var r=n(10),i=n(11),c=n(12);e.exports=function(e,t){return r(e)||i(e,t)||c()}},function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},function(e,t){!function(){e.exports=this.wp.blocks}()},function(e,t){!function(){e.exports=this.wp.blockEditor}()},function(e,t){!function(){e.exports=this.wp.serverSideRender}()},function(e,t){function n(){return e.exports=n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}e.exports=n},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],r=!0,i=!1,c=void 0;try{for(var o,a=e[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,c=e}finally{try{r||null==a.return||a.return()}finally{if(i)throw c}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var r=n(0),i=n(1),c=n(6),o=n(7),a=n(8),l=n.n(a),u=n(4),b=n.n(u),s=n(2),f=function(e){var t=e.component,n=e.setAttributes,c=Object(r.useState)([{label:Object(i.__)("User Dashboard","civicrm"),value:"user-dashboard"},{label:Object(i.__)("Profile","civicrm"),value:"profile"},{label:Object(i.__)("Contribution Page","civicrm"),value:"contribution",component:"CiviContribute"},{label:Object(i.__)("Event Page","civicrm"),value:"event",component:"CiviEvent"},{label:Object(i.__)("Petition","civicrm"),value:"petition",component:"CiviCampaign"}]),o=b()(c,2),a=o[0],l=o[1];return Object(r.useEffect)((function(){CRM.api4("Setting","get",{select:["enable_components"]}).then((function(e){var t=e[0];if(t.value&&t.value.length){var n=a.filter((function(e){var n=t.value.includes(e.component);return!e.component||n}));l(n)}}))}),[]),Object(r.createElement)(s.SelectControl,{label:Object(i.__)("Component","civicrm"),value:t,options:a,onChange:function(e){return n({component:e})}})},v=function(e){var t=e.hijack,n=e.setAttributes;return Object(r.createElement)(s.ToggleControl,{label:Object(i.__)("Override page content"),help:Object(i.__)("If you only insert one shortcode, you can choose to override all page content with the content of the shortcode.","civicrm"),checked:t,onChange:function(){return n({hijack:!t})}})},m=n(3),p=n.n(m),O=function(e){var t=e.gid,n=e.setAttributes,c=Object(r.useState)([{label:Object(i.__)("Select a Profile","civicrm"),value:0,disabled:!0}]),o=b()(c,2),a=o[0],l=o[1];return Object(r.useEffect)((function(){CRM.api4("UFGroup","get",{select:["title","group_type"],where:[["is_active","=","1"]]}).then((function(e){if(e||e.length){var t=e.map((function(e){return{label:e.title,value:e.id}}));l([].concat(p()(a),p()(t)))}}))}),[]),Object(r.createElement)(s.SelectControl,{label:Object(i.__)("Profile","civicrm"),value:t,options:a,onChange:function(e){return n({gid:e})}})},j=function(e){var t=e.id,n=e.setAttributes,c=Object(r.useState)([{label:Object(i.__)("Select an Event","civicrm"),value:0,disabled:!0}]),o=b()(c,2),a=o[0],l=o[1];return Object(r.useEffect)((function(){CRM.api4("Event","get",{select:["title","summary","event_type.label","start_date","end_date"],where:[["is_active","=","1"],["is_template","=","0"]]}).then((function(e){if(e||e.length){var t=e.map((function(e){return{label:e.title,value:e.id}}));l([].concat(p()(a),p()(t)))}}))}),[]),Object(r.createElement)(s.SelectControl,{label:Object(i.__)("Event Page","civicrm"),value:t,options:a,onChange:function(e){return n({id:e})}})},d=function(e){var t=e.id,n=e.setAttributes,c=Object(r.useState)([{label:Object(i.__)("Select a Contribution page","civicrm"),value:"0",disabled:!0}]),o=b()(c,2),a=o[0],l=o[1];return Object(r.useEffect)((function(){CRM.api4("ContributionPage","get",{select:["title","intro_text"],where:[["is_active","=","1"]]}).then((function(e){if(e||e.length){var t=e.map((function(e){return{label:e.title,value:e.id}}));l([].concat(p()(a),p()(t)))}}))}),[]),Object(r.createElement)(s.SelectControl,{label:Object(i.__)("Contribution Page","civicrm"),value:t,options:a,onChange:function(e){return n({id:e})}})},_=function(e){var t=e.mode,n=e.setAttributes,c=[{label:Object(i.__)("Create","civicrm"),value:"create"},{label:Object(i.__)("Edit","civicrm"),value:"edit"},{label:Object(i.__)("View","civicrm"),value:"view"},{label:Object(i.__)("Search/Public Directory","civicrm"),value:"search"}];return Object(r.createElement)(s.RadioControl,{label:Object(i.__)("Mode","civicrm"),value:t,options:c,selected:t||"create",onChange:function(e){return n({mode:e})}})},g=function(e){var t=e.mode,n=e.setAttributes,c=[{label:Object(i.__)("Live Mode","civicrm"),value:"live"},{label:Object(i.__)("Test Mode","civicrm"),value:"test"}];return Object(r.createElement)(s.RadioControl,{label:Object(i.__)("Mode","civicrm"),value:t,options:c,selected:t||"live",onChange:function(e){return n({mode:e})}})},y=function(e){var t=e.action,n=e.setAttributes,c=[{label:Object(i.__)("Event Info Page","civicrm"),value:"info"},{label:Object(i.__)("Event Registration Page","civicrm"),value:"register"}];return Object(r.createElement)(s.RadioControl,{label:Object(i.__)("Action","civicrm"),value:t,options:c,selected:t||"info",onChange:function(e){return n({action:e})}})},h=n(9),E=n.n(h),C=n(5),x=n.n(C);function A(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var w=function(e){var t=e.attribute,n=e.index,c=e.extra_attributes,o=e.setAttributes,a=function(e){var r=p()(c);r[n]=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A(Object(n),!0).forEach((function(t){x()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,x()({},e.target.name,e.target.value)),o({extra_attributes:p()(r)})};return Object(r.createElement)(r.Fragment,null,Object(r.createElement)("strong",null,Object(i.__)("Attribute","civicrm")," ",n+1),Object(r.createElement)(s.BaseControl,{label:Object(i.__)("Attribute name","civicrm")},Object(r.createElement)("input",{className:"components-text-control__input",type:"text",name:"name",value:t.name,onChange:a})),Object(r.createElement)(s.BaseControl,{label:Object(i.__)("Attribute value","civicrm")},Object(r.createElement)("input",{className:"components-text-control__input",type:"text",name:"value",value:t.value,onChange:a})),Object(r.createElement)(s.IconButton,{icon:"trash",onClick:function(){return(e=p()(c)).splice(n,1),void o({extra_attributes:p()(e)});var e}},Object(i.__)("Delete attribute","civicrm")," ",n+1),Object(r.createElement)("hr",null))},P=function(e){var t=e.extra_attributes,n=e.setAttributes;return Object(r.createElement)(s.PanelBody,{title:Object(i.__)("Extra attributes","civicrm"),initialOpen:!1},Object(r.createElement)(s.PanelRow,null,Object(r.createElement)(s.IconButton,{icon:"insert",isDefault:!0,isLarge:!0,onClick:function(){n({extra_attributes:[].concat(p()(t),[{name:"",value:""}])})}},Object(i.__)("Add attribute","civicrm"))),t.length?t.map((function(e,i){return Object(r.createElement)(w,E()({key:i},{attribute:e,index:i,extra_attributes:t,setAttributes:n}))})):"")},S=function(e){var t=e.attributes,n=e.setAttributes,c=t.component,a=t.gid,u=t.id,b=t.mode,s=t.action,m=t.hijack,p=t.extra_attributes,h=["live","test"];switch(c){case"profile":E=Object(r.createElement)(O,{gid:a,setAttributes:n}),["create","edit","view","search"].includes(b)||n({mode:"create"});break;case"event":E=Object(r.createElement)(j,{id:u,setAttributes:n}),h.includes(b)||n({mode:"live"});break;case"contribution":E=Object(r.createElement)(d,{id:u,setAttributes:n}),h.includes(b)||n({mode:"live"})}var E,C=Object(r.createElement)(_,{mode:b,setAttributes:n}),x=Object(r.createElement)(g,{mode:b,setAttributes:n}),A=Object(r.createElement)(y,{action:s,setAttributes:n});return Object(r.createElement)(r.Fragment,null,Object(r.createElement)(o.InspectorControls,{key:"inspector"},Object(r.createElement)(f,{component:c,setAttributes:n}),E,"profile"==c?C:"","event"==c?A:"",["event","contribution"].includes(c)?x:"",Object(r.createElement)(v,{hijack:m,setAttributes:n}),Object(r.createElement)(P,{extra_attributes:p,setAttributes:n})),Object(r.createElement)("p",null,Object(i.__)("CiviCRM content block","civicrm")),Object(r.createElement)(l.a,{block:"civicrm/civicrm-content-block",attributes:t}))};Object(c.registerBlockType)("civicrm/civicrm-content-block",{title:Object(i.__)("CiviCRM Content","civicrm"),icon:"megaphone",category:"layout",attributes:{component:{type:"string",default:"profile"},gid:{type:"string",default:"1"},id:{type:"string"},mode:{type:"string",default:"create"},action:{type:"string",default:"info"},hijack:{type:"boolean",default:!1},extra_attributes:{type:"array",default:[]}},edit:function(e){var t=e.attributes,n=e.setAttributes;return Object(r.createElement)(S,{attributes:t,setAttributes:n})},save:function(e){return null}})}]);
\ No newline at end of file
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/@babel/runtime/helpers/arrayWithHoles.js","webpack:///./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","webpack:///./node_modules/@babel/runtime/helpers/defineProperty.js","webpack:///./node_modules/@babel/runtime/helpers/extends.js","webpack:///./node_modules/@babel/runtime/helpers/iterableToArray.js","webpack:///./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","webpack:///./node_modules/@babel/runtime/helpers/nonIterableRest.js","webpack:///./node_modules/@babel/runtime/helpers/nonIterableSpread.js","webpack:///./node_modules/@babel/runtime/helpers/slicedToArray.js","webpack:///./node_modules/@babel/runtime/helpers/toConsumableArray.js","webpack:///./src/assets/blocks/civicrm-content/CiviCRMContentBlock.js","webpack:///./src/assets/blocks/civicrm-content/components/ActionControl.js","webpack:///./src/assets/blocks/civicrm-content/components/ComponentControl.js","webpack:///./src/assets/blocks/civicrm-content/components/ExtraAttributeItemControl.js","webpack:///./src/assets/blocks/civicrm-content/components/ExtraAttributesListControl.js","webpack:///./src/assets/blocks/civicrm-content/components/HijackControl.js","webpack:///./src/assets/blocks/civicrm-content/components/ModeControl.js","webpack:///./src/assets/blocks/civicrm-content/components/ProfileModeControl.js","webpack:///./src/assets/blocks/civicrm-content/components/SelectContributionPageControl.js","webpack:///./src/assets/blocks/civicrm-content/components/SelectEventControl.js","webpack:///./src/assets/blocks/civicrm-content/components/SelectProfileControl.js","webpack:///./src/assets/blocks/civicrm-content/index.js","webpack:///./src/assets/blocks/index.js","webpack:///external {\"this\":[\"wp\",\"blockEditor\"]}","webpack:///external {\"this\":[\"wp\",\"blocks\"]}","webpack:///external {\"this\":[\"wp\",\"components\"]}","webpack:///external {\"this\":[\"wp\",\"element\"]}","webpack:///external {\"this\":[\"wp\",\"i18n\"]}","webpack:///external {\"this\":[\"wp\",\"serverSideRender\"]}"],"names":["CiviCRMContentBlock","attributes","setAttributes","component","gid","id","mode","action","hijack","extra_attributes","profileModes","pageModes","selectControl","includes","profileModeControl","modeControl","actionControl","__","ActionControl","onChangeAction","options","label","value","ComponentControl","onChangeComponent","useState","components","setComponents","useEffect","CRM","api4","select","then","result","setting","length","filteredComponents","filter","isEnabled","ExtraAttributeItemControl","attribute","index","updateAttribute","e","newAttrs","target","name","deleteAttribute","splice","ExtraAttributesListControl","addAttribute","map","HijackControl","onChangeHijack","ModeControl","onChangeMode","ProfileModeControl","SelectContributionPageControl","onChangeContributionPage","disabled","contributionPages","setConstributionPages","where","page","title","SelectEventControl","onChangeEvent","events","setEvents","event","SelectProfileControl","onChangeProfile","profiles","setProfiles","ufGroup","registerBlockType","icon","category","type","default","edit","save","props"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;Q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;AAgBXxE,UAAM,EAAE;AACPuE,UAAI,EAAE,QADC;AAEPC,aAAO,EAAE;AAFF,KAhBG;AAoBXvE,UAAM,EAAE;AACPsE,UAAI,EAAE,SADC;AAEPC,aAAO,EAAE;AAFF,KApBG;AAwBXtE,oBAAgB,EAAE;AACjBqE,UAAI,EAAE,OADW;AAEjBC,aAAO,EAAE;AAFQ;AAxBP,GAJsC;AAiClDC,MAAI,EAAE;AAAA,QAAG/E,UAAH,QAAGA,UAAH;AAAA,QAAeC,aAAf,QAAeA,aAAf;AAAA,WACL,yEAAC,4DAAD,EAAyB;AAACD,gBAAU,EAAVA,UAAD;AAAaC,mBAAa,EAAbA;AAAb,KAAzB,CADK;AAAA,GAjC4C;AAoChD+E,MAAI,EAAE,cAACC,KAAD,EAAW;AAClB,WAAO,IAAP;AACE;AAtC+C,CAAlC,CAAjB,C;;;;;;;;;;;;ACLA;AAAA;;;;;;;;;;;;ACAA,aAAa,4CAA4C,EAAE,I;;;;;;;;;;;ACA3D,aAAa,uCAAuC,EAAE,I;;;;;;;;;;;ACAtD,aAAa,2CAA2C,EAAE,I;;;;;;;;;;;ACA1D,aAAa,wCAAwC,EAAE,I;;;;;;;;;;;ACAvD,aAAa,qCAAqC,EAAE,I;;;;;;;;;;;ACApD,aAAa,iDAAiD,EAAE,I","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/assets/blocks/index.js\");\n","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles;","function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}\n\nmodule.exports = _arrayWithoutHoles;","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty;","function _extends() {\n module.exports = _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nmodule.exports = _extends;","function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray;","function _iterableToArrayLimit(arr, i) {\n if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) {\n return;\n }\n\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}\n\nmodule.exports = _nonIterableRest;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}\n\nmodule.exports = _nonIterableSpread;","var arrayWithHoles = require(\"./arrayWithHoles\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit\");\n\nvar nonIterableRest = require(\"./nonIterableRest\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray;","var arrayWithoutHoles = require(\"./arrayWithoutHoles\");\n\nvar iterableToArray = require(\"./iterableToArray\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray;","import { __ } from '@wordpress/i18n'\nimport { InspectorControls } from '@wordpress/block-editor'\nimport ServerSideRender from '@wordpress/server-side-render'\n\nimport ComponentControl from './components/ComponentControl'\nimport HijackControl from './components/HijackControl'\nimport SelectProfileControl from './components/SelectProfileControl'\nimport SelectEventControl from './components/SelectEventControl'\nimport SelectContributionPageControl from './components/SelectContributionPageControl'\nimport ProfileModeControl from './components/ProfileModeControl'\nimport ModeControl from './components/ModeControl'\nimport ActionControl from './components/ActionControl'\nimport ExtraAttributesListControl from './components/ExtraAttributesListControl'\n\nconst CiviCRMContentBlock = ({ attributes, setAttributes }) => {\n\tconst { component, gid, id, mode, action, hijack, extra_attributes } = attributes\n\tconst profileModes = ['create', 'edit', 'view', 'search']\n\tconst pageModes = ['live', 'test']\n\n\tswitch (component) {\n\t\tcase 'profile':\n\t\t\tselectControl = <SelectProfileControl {...{ gid, setAttributes }} />\n\t\t\tif (!profileModes.includes(mode)) setAttributes({ mode: 'create' })\n\t\t\tbreak\n\n\t\tcase 'event':\n\t\t\tselectControl = <SelectEventControl {...{ id, setAttributes }} />\n\t\t\tif (!pageModes.includes(mode)) setAttributes({ mode: 'live' })\n\t\t\tbreak\n\n\t\tcase 'contribution':\n\t\t\tselectControl = <SelectContributionPageControl {...{ id, setAttributes }} />\n\t\t\tif (!pageModes.includes(mode)) setAttributes({ mode: 'live' })\n\t\t\tbreak\n\t}\n\n\tlet selectControl,\n\t\tprofileModeControl = <ProfileModeControl {...{ mode, setAttributes }} />,\n\t\tmodeControl = <ModeControl {...{ mode, setAttributes }} />,\n\t\tactionControl = <ActionControl {...{ action, setAttributes }} />\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls key='inspector'>\n\t\t\t\t<ComponentControl {...{ component, setAttributes }} />\n\t\t\t\t{selectControl}\n\t\t\t\t{component == 'profile' ? profileModeControl : ''}\n\t\t\t\t{component == 'event' ? actionControl : ''}\n\t\t\t\t{['event', 'contribution'].includes(component) ? modeControl : ''}\n\t\t\t\t<HijackControl {...{ hijack, setAttributes }} />\n\t\t\t\t<ExtraAttributesListControl {...{ extra_attributes, setAttributes }} />\n\t\t\t</InspectorControls>\n\t\t\t<p>{__('CiviCRM content block', 'civicrm')}</p>\n\t\t\t<ServerSideRender\n\t\t\t\tblock='civicrm/civicrm-content-block'\n\t\t\t\tattributes={attributes}\n\t\t\t/>\n\t\t</>\n\t)\n}\n\nexport default CiviCRMContentBlock\n","import { __ } from '@wordpress/i18n'\nimport { RadioControl } from '@wordpress/components'\n\nconst ActionControl = ({action, setAttributes}) => {\n\tconst onChangeAction = action => setAttributes({ action })\n \tconst options = [\n\t\t{ label: __('Event Info Page', 'civicrm'), value: 'info' },\n\t\t{ label: __('Event Registration Page', 'civicrm'), value: 'register' },\n \t]\n\n \treturn <RadioControl\n\t\tlabel={__('Action', 'civicrm')}\n\t\tvalue={action}\n\t\toptions={options}\n\t\tselected={action || 'info'}\n\t\tonChange={onChangeAction}\n \t/>\n}\n\nexport default ActionControl\n","import { __ } from '@wordpress/i18n'\nimport { useState, useEffect } from \"@wordpress/element\";\nimport { SelectControl } from '@wordpress/components'\n\nconst ComponentControl = ({ component, setAttributes }) => {\n\tconst onChangeComponent = component => setAttributes({ component })\n\n\tconst [components, setComponents] = useState([\n\t\t{ label: __('User Dashboard', 'civicrm'), value: 'user-dashboard' },\n\t\t{ label: __('Profile', 'civicrm'), value: 'profile' },\n\t\t{ label: __('Contribution Page', 'civicrm'), value: 'contribution', component: 'CiviContribute' },\n\t\t{ label: __('Event Page', 'civicrm'), value: 'event', component: 'CiviEvent' },\n\t\t{ label: __('Petition', 'civicrm'), value: 'petition', component: 'CiviCampaign' },\n\t])\n\n\tuseEffect(() => {\n\t\tCRM.api4('Setting', 'get', {\n\t\t\tselect: ['enable_components']\n\t\t})\n\t\t.then(function(result) {\n\t\t\tconst setting = result[0]\n\t\t\tif (!setting.value || !setting.value.length) return;\n\n\t\t\tconst filteredComponents = components.filter(component => {\n\t\t\t\tconst isEnabled = setting.value.includes(\n\t\t\t\t\tcomponent.component\n\t\t\t\t);\n\t\t\t\treturn !component.component || isEnabled;\n\t\t\t});\n\n\t\t\tsetComponents(filteredComponents)\n\t\t})\n\t}, [])\n\n\treturn <SelectControl\n\t\tlabel={__('Component', 'civicrm')}\n\t\tvalue={component}\n\t\toptions={components}\n\t\tonChange={onChangeComponent}\n \t/>\n}\n\nexport default ComponentControl\n","import { __ } from '@wordpress/i18n'\nimport { BaseControl, IconButton } from '@wordpress/components'\n\nconst ExtraAttributeItemControl = ({ attribute, index, extra_attributes, setAttributes }) => {\n\n\tconst updateAttribute = e => {\n\t\tconst newAttrs = [...extra_attributes]\n\t\tnewAttrs[index] = {\n\t\t\t...attribute,\n\t\t\t[e.target.name]: e.target.value\n\t\t}\n\t\tsetAttributes({\n\t\t\textra_attributes: [...newAttrs]\n\t\t})\n\t}\n\n\tconst deleteAttribute = () => {\n\t\tconst newAttrs = [...extra_attributes]\n\t\tnewAttrs.splice(index, 1)\n\t\tsetAttributes({\n\t\t\textra_attributes: [...newAttrs]\n\t\t})\n\t}\n\n\treturn <>\n\t\t<strong>{__('Attribute', 'civicrm')} {index + 1}</strong>\n\t\t<BaseControl label={__('Attribute name', 'civicrm')}>\n\t\t\t<input\n\t\t\t\tclassName='components-text-control__input'\n\t\t\t\ttype='text'\n\t\t\t\tname='name'\n\t\t\t\tvalue={attribute.name}\n\t\t\t\tonChange={updateAttribute}\n\t\t\t/>\n\t\t</BaseControl>\n\t\t<BaseControl label={__('Attribute value', 'civicrm')}>\n\t\t\t<input\n\t\t\t\tclassName='components-text-control__input'\n\t\t\t\ttype='text'\n\t\t\t\tname='value'\n\t\t\t\tvalue={attribute.value}\n\t\t\t\tonChange={updateAttribute}\n\t\t\t/>\n\t\t</BaseControl>\n\t\t<IconButton icon='trash' onClick={() => deleteAttribute()}>\n\t\t\t{__('Delete attribute', 'civicrm')} {index + 1}\n\t\t</IconButton>\n\t\t<hr />\n\t</>\n}\n\nexport default ExtraAttributeItemControl\n","import { __ } from '@wordpress/i18n'\nimport { PanelBody, PanelRow, IconButton } from '@wordpress/components'\nimport ExtraAttributeItemControl from './ExtraAttributeItemControl'\n\nconst ExtraAttributesListControl = ({ extra_attributes, setAttributes }) => {\n\n\tconst addAttribute = () => {\n\t\tsetAttributes({\n\t\t\textra_attributes: [\n\t\t\t\t...extra_attributes,\n\t\t\t\t{\n\t\t\t\t\tname: '',\n\t\t\t\t\tvalue: ''\n\t\t\t\t}\n\t\t\t]\n\t\t})\n\t}\n\n\treturn <PanelBody title={__('Extra attributes', 'civicrm')} initialOpen={false}>\n\t\t<PanelRow>\n\t\t\t<IconButton icon=\"insert\" isDefault isLarge onClick={addAttribute}>\n\t\t\t\t{__('Add attribute', 'civicrm')}\n\t\t\t</IconButton>\n\t\t</PanelRow>\n\t\t{\n\t\t\textra_attributes.length\n\t\t\t\t? extra_attributes.map(\n\t\t\t\t\t(attribute, index) => <ExtraAttributeItemControl\n\t\t\t\t\t\tkey={index}\n\t\t\t\t\t\t{...{attribute, index, extra_attributes, setAttributes}}\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t\t: ''\n\t\t}\n\t</PanelBody>\n}\n\nexport default ExtraAttributesListControl\n","import { __ } from '@wordpress/i18n'\nimport { ToggleControl } from '@wordpress/components'\n\nconst HijackControl = ({ hijack, setAttributes }) => {\n\tconst onChangeHijack = () => setAttributes({ hijack: !hijack })\n \treturn <ToggleControl\n\t\tlabel={__('Override page content')}\n\t\thelp={__('If you only insert one shortcode, you can choose to override all page content with the content of the shortcode.', 'civicrm')}\n\t\tchecked={hijack}\n\t\tonChange={onChangeHijack}\n \t/>\n}\n\nexport default HijackControl\n","import { __ } from '@wordpress/i18n'\nimport { RadioControl } from '@wordpress/components'\n\nconst ModeControl = ({ mode, setAttributes }) => {\n\tconst onChangeMode = mode => setAttributes({ mode })\n \tconst options = [\n\t\t{ label: __('Live Mode', 'civicrm'), value: 'live' },\n\t\t{ label: __('Test Mode', 'civicrm'), value: 'test' },\n \t]\n\n \treturn <RadioControl\n\t\tlabel={__('Mode', 'civicrm')}\n\t\tvalue={mode}\n\t\toptions={options}\n\t\tselected={mode || 'live'}\n\t\tonChange={onChangeMode}\n \t/>\n}\n\nexport default ModeControl\n","import { __ } from '@wordpress/i18n'\nimport { RadioControl } from '@wordpress/components'\n\nconst ProfileModeControl = ({ mode, setAttributes }) => {\n\tconst onChangeMode = mode => setAttributes({ mode })\n \tconst options = [\n\t\t{ label: __('Create', 'civicrm'), value: 'create' },\n\t\t{ label: __('Edit', 'civicrm'), value: 'edit' },\n\t\t{ label: __('View', 'civicrm'), value: 'view' },\n\t\t{ label: __('Search/Public Directory', 'civicrm'), value: 'search' },\n \t]\n\n \treturn <RadioControl\n\t\tlabel={__('Mode', 'civicrm')}\n\t\tvalue={mode}\n\t\toptions={options}\n\t\tselected={mode || 'create'}\n\t\tonChange={onChangeMode}\n \t/>\n}\n\nexport default ProfileModeControl\n","import { __ } from '@wordpress/i18n'\nimport { useState, useEffect } from '@wordpress/element'\nimport { SelectControl } from '@wordpress/components'\n\nconst SelectContributionPageControl = ({ id, setAttributes }) => {\n\tconst onChangeContributionPage = id => setAttributes({ id })\n\n\tconst [ contributionPages, setConstributionPages ] = useState([{\n\t\tlabel: __('Select a Contribution page', 'civicrm'),\n\t\tvalue: '0',\n\t\tdisabled: true\n \t}])\n\n \tuseEffect(() => {\n \tCRM.api4('ContributionPage', 'get', {\n\t\t\tselect: ['title', 'intro_text'],\n\t\t\twhere: [['is_active', '=', '1']]\n\t\t})\n\t\t.then((result) => {\n\t\t\tif (!result && !result.length) return;\n\n\t\t\tconst options = result.map(page => ({\n\t\t\t\tlabel: page.title,\n\t\t\t\tvalue: page.id\n\t\t\t}))\n\n\t\t\tsetConstributionPages([\n\t\t\t\t...contributionPages,\n\t\t\t\t...options\n\t\t\t])\n\t\t})\n \t}, [])\n\n \treturn <SelectControl\n\t\tlabel={__('Contribution Page', 'civicrm')}\n\t\tvalue={id}\n\t\toptions={contributionPages}\n\t\tonChange={onChangeContributionPage}\n\t/>\n}\n\nexport default SelectContributionPageControl\n","import { __ } from '@wordpress/i18n'\nimport { useState, useEffect } from '@wordpress/element'\nimport { SelectControl } from '@wordpress/components'\n\nconst SelectEventControl = ({ id, setAttributes }) => {\n\tconst onChangeEvent = id => setAttributes({ id })\n\n\tconst [events, setEvents] = useState([{\n\t\tlabel: __('Select an Event', 'civicrm'),\n\t\tvalue: 0,\n\t\tdisabled: true\n \t}])\n\n \tuseEffect(() => {\n\t\tCRM.api4('Event', 'get', {\n\t\t\tselect: ['title', 'summary', 'event_type.label', 'start_date', 'end_date'],\n\t\t\twhere: [\n\t\t\t\t['is_active', '=', '1'],\n\t\t\t\t['is_template', '=', '0']\n\t\t\t]\n\t\t})\n\t\t.then((result) => {\n\t\t\tif (!result && !result.length) return;\n\n\t\t\tconst options = result.map(event => ({\n\t\t\t\tlabel: event.title,\n\t\t\t\tvalue: event.id\n\t\t\t}))\n\n\t\t\tsetEvents([\n\t\t\t\t...events,\n\t\t\t\t...options\n\t\t\t])\n\t\t})\n \t}, [])\n\n \treturn <SelectControl\n\t\tlabel={__('Event Page', 'civicrm')}\n\t\tvalue={id}\n\t\toptions={events}\n\t\tonChange={onChangeEvent}\n \t/>\n}\n\nexport default SelectEventControl\n","import { __ } from '@wordpress/i18n'\nimport { useState, useEffect } from '@wordpress/element'\nimport { SelectControl } from '@wordpress/components'\n\nconst SelectProfileControl = ({ gid, setAttributes }) => {\n\tconst onChangeProfile = gid => setAttributes({ gid })\n\n \tconst [profiles, setProfiles] = useState([{\n\t\tlabel: __('Select a Profile', 'civicrm'),\n\t\tvalue: 0,\n\t\tdisabled: true\n \t}])\n\n \tuseEffect(() => {\n \tCRM.api4('UFGroup', 'get', {\n\t\t\tselect: ['title', 'group_type'],\n\t\t\twhere: [['is_active', '=', '1']]\n\t\t})\n\t\t.then((result) => {\n\t\t\tif (!result && !result.length) return;\n\n\t\t\tconst options = result.map(ufGroup => ({\n\t\t\t\tlabel: ufGroup.title,\n\t\t\t\tvalue: ufGroup.id\n\t\t\t}))\n\t\t\tsetProfiles([\n\t\t\t\t...profiles,\n\t\t\t\t...options\n\t\t\t])\n\t\t})\n \t}, [])\n\n \treturn <SelectControl\n\t\tlabel={__('Profile', 'civicrm')}\n\t\tvalue={gid}\n\t\toptions={profiles}\n\t\tonChange={onChangeProfile}\n \t/>\n}\n\nexport default SelectProfileControl\n","import { __ } from '@wordpress/i18n'\nimport { registerBlockType } from '@wordpress/blocks'\n\nimport CiviCRMContentBlock from './CiviCRMContentBlock'\n\nregisterBlockType('civicrm/civicrm-content-block', {\n\ttitle: __('CiviCRM Content', 'civicrm'),\n\ticon: 'megaphone',\n\tcategory: 'layout',\n\tattributes: {\n\t\tcomponent: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'profile',\n\t\t},\n\t\tgid: {\n\t\t\ttype: 'string',\n\t\t\tdefault: '1',\n\t\t},\n\t\tid: {\n\t\t\ttype: 'string',\n\t\t},\n\t\tmode: {\n\t\t\t type: 'string',\n\t\t\t default: 'create',\n\t\t},\n\t\taction: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'info',\n\t\t},\n\t\thijack: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\textra_attributes: {\n\t\t\ttype: 'array',\n\t\t\tdefault: [],\n\t\t},\n \t},\n\tedit: ({ attributes, setAttributes }) => (\n\t\t<CiviCRMContentBlock {...{attributes, setAttributes}} />\n\t),\n \tsave: (props) => {\n\t\treturn null\n \t}\n});\n","import './civicrm-content'\n","(function() { module.exports = this[\"wp\"][\"blockEditor\"]; }());","(function() { module.exports = this[\"wp\"][\"blocks\"]; }());","(function() { module.exports = this[\"wp\"][\"components\"]; }());","(function() { module.exports = this[\"wp\"][\"element\"]; }());","(function() { module.exports = this[\"wp\"][\"i18n\"]; }());","(function() { module.exports = this[\"wp\"][\"serverSideRender\"]; }());"],"sourceRoot":""}
\ No newline at end of file
......@@ -55,71 +55,14 @@ class CiviCRM_Gutenberg_Blocks {
// Init block and shortcode.
add_action( 'init', array( $this, 'block_init' ) );
// Check content.
//add_filter( 'the_content', array( $this, 'the_content' ), 1 );
// render block preview
add_filter( 'rest_post_dispatch', [ $this, 'render_block_preview' ], 10, 3);
// Add API endpoint.
add_action( 'rest_api_init', array( $this, 'user_roles' ) );
// convert serialised civicrm content blocks to shortcode
add_action( 'wp', [ $this, 'prerender' ], 5 );
}
/**
* Register REST API route.
*
* @since 0.1
*/
public function user_roles() {
// Register route.
register_rest_route(
'civicrm/civicrm-profile-block/v1',
'/user-roles',
array(
'methods' => 'GET',
'callback' => array( $this, 'get_user_roles' ),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
)
);
}
/**
* Get the user roles.
*
* @since 0.1
*
* @return array $roles JSON feed of returned objects.
*/
public function get_user_roles() {
global $wp_roles;
$roles = array();
$user_roles = $wp_roles->roles;
foreach ( $user_roles as $key => $role ) {
$roles[] = array(
'value' => $key,
'label' => $role['name'],
);
}
$e = new Exception;
$trace = $e->getTraceAsString();
error_log( print_r( array(
'method' => __METHOD__,
'roles' => $roles,
//'backtrace' => $trace,
), true ) );
// --<
return $roles;
// add civicrm core resources
add_action( 'admin_head', [ $this, 'maybe_add_core_resources' ], 20 );
}
......@@ -151,61 +94,60 @@ class CiviCRM_Gutenberg_Blocks {
// Register our block editor script.
wp_register_script(
'civicrm-profile-block',
plugins_url( 'assets/js/civicrm-profile-block.build.js', CIVICRM_GUTENBERG_BLOCKS_PLUGIN_FILE ),
array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wp-i18n' )
'civicrm-gutenberg-blocks',
plugins_url( 'build/index.js', CIVICRM_GUTENBERG_BLOCKS_PLUGIN_FILE ),
[ 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wp-i18n' ],
filemtime( CIVICRM_GUTENBERG_BLOCKS_PLUGIN_PATH . 'build/index.js' )
);
// Register our block, and explicitly define the attributes we accept.
register_block_type( 'civicrm/civicrm-profile-block', array(
'attributes' => array(
'component' => array(
register_block_type( 'civicrm/civicrm-content-block', [
'attributes' => [
'component' => [
'type' => 'string',
'default' => 'profile',
),
'gid' => array(
],
'gid' => [
'type' => 'string',
'default' => '1',
],
'id' => [
'type' => 'string',
'default' => '1',
),
'mode' => array(
],
'mode' => [
'type' => 'string',
'enum' => array( 'test', 'live' ),
'default' => 'test',
),
'hijack' => array(
'enum' => [ 'test', 'live', 'create', 'edit', 'view', 'search' ],
'default' => 'live',
],
'action' => [
'type' => 'string',
'enum' => [ 'info', 'register' ],
'default' => 'info',
],
'hijack' => [
'type' => 'boolean',
'default' => false,
),
),
'editor_script' => 'civicrm-profile-block', // The script name we gave in the wp_register_script() call.
'render_callback' => array( $this, 'block_render' ),
) );
/*
// Pass translations to our JavaScript.
],
'extra_attributes' => [
'type' => 'array',
'default' => [],
],
],
'editor_script' => 'civicrm-gutenberg-blocks', // The script name we gave in the wp_register_script() call.
'render_callback' => [ $this, 'block_render' ],
] );
/**
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
*/
wp_set_script_translations(
'civicrm-profile-block',
'civicrm-gutenberg-blocks',
'civicrm-gutenberg-blocks',
plugin_dir_path( CIVICRM_GUTENBERG_BLOCKS_PLUGIN_FILE ) . 'languages'
);
*/
// Encode translations.
$translations = json_encode( gutenberg_get_jed_locale_data( 'civicrm-gutenberg-blocks' ) );
/*
* Pass already loaded translations to our JavaScript.
*
* This happens *before* our JavaScript runs, afterwards it's too late.
*/
wp_add_inline_script(
'civicrm-profile-block',
'wp.i18n.setLocaleData( ' . $translations . ', "civicrm-gutenberg-blocks" );',
'before'
);
// Define our shortcode, too, using the same render function as the block.
//add_shortcode( 'civicrm_block', array( $this, 'block_render' ) );
}
......@@ -221,9 +163,21 @@ class CiviCRM_Gutenberg_Blocks {
*
* @param array $attributes The attributes that were set on the block or shortcode.
*/
public function block_render( $attributes = array() ) {
public function block_render( $attributes = [] ) {
$attributes = $this->clenup_and_set_default_attributes( $attributes );
$pairs = array();
// add extra attributes
if ( ! empty( $attributes['extra_attributes'] ) ) {
foreach ( $attributes['extra_attributes'] AS $attr ) {
if ( empty( $attr['value'] ) ) continue;
$attributes[$attr['name']] = $attr['value'];
}
}
unset( $attributes['extra_attributes'] );
$pairs = [];
foreach( $attributes AS $key => $value ) {
$pairs[] = esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
}
......@@ -237,24 +191,358 @@ class CiviCRM_Gutenberg_Blocks {
/**
* Check content for rendering.
* Filters the block-renderer route response
* and renders the civicrm content block preview.
*
* @uses 'rest_post_dispatch' filter
*
* @since 1.0
*
* @param WP_REST_Response $response
* @param WP_REST_Server $server
* @param WP_REST_Request $request
* @return WP_REST_Response $response
*/
public function render_block_preview( $response, WP_REST_Server $server, WP_REST_Request $request ) {
if ( ! strpos( $request->get_route(), 'civicrm/civicrm-content-block' ) ) {
return $response;
}
$response->set_data( [
'rendered' => $this->get_block_preview( $request->get_param( 'attributes' ) )
] );
return $response;
}
/**
* Retreives CiviCRM's content block html preview.
*
* @since 1.0
*
* @param array $atts The block attributes
* @return string $html
*/
public function get_block_preview( array $atts ) {
switch ( $atts['component'] ) {
case 'profile':
return $this->render_profile( $atts );
break;
case 'contribution':
return $this->render_contribution_page( $atts );
break;
case 'event':
return $this->render_event_page( $atts );
break;
case 'user-dashboard':
return $this->render_user_dashboard( $atts );
break;
}
}
/**
* Renders a profile's html.
*
* @since 0.1
*
* @param array $atts The block attributes
* @return string $html
*/
public function render_profile( array $atts ) {
if ( empty( $atts['gid'] ) ) return '';
$args = [
'civicrm',
'profile',
$atts['mode']
];
$_REQUEST['gid'] = $atts['gid'];
ob_start();
( new CRM_Profile_Page_Router )->run( $args );
return ob_get_clean();
}
/**
* Renders a contribution's page html.
*
* @since 0.1
*
* @param array $atts The block attributes
* @return string $html
*/
public function render_contribution_page( array $atts ) {
if ( empty( $atts['id'] ) ) return '';
$_REQUEST['id'] = $atts['id'];
ob_start();
( new CRM_Contribute_Controller_Contribution(
'CiviContribute',
CRM_Core_Action::ADD
) )->run();
return ob_get_clean();
}
/**
* Renders an event's page html.
*
* @since 0.1
*
* @param str $content The content.
* @return str $content The content.
* @param array $atts The block attributes
* @return string $content
*/
public function the_content( $content ) {
public function render_event_page( array $atts ) {
$e = new Exception;
$trace = $e->getTraceAsString();
error_log( print_r( array(
'method' => __METHOD__,
'content' => $content,
//'backtrace' => $trace,
), true ) );
if ( empty( $atts['id'] ) ) return '';
return $content;
$_REQUEST['id'] = $atts['id'];
ob_start();
if ( $atts['action'] == 'register' ) {
( new CRM_Event_Controller_Registration() )->run();
} else {
( new CRM_Event_Page_EventInfo )->run();
}
return ob_get_clean();
}
/**
* Renders the user dashboard html.
*
* @since 0.1
*
* @param array $atts The block attributes
* @return string $html
*/
public function render_user_dashboard( array $atts ) {
ob_start();
( new CRM_Contact_Page_View_UserDashBoard() )->run();
return ob_get_clean();
}
/**
* Determine if a CiviCRM block is present
* in any of the posts about to be displayed
* and replace the serialised block string
* with it's shortcode version.
*
* Based on CiviCRM_For_WordPress_Shortcodes::prerender().
*
* @uses 'wp' action
*
* @since 0.1
*
* @return void
*/
public function prerender() {
if ( is_404() ) return;
if ( have_posts() ) {
while ( have_posts() ) : the_post();
global $post;
$post = $this->convert_serialised_block_to_shortcode( $post );
endwhile;
}
// reset loop
rewind_posts();
}
/**
* Replaces all serslised content block
* strings with their shorcode string
* in post_content.
*
* @since 0.1
*
* @param WP_Post $post
* @return WP_Post $post
*/
public function convert_serialised_block_to_shortcode( $post ) {
if ( is_null( $post ) || ! $post instanceof WP_Post ) return $post;
if ( ! has_block( 'civicrm/civicrm-content-block', $post ) ) return $post;
// get blocks
$blocks = parse_blocks( $post->post_content );
// get all civicrm content blocks
$civicrm_content_blocks = array_filter(
$blocks,
function ( $block ) {
return $block['blockName'] == 'civicrm/civicrm-content-block';
}
);
// reset keys
$civicrm_content_blocks = array_reduce(
$civicrm_content_blocks,
function( $list, $block ) {
$list[] = $block;
return $list;
},
[]
);
// get all serialised content block strings
preg_match_all(
'/<!-- wp:civicrm\/civicrm-content-block.*\/-->/',
$post->post_content,
$serialised_content_blocks
);
// bail if no matches
if ( empty( $serialised_content_blocks[0] ) ) return $post;
// replace serialised content block with shortcode
array_map(
function( $key, $block ) use ( &$post, $serialised_content_blocks ) {
$post->post_content = str_replace(
$serialised_content_blocks[0][$key],
$this->block_render( $block['attrs'] ), // render with defaults
$post->post_content
);
},
array_keys( $civicrm_content_blocks ),
$civicrm_content_blocks
);
return $post;
}
/**
* Cleans up the attributes
* and sets default values.
*
* We need to set defaults because
* default values for attributes aren't
* converted into html comments.
*
* @see https://github.com/WordPress/gutenberg/issues/7342
*
* @since 0.1
*
* @param array $atts The block attributes
* @param array $attributes The block attributes
*/
public function clenup_and_set_default_attributes( array $atts = [] ) {