本文整理汇总了PHP中CRM_Core_ShowHideBlocks类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_ShowHideBlocks类的具体用法?PHP CRM_Core_ShowHideBlocks怎么用?PHP CRM_Core_ShowHideBlocks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_ShowHideBlocks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @return string
*/
function run()
{
$errorMessage = '';
// ensure that all CiviCRM tables are InnoDB, else abort
// this is not a very fast operation, so we do it randomly 10% of the times
// but we do it for most / all tables
// http://bugs.mysql.com/bug.php?id=43664
if (rand(1, 10) == 3 && CRM_Core_DAO::isDBMyISAM(150)) {
$errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues.');
CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert");
}
if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert", array('expires' => 0));
}
$groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
$config = CRM_Core_Config::singleton();
if (in_array('CiviContribute', $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array('CiviMember', $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array('CiviEvent', $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array('CiviMail', $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array('CiviCase', $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array('CiviReport', $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array('CiviCampaign', $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
$values = CRM_Core_Menu::getAdminLinks();
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
$this->_showHide->addShow("id_{$groupId}_show");
$this->_showHide->addHide("id_{$groupId}");
$v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
if (isset($values[$group])) {
$adminPanel[$groupId] = $values[$group];
$adminPanel[$groupId]['show'] = $v['show'];
$adminPanel[$groupId]['hide'] = $v['hide'];
$adminPanel[$groupId]['title'] = $title;
} else {
$adminPanel[$groupId] = array();
$adminPanel[$groupId]['show'] = '';
$adminPanel[$groupId]['hide'] = '';
$adminPanel[$groupId]['title'] = $title;
}
}
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
示例2: setShowHide
/**
* Fix what blocks to show/hide based on the default values set
*
* @param array $defaults the array of default values
* @param boolean $force should we set show hide based on input defaults
*
* @return void
*/
function setShowHide(&$defaults)
{
require_once 'CRM/Core/ShowHideBlocks.php';
$this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
if (empty($defaults)) {
$this->_showHide->addShow('registration_screen_show');
$this->_showHide->addShow('confirm_show');
$this->_showHide->addShow('mail_show');
$this->_showHide->addShow('thankyou_show');
$this->_showHide->addHide('registration');
$this->_showHide->addHide('registration_screen');
$this->_showHide->addHide('confirm');
$this->_showHide->addHide('mail');
$this->_showHide->addHide('thankyou');
$this->_showHide->addHide('additional_profile_pre');
$this->_showHide->addHide('additional_profile_post');
$this->_showHide->addHide('id-approval-text');
} else {
$this->_showHide->addShow('confirm');
$this->_showHide->addShow('mail');
$this->_showHide->addShow('thankyou');
$this->_showHide->addHide('registration_screen_show');
$this->_showHide->addHide('confirm_show');
$this->_showHide->addHide('mail_show');
$this->_showHide->addHide('thankyou_show');
if (!$defaults['is_multiple_registrations']) {
$this->_showHide->addHide('additional_profile_pre');
$this->_showHide->addHide('additional_profile_post');
}
if (!CRM_Utils_Array::value('requires_approval', $defaults)) {
$this->_showHide->addHide('id-approval-text');
}
}
$this->_showHide->addToTemplate();
}
示例3: buildIMBlock
/**
* build the form elements for an IM object
*
* @param CRM_Core_Form $form reference to the form object
* @param array $location the location object to store all the form elements in
* @param int $locationId the locationId we are dealing with
* @param int $count the number of blocks to create
*
* @return void
* @access public
* @static
*/
function buildIMBlock(&$form, &$location, $locationId, $count)
{
for ($i = 1; $i <= $count; $i++) {
$label = $i == 1 ? ts('Instant Messenger (preferred)') : ts('Instant Messenger');
CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][im]", ts('another IM'), ts('hide this IM'));
$location[$locationId]['im'][$i]['service_id'] = $form->addElement('select', "location[{$locationId}][im][{$i}][provider_id]", $label, array('' => ts('- select service -')) + CRM_Core_PseudoConstant::IMProvider());
$location[$locationId]['im'][$i]['name'] = $form->addElement('text', "location[{$locationId}][im][{$i}][name]", null, CRM_Core_DAO::getAttribute('CRM_Core_DAO_IM', 'name'));
}
}
示例4: buildEmailBlock
/**
* build the form elements for an email object
*
* @param CRM_Core_Form $form reference to the form object
* @param array $location the location object to store all the form elements in
* @param int $locationId the locationId we are dealing with
* @param int $count the number of blocks to create
*
* @return void
* @access public
* @static
*/
function buildEmailBlock(&$form, &$location, $locationId, $count)
{
for ($i = 1; $i <= $count; $i++) {
$label = $i == 1 ? ts('Email (preferred)') : ts('Email');
CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][email]", ts('another email'), ts('hide this email'));
$location[$locationId]['email'][$i]['email'] = $form->addElement('text', "location[{$locationId}][email][{$i}][email]", $label, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
$form->addRule("location[{$locationId}][email][{$i}][email]", ts('Email is not valid.'), 'email');
}
}
示例5: run
function run()
{
// ensure that all CiviCRM tables are InnoDB, else abort
if (CRM_Core_DAO::isDBMyISAM()) {
$errorMessage = 'Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues. This will be a fatal error in CiviCRM v2.1.';
require_once 'CRM/Core/Session.php';
CRM_Core_Session::setStatus($errorMessage);
}
if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
CRM_Core_Session::setStatus($errorMessage);
}
$groups = array('Customize' => ts('Customize'), 'Configure' => ts('Configure'), 'Manage' => ts('Manage'), 'Option Lists' => ts('Option Lists'));
$config = CRM_Core_Config::singleton();
if (in_array("CiviContribute", $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array("CiviMember", $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array("CiviEvent", $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array("CiviMail", $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array("CiviCase", $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array("CiviReport", $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array("CiviCampaign", $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
require_once 'CRM/Core/Menu.php';
$values =& CRM_Core_Menu::getAdminLinks();
require_once 'CRM/Core/ShowHideBlocks.php';
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$this->_showHide->addShow("id_{$group}_show");
$this->_showHide->addHide("id_{$group}");
$v = CRM_Core_ShowHideBlocks::links($this, $group, '', '', false);
$adminPanel[$group] = $values[$group];
$adminPanel[$group]['show'] = $v['show'];
$adminPanel[$group]['hide'] = $v['hide'];
$adminPanel[$group]['title'] = $title;
}
require_once 'CRM/Utils/VersionCheck.php';
$versionCheck =& CRM_Utils_VersionCheck::singleton();
$this->assign('newVersion', $versionCheck->newerVersion());
$this->assign('localVersion', $versionCheck->localVersion);
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
示例6: buildPhoneBlock
/**
* build the form elements for a phone object
*
* @param CRM_Core_Form $form reference to the form object
* @param array $location the location object to store all the form elements in
* @param int $locationId the locationId we are dealing with
* @param int $count the number of blocks to create
*
* @return void
* @access public
* @static
*/
function buildPhoneBlock(&$form, &$location, $locationId, $count)
{
for ($i = 1; $i <= $count; $i++) {
$label = $i == 1 ? ts('Phone (preferred)') : ts('Phone');
CRM_Core_ShowHideBlocks::linksForArray($form, $i, $count, "location[{$locationId}][phone]", ts('another phone'), ts('hide this phone'));
$location[$locationId]['phone'][$i]['phone_type'] = $form->addElement('select', "location[{$locationId}][phone][{$i}][phone_type]", null, CRM_Core_SelectValues::phoneType());
$location[$locationId]['phone'][$i]['phone'] = $form->addElement('text', "location[{$locationId}][phone][{$i}][phone]", $label, CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
// TODO: set this up as a group, we need a valid phone_type_id if we have a phone number
// $form->addRule( "location[$locationId][phone][$i][phone]", ts('Phone number is not valid.'), 'phone' );
}
}
示例7: setDefaultValues
/**
* Set default values for the form.
*/
public function setDefaultValues()
{
$defaults = array();
// check if there is a widget already created
if ($this->_widget) {
CRM_Core_DAO::storeValues($this->_widget, $defaults);
} else {
foreach ($this->_fields as $name => $val) {
$defaults[$name] = $val[3];
}
foreach ($this->_colorFields as $name => $val) {
$defaults[$name] = $val[3];
}
$defaults['about'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'intro_text');
}
$showHide = new CRM_Core_ShowHideBlocks();
$showHide->addHide('id-colors');
$showHide->addToTemplate();
return $defaults;
}
示例8: setShowHide
/**
* Fix what blocks to show/hide based on the default values set
*
* @param array $defaults
* The array of default values.
*
* @return void
*/
public function setShowHide($defaults)
{
$this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
if (empty($defaults)) {
$this->_showHide->addHide('registration');
$this->_showHide->addHide('id-approval-text');
} else {
if (empty($defaults['requires_approval'])) {
$this->_showHide->addHide('id-approval-text');
}
}
$this->assign('defaultsEmpty', empty($defaults));
$this->_showHide->addToTemplate();
}
示例9: run
/**
* Run page.
*
* @return string
*/
public function run()
{
Civi::resources()->addStyleFile('civicrm', 'css/admin.css');
$this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
$groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
$config = CRM_Core_Config::singleton();
if (in_array('CiviContribute', $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array('CiviMember', $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array('CiviEvent', $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array('CiviMail', $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array('CiviCase', $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array('CiviReport', $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array('CiviCampaign', $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
$values = CRM_Core_Menu::getAdminLinks();
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
$this->_showHide->addShow("id_{$groupId}_show");
$this->_showHide->addHide("id_{$groupId}");
$v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
if (isset($values[$group])) {
$adminPanel[$groupId] = $values[$group];
$adminPanel[$groupId]['show'] = $v['show'];
$adminPanel[$groupId]['hide'] = $v['hide'];
$adminPanel[$groupId]['title'] = $title;
} else {
$adminPanel[$groupId] = array();
$adminPanel[$groupId]['show'] = '';
$adminPanel[$groupId]['hide'] = '';
$adminPanel[$groupId]['title'] = $title;
}
}
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
示例10: run
/**
* @return string
*/
public function run()
{
$groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
$config = CRM_Core_Config::singleton();
if (in_array('CiviContribute', $config->enableComponents)) {
$groups['CiviContribute'] = ts('CiviContribute');
}
if (in_array('CiviMember', $config->enableComponents)) {
$groups['CiviMember'] = ts('CiviMember');
}
if (in_array('CiviEvent', $config->enableComponents)) {
$groups['CiviEvent'] = ts('CiviEvent');
}
if (in_array('CiviMail', $config->enableComponents)) {
$groups['CiviMail'] = ts('CiviMail');
}
if (in_array('CiviCase', $config->enableComponents)) {
$groups['CiviCase'] = ts('CiviCase');
}
if (in_array('CiviReport', $config->enableComponents)) {
$groups['CiviReport'] = ts('CiviReport');
}
if (in_array('CiviCampaign', $config->enableComponents)) {
$groups['CiviCampaign'] = ts('CiviCampaign');
}
$values = CRM_Core_Menu::getAdminLinks();
$this->_showHide = new CRM_Core_ShowHideBlocks();
foreach ($groups as $group => $title) {
$groupId = str_replace(' ', '_', $group);
$this->_showHide->addShow("id_{$groupId}_show");
$this->_showHide->addHide("id_{$groupId}");
$v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
if (isset($values[$group])) {
$adminPanel[$groupId] = $values[$group];
$adminPanel[$groupId]['show'] = $v['show'];
$adminPanel[$groupId]['hide'] = $v['hide'];
$adminPanel[$groupId]['title'] = $title;
} else {
$adminPanel[$groupId] = array();
$adminPanel[$groupId]['show'] = '';
$adminPanel[$groupId]['hide'] = '';
$adminPanel[$groupId]['title'] = $title;
}
}
$this->assign('adminPanel', $adminPanel);
$this->_showHide->addToTemplate();
return parent::run();
}
示例11: custom
/**
* Generate the custom Data Fields based
* on the is_searchable
*
*
* @param $form
*
* @return void
*/
public static function custom(&$form)
{
$form->add('hidden', 'hidden_custom', 1);
$extends = array('Relationship');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
$form->assign('groupTree', $groupDetails);
foreach ($groupDetails as $key => $group) {
$_groupTitle[$key] = $group['name'];
CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
$groupId = $group['id'];
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
示例12: setShowHide
/**
* Fix what blocks to show/hide based on the default values set
*
* @param array array of Group Titles
* @param array array of Group Collapse Display
*
* @return
*
* @access protected
*/
function setShowHide(&$groupTitle, &$groupCollapseDisplay)
{
if (empty($groupTitle)) {
return;
}
$this->_showHide =& new CRM_Core_ShowHideBlocks('', '');
foreach ($groupTitle as $key => $title) {
$showBlocks = $title . '[show]';
$hideBlocks = $title;
if ($groupCollapseDisplay[$key]) {
$this->_showHide->addShow($showBlocks);
$this->_showHide->addHide($hideBlocks);
} else {
$this->_showHide->addShow($hideBlocks);
$this->_showHide->addHide($showBlocks);
}
}
$this->_showHide->addToTemplate();
}
示例13: setShowHide
/**
* Fix what blocks to show/hide based on the default values set
*
* @param array $defaults the array of default values
* @param boolean $force should we set show hide based on input defaults
*
* @return void
*/
function setShowHide($defaults)
{
$this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), '');
if (empty($defaults)) {
$this->_showHide->addHide('registration');
$this->_showHide->addHide('additional_profile_pre');
$this->_showHide->addHide('additional_profile_post');
$this->_showHide->addHide('id-approval-text');
} else {
if (!CRM_Utils_Array::value('is_multiple_registrations', $defaults)) {
$this->_showHide->addHide('additional_profile_pre');
$this->_showHide->addHide('additional_profile_post');
}
if (!CRM_Utils_Array::value('requires_approval', $defaults)) {
$this->_showHide->addHide('id-approval-text');
}
}
$this->assign('defaultsEmpty', empty($defaults));
$this->_showHide->addToTemplate();
}
示例14: buildQuickForm
/**
* This function provides the HTML form elements that are specific to the Individual Contact Type
*
* @access public
* @return None
*/
function buildQuickForm(&$form)
{
$form->applyFilter('__ALL__', 'trim');
// prefix
$form->addElement('select', 'prefix_id', ts('Prefix'), array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::individualPrefix());
$attributes = CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Individual');
// first_name
$form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name']);
//middle_name
$form->addElement('text', 'middle_name', ts('Middle Name'), $attributes['middle_name']);
// last_name
$form->addElement('text', 'last_name', ts('Last Name'), $attributes['last_name']);
// suffix
$form->addElement('select', 'suffix_id', ts('Suffix'), array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::individualSuffix());
// nick_name
$form->addElement('text', 'nick_name', ts('Nick Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'nick_name'));
// greeting type
$form->addElement('select', 'greeting_type', ts('Greeting'), CRM_Core_SelectValues::greeting());
// job title
$form->addElement('text', 'job_title', ts('Job title'), $attributes['job_title']);
// radio button for gender
$genderOptions = array();
$gender = CRM_Core_PseudoConstant::gender();
foreach ($gender as $key => $var) {
$genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
}
$form->addGroup($genderOptions, 'gender_id', ts('Gender'));
$form->addElement('checkbox', 'is_deceased', null, ts('Contact is deceased'));
$form->addElement('date', 'birth_date', ts('Date of birth'), CRM_Core_SelectValues::date('birth'));
$form->addRule('birth_date', ts('Select a valid date.'), 'qfDate');
$form->addElement('text', 'home_URL', ts('Website'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'home_URL'));
$form->addRule('home_URL', ts('Enter a valid Website.'), 'url');
$config =& CRM_Core_Config::singleton();
CRM_Core_ShowHideBlocks::links($this, 'demographics', '', '');
}
示例15: custom
/**
* Generate the custom Data Fields based
* on the is_searchable
*
*
* @param $form
*
* @return void
*/
public static function custom(&$form)
{
$form->add('hidden', 'hidden_custom', 1);
$extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), CRM_Contact_BAO_ContactType::subTypes());
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
$form->assign('groupTree', $groupDetails);
foreach ($groupDetails as $key => $group) {
$_groupTitle[$key] = $group['name'];
CRM_Core_ShowHideBlocks::links($form, $group['name'], '', '');
$groupId = $group['id'];
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
if ($field['data_type'] == 'Date' && $field['is_search_range']) {
CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE);
} else {
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
//TODO: validate for only one state if prox_distance isset
}