Commit 32647c6a authored by Andrei Mondoc's avatar Andrei Mondoc
Browse files

render PCP and Petition previews

parent 949cc62a
...@@ -245,6 +245,14 @@ class CiviCRM_Gutenberg_Blocks { ...@@ -245,6 +245,14 @@ class CiviCRM_Gutenberg_Blocks {
case 'user-dashboard': case 'user-dashboard':
return $this->render_user_dashboard( $atts ); return $this->render_user_dashboard( $atts );
break; 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 { ...@@ -272,6 +280,7 @@ class CiviCRM_Gutenberg_Blocks {
$_GET['gid'] = $_REQUEST['gid'] = $atts['gid']; $_GET['gid'] = $_REQUEST['gid'] = $atts['gid'];
ob_start(); ob_start();
try { try {
if ( $atts['mode'] == 'view' ) { if ( $atts['mode'] == 'view' ) {
( new CRM_Profile_Page_View )->run(); ( new CRM_Profile_Page_View )->run();
...@@ -282,7 +291,7 @@ class CiviCRM_Gutenberg_Blocks { ...@@ -282,7 +291,7 @@ class CiviCRM_Gutenberg_Blocks {
( new CRM_Profile_Page_Router )->run( $args ); ( new CRM_Profile_Page_Router )->run( $args );
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
// silence return $e->getMessage();
} }
return ob_get_clean(); return ob_get_clean();
...@@ -366,9 +375,61 @@ class CiviCRM_Gutenberg_Blocks { ...@@ -366,9 +375,61 @@ class CiviCRM_Gutenberg_Blocks {
ob_start(); ob_start();
try { 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 ) { } 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(); return ob_get_clean();
...@@ -527,6 +588,11 @@ class CiviCRM_Gutenberg_Blocks { ...@@ -527,6 +588,11 @@ class CiviCRM_Gutenberg_Blocks {
case 'user-dashboard': case 'user-dashboard':
$attributes = ['component' => 'user-dashboard', 'hijack' => $attributes['hijack']]; $attributes = ['component' => 'user-dashboard', 'hijack' => $attributes['hijack']];
break; break;
case 'petition':
case 'pcp':
unset( $attributes['gid'], $attributes['action'] );
break;
} }
return $attributes; return $attributes;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment