Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
plugins
CiviCRM Gutenberg Blocks
Commits
32647c6a
Commit
32647c6a
authored
Sep 07, 2020
by
Andrei Mondoc
Browse files
render PCP and Petition previews
parent
949cc62a
Changes
1
Hide whitespace changes
Inline
Side-by-side
civicrm-gutenberg-blocks.php
View file @
32647c6a
...
...
@@ -245,6 +245,14 @@ class CiviCRM_Gutenberg_Blocks {
case
'user-dashboard'
:
return
$this
->
render_user_dashboard
(
$atts
);
break
;
case
'pcp'
:
return
$this
->
render_pcp
(
$atts
);
break
;
case
'petition'
:
return
$this
->
render_petition
(
$atts
);
break
;
}
}
...
...
@@ -272,6 +280,7 @@ class CiviCRM_Gutenberg_Blocks {
$_GET
[
'gid'
]
=
$_REQUEST
[
'gid'
]
=
$atts
[
'gid'
];
ob_start
();
try
{
if
(
$atts
[
'mode'
]
==
'view'
)
{
(
new
CRM_Profile_Page_View
)
->
run
();
...
...
@@ -282,7 +291,7 @@ class CiviCRM_Gutenberg_Blocks {
(
new
CRM_Profile_Page_Router
)
->
run
(
$args
);
}
}
catch
(
Exception
$e
)
{
// silence
return
$e
->
getMessage
();
}
return
ob_get_clean
();
...
...
@@ -366,9 +375,61 @@ class CiviCRM_Gutenberg_Blocks {
ob_start
();
try
{
(
new
CRM_Contact_Page_View_UserDashBoard
()
)
->
run
();
(
new
CRM_Contact_Page_View_UserDashBoard
)
->
run
();
}
catch
(
Exception
$e
)
{
return
$e
->
getMessage
();
}
return
ob_get_clean
();
}
/**
* Renders a PCP's html.
*
* @since 0.1
*
* @param array $atts The block attributes
* @return string $html
*/
public
function
render_pcp
(
array
$atts
)
{
ob_start
();
$_REQUEST
[
'id'
]
=
$atts
[
'id'
];
try
{
(
new
CRM_PCP_Page_PCPInfo
)
->
run
();
}
catch
(
Exception
$e
)
{
// silence
return
$e
->
getMessage
();
}
return
ob_get_clean
();
}
/**
* Renders a Petition's html.
*
* @since 0.1
*
* @param array $atts The block attributes
* @return string $html
*/
public
function
render_petition
(
array
$atts
)
{
ob_start
();
$_REQUEST
[
'sid'
]
=
$atts
[
'id'
];
try
{
(
new
CRM_Utils_Wrapper
)
->
run
(
'CRM_Campaign_Form_Petition_Signature'
,
'Sign Petition'
,
null
);
}
catch
(
Exception
$e
)
{
return
$e
->
getMessage
();
}
return
ob_get_clean
();
...
...
@@ -527,6 +588,11 @@ class CiviCRM_Gutenberg_Blocks {
case
'user-dashboard'
:
$attributes
=
[
'component'
=>
'user-dashboard'
,
'hijack'
=>
$attributes
[
'hijack'
]];
break
;
case
'petition'
:
case
'pcp'
:
unset
(
$attributes
[
'gid'
],
$attributes
[
'action'
]
);
break
;
}
return
$attributes
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment