From 6d608c2b1ff96580a7f8a46cdaad8b1c60a84b2a Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Wed, 5 Nov 2014 12:41:32 +0530 Subject: [PATCH] #30982 show hide feature for title, border, pb caption --- CRM/Wci/BAO/Widget.php | 3 +++ CRM/Wci/DAO/Widget.php | 39 ++++++++++++++++++++++++++++ CRM/Wci/Form/CreateWidget.php | 35 +++++++++++++++++++++---- sql/install.sql | 5 +++- templates/CRM/Wci/Page/wciwidget.tpl | 16 ++++++++---- 5 files changed, 87 insertions(+), 11 deletions(-) diff --git a/CRM/Wci/BAO/Widget.php b/CRM/Wci/BAO/Widget.php index c1823a6..a5bb74f 100644 --- a/CRM/Wci/BAO/Widget.php +++ b/CRM/Wci/BAO/Widget.php @@ -157,6 +157,9 @@ class CRM_Wci_BAO_Widget extends CRM_Wci_DAO_Widget { $data["custom_template"] = $dao->custom_template; $data["widgetId"] = $widgetId; $data["override"] = $dao->override; + $data["hide_title"] = $dao->hide_title; + $data["hide_border"] = $dao->hide_border; + $data["hide_pbcap"] = $dao->hide_pbcap; $data["color_bar"] = $dao->color_progress_bar; $data["emailSignupGroupFormURL"] = CRM_Utils_System::baseCMSURL() . '/civicrm/profile/create?reset=1&gid=15'; } diff --git a/CRM/Wci/DAO/Widget.php b/CRM/Wci/DAO/Widget.php index f062e23..b00b42a 100644 --- a/CRM/Wci/DAO/Widget.php +++ b/CRM/Wci/DAO/Widget.php @@ -203,6 +203,24 @@ class CRM_Wci_DAO_Widget extends CRM_Core_DAO * @var boolean */ public $override; + /** + * Flag to Hide title + * + * @var boolean + */ + public $hide_title; + /** + * Flag to Hide widget border + * + * @var boolean + */ + public $hide_border; + /** + * Flag to Hide pb caption + * + * @var boolean + */ + public $hide_pbcap; /** * Custom template * @@ -374,6 +392,24 @@ class CRM_Wci_DAO_Widget extends CRM_Core_DAO 'type' => CRM_Utils_Type::T_BOOLEAN, 'title' => ts('Override default template', array('domain' => 'org.civicrm.wci')) , 'required' => false, + ) , + 'hide_title' => array( + 'name' => 'hide_title', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Hide title, if 1.', array('domain' => 'org.civicrm.wci')) , + 'required' => false, + ) , + 'hide_border' => array( + 'name' => 'hide_border', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Hide widget border, if 1.', array('domain' => 'org.civicrm.wci')) , + 'required' => false, + ) , + 'hide_pbcap' => array( + 'name' => 'hide_pbcap', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Hide pb caption, if 1.', array('domain' => 'org.civicrm.wci')) , + 'required' => false, ) , 'custom_template' => array( 'name' => 'custom_template', @@ -416,6 +452,9 @@ class CRM_Wci_DAO_Widget extends CRM_Core_DAO 'color_button_bg' => 'color_button_bg', 'style_rules' => 'style_rules', 'override' => 'override', + 'hide_title' => 'hide_title', + 'hide_border' => 'hide_border', + 'hide_pbcap' => 'hide_pbcap', 'custom_template' => 'custom_template', ); } diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index 1a1abd0..387dc12 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -91,6 +91,9 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form { $this->add('select', 'email_signup_group_id', ts('Newsletter signup'), $this->getGroupOptions()); $this->add('select', 'size_variant', ts('Size variant'), $this->getSizeOptions()); // $fieldset = $this->addElement('fieldset')->setLabel('Advanced Settings'); + $this->add('checkbox', 'hide_title', ts('Hide Title')); + $this->add('checkbox', 'hide_border', ts('Hide border')); + $this->add('checkbox', 'hide_pbcap', ts('Hide progress bar caption')); foreach ($this->_colorFields as $name => $val) { $this->addElement($val[1], $name, @@ -175,6 +178,12 @@ where w.id=" . $this->_id;*/ 'style_rules' => base64_decode($wid_page[$dao->id]['style_rules']))); $this->setDefaults(array( 'override' => $wid_page[$dao->id]['override'])); + $this->setDefaults(array( + 'hide_title' => $wid_page[$dao->id]['hide_title'])); + $this->setDefaults(array( + 'hide_border' => $wid_page[$dao->id]['hide_border'])); + $this->setDefaults(array( + 'hide_pbcap' => $wid_page[$dao->id]['hide_pbcap'])); if(true == $wid_page[$dao->id]['override']) { $cust_templ = base64_decode($wid_page[$dao->id]['custom_template']); $this->setDefaults(array( @@ -199,8 +208,10 @@ where w.id=" . $this->_id;*/ function postProcess() { $values = $this->exportValues(); - $override = 0; + $hide_title = 0; + $hide_border = 0; + $hide_pbcap = 0; $cust_tmpl = ""; $cust_tmpl_col = ""; $sql = ""; @@ -218,7 +229,16 @@ where w.id=" . $this->_id;*/ $equals = " = "; $quote = "'"; } - + if(isset($values['hide_title'])){ + $hide_title = $values['hide_title']; + } + if(isset($values['hide_border'])){ + $hide_border = $values['hide_border']; + } + if(isset($values['hide_pbcap'])){ + $hide_pbcap = $values['hide_pbcap']; + } + if (isset($this->_id)) { $sql = "UPDATE civicrm_wci_widget SET title = '". base64_encode($values['title']) . "', logo_image = '" . $values['logo_image'] . "', image = '" @@ -235,7 +255,10 @@ where w.id=" . $this->_id;*/ . "', color_description = '" . $values['color_description'] . "', color_border = '" . $values['color_border'] . "', color_button = '" . $values['color_button'] - . "', color_button_bg = '" . $values['color_button_bg'] + . "', color_button_bg = '" . $values['color_button_bg'] + . "', hide_title = '" . $hide_title + . "', hide_border = '" . $hide_border + . "', hide_pbcap = '" . $hide_pbcap . "', style_rules = '" . base64_encode($values['style_rules']) . "', override = '" . $override . $quote . $coma . $cust_tmpl_col . $equals . $quote . $cust_tmpl . "' where id =" . $this->_id ; } @@ -244,7 +267,7 @@ where w.id=" . $this->_id;*/ button_title, button_link_to, progress_bar_id, description, email_signup_group_id, size_variant, color_title, color_title_bg, color_progress_bar, color_widget_bg, color_description, color_border, - color_button, color_button_bg, style_rules, override" . $coma . $cust_tmpl_col ." ) + color_button, color_button_bg, hide_title, hide_border, hide_pbcap, style_rules, override" . $coma . $cust_tmpl_col ." ) VALUES ('" . base64_encode($values['title']) . "','" . $values['logo_image'] . "','" . $values['image'] . "','" . $values['button_title'] . "','" . $values['button_link_to'] . "','" . $values['progress_bar'] . "','" . @@ -254,7 +277,9 @@ where w.id=" . $this->_id;*/ $values['color_title_bg'] . "','" . $values['color_bar'] . "','" . $values['color_widget_bg'] . "','" . $values['color_description'] . "','" . $values['color_border'] . "','" . $values['color_button'] . "','" . - $values['color_button_bg'] . "','" . base64_encode($values['style_rules']) . "','" . + $values['color_button_bg'] . "','" . $values['hide_title'] . "','" . + $values['hide_border'] . "','" . $values['hide_pbcap'] . "','" + . base64_encode($values['style_rules']) . "','" . $override . $quote . $coma . $quote . $cust_tmpl . "')"; } diff --git a/sql/install.sql b/sql/install.sql index 329b2a6..e921af8 100644 --- a/sql/install.sql +++ b/sql/install.sql @@ -41,7 +41,10 @@ CREATE TABLE IF NOT EXISTS civicrm_wci_widget ( style_rules text DEFAULT NULL COMMENT 'Additional style rules.', override tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Override default template, if 1.', custom_template text DEFAULT NULL COMMENT 'Widget custom template.', + hide_title tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Hide title, if 1.', + hide_border tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Hide widget border, if 1.', + hide_pbcap tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Hide pb caption, if 1.', PRIMARY KEY (`id`), UNIQUE KEY `unique_wci_title` (`title`), CONSTRAINT FK_civicrm_wci_widget_progress_bar_id FOREIGN KEY (`progress_bar_id`) REFERENCES `civicrm_wci_progress_bar`(`id`) ON DELETE SET NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; diff --git a/templates/CRM/Wci/Page/wciwidget.tpl b/templates/CRM/Wci/Page/wciwidget.tpl index 1813008..8374bbc 100644 --- a/templates/CRM/Wci/Page/wciwidget.tpl +++ b/templates/CRM/Wci/Page/wciwidget.tpl @@ -8,7 +8,12 @@ -webkit-border-radius: 4px; -khtml-border-radius: 4px; border-radius: 4px; - border: 4px solid {/literal}{$wciform.color_border}{literal}; + + {/literal}{if (0 == $wciform.hide_border)}{literal} + border: 4px solid {/literal}{$wciform.color_border}{literal}; + {if (1 == $wciform.hide_border)} + border: None; + {/literal}{/if}{literal} background-color: {/literal}{$wciform.color_widget_bg}{literal}; /* background color */ } @@ -153,9 +158,8 @@ {literal} {/literal} -
- {if $wciform.title} + {if $wciform.title && (false == $wciform.hide_title)}
{if $wciform.logo_image}
{/if} + {if (false == $wciform.hide_pbcap)}
-
${$wciform.goal_amount}
-
${$wciform.starting_amount}
+
{$wciform.goal_amount}
+
{$wciform.starting_amount}
{$wciform.pb_percentage}%
+ {/if}
-- 2.25.1