本文整理汇总了PHP中CRM_Core_I18n::isMultilingual方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_I18n::isMultilingual方法的具体用法?PHP CRM_Core_I18n::isMultilingual怎么用?PHP CRM_Core_I18n::isMultilingual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_I18n
的用法示例。
在下文中一共展示了CRM_Core_I18n::isMultilingual方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareQuery
/**
* @param string $phase
* @return \CRM_Utils_SQL_Select
* @throws \CRM_Core_Exception
*/
protected function prepareQuery($phase)
{
$defaultParams = array('casActionScheduleId' => $this->actionSchedule->id, 'casMappingId' => $this->mapping->getId(), 'casMappingEntity' => $this->mapping->getEntity(), 'casNow' => $this->now);
/** @var \CRM_Utils_SQL_Select $query */
$query = $this->mapping->createQuery($this->actionSchedule, $phase, $defaultParams);
if ($this->actionSchedule->limit_to) {
$query->merge($this->prepareContactFilter($query['casContactIdField']));
}
if (empty($query['casContactTableAlias'])) {
$query['casContactTableAlias'] = 'c';
$query->join('c', "INNER JOIN civicrm_contact c ON c.id = !casContactIdField AND c.is_deleted = 0 AND c.is_deceased = 0 ");
}
$multilingual = \CRM_Core_I18n::isMultilingual();
if ($multilingual && !empty($this->actionSchedule->filter_contact_language)) {
$query->where($this->prepareLanguageFilter($query['casContactTableAlias']));
}
return $query;
}
示例2: buildQuickForm
//.........这里部分代码省略.........
$sel =& $this->add('hierselect', 'entity', ts('Entity'), array('name' => 'entity[0]', 'style' => 'vertical-align: top;'));
$sel->setOptions(array(CRM_Utils_Array::collectMethod('getLabel', $mappings), CRM_Core_BAO_ActionSchedule::getAllEntityValueLabels(), CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels()));
if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
// make second selector a multi-select -
$sel->_elements[1]->setMultiple(TRUE);
$sel->_elements[1]->setSize(5);
}
if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) {
// make third selector a multi-select -
$sel->_elements[2]->setMultiple(TRUE);
$sel->_elements[2]->setSize(5);
}
} else {
// Dig deeper - this code is sublimely stupid.
$allEntityStatusLabels = CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels();
$options = $allEntityStatusLabels[$this->_mappingID][0];
$attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]);
unset($options[0]);
$this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes);
$this->assign('context', $this->_context);
}
//get the frequency units.
$this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits();
$numericOptions = CRM_Core_SelectValues::getNumericOptions(0, 30);
//reminder_interval
$this->add('select', 'start_action_offset', ts('When'), $numericOptions);
$isActive = ts('Send email');
$recordActivity = ts('Record activity for automated email');
if ($providersCount) {
$this->assign('sms', $providersCount);
$isActive = ts('Send email or SMS');
$recordActivity = ts('Record activity for automated email or SMS');
$options = CRM_Core_OptionGroup::values('msg_mode');
$this->add('select', 'mode', ts('Send as'), $options);
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc');
$providerSelect = array();
foreach ($providers as $provider) {
$providerSelect[$provider['id']] = $provider['title'];
}
$this->add('select', 'sms_provider_id', ts('SMS Provider'), $providerSelect, TRUE);
}
foreach ($this->_freqUnits as $val => $label) {
$freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
}
$this->addDate('absolute_date', ts('Start Date'), FALSE, array('formatType' => 'mailing'));
//reminder_frequency
$this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE);
$condition = array('before' => ts('before'), 'after' => ts('after'));
//reminder_action
$this->add('select', 'start_action_condition', ts('Action Condition'), $condition);
$this->add('select', 'start_action_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE);
$this->addElement('checkbox', 'record_activity', $recordActivity);
$this->addElement('checkbox', 'is_repeat', ts('Repeat'), NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);"));
$this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay);
$this->add('select', 'repetition_frequency_interval', ts('every'), $numericOptions);
$this->add('select', 'end_frequency_unit', ts('until'), $freqUnitsDisplay);
$this->add('select', 'end_frequency_interval', ts('until'), $numericOptions);
$this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE);
$this->add('select', 'end_date', ts('Date Field'), $selectedMapping->getDateFields(), TRUE);
$this->add('text', 'from_name', ts('From Name'));
$this->add('text', 'from_email', ts('From Email'));
$recipientListingOptions = array();
if ($mappingID) {
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $mappingID)));
}
$limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include'));
$recipientLabels = array('activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients'));
$this->assign('recipientLabels', $recipientLabels);
$this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);"));
$this->add('select', 'recipient', $recipientLabels['other'], $entityRecipientLabels, FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);"));
if (!empty($this->_submitValues['recipient_listing'])) {
if (!empty($this->_context)) {
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_mappingID, $this->_submitValues['recipient']);
} else {
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($_POST['entity'][0], $_POST['recipient']);
}
} elseif (!empty($this->_values['recipient_listing'])) {
$recipientListingOptions = CRM_Core_BAO_ActionSchedule::getRecipientListing($this->_values['mapping_id'], $this->_values['recipient']);
}
$this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE));
$this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE));
$this->add('select', 'group_id', ts('Group'), CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, array('class' => 'crm-select2 huge'));
// multilingual only options
$multilingual = CRM_Core_I18n::isMultilingual();
if ($multilingual) {
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('multilingual', $multilingual);
$languages = CRM_Core_I18n::languages(TRUE);
$languageFilter = $languages + array(CRM_Core_I18n::NONE => ts('Contacts with no preferred language'));
$element = $this->add('select', 'filter_contact_language', ts('Recipients language'), $languageFilter, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE));
$communicationLanguage = array('' => ts('System default language'), CRM_Core_I18n::AUTO => ts('Follow recipient preferred language'));
$communicationLanguage = $communicationLanguage + $languages;
$this->add('select', 'communication_language', ts('Communication language'), $communicationLanguage);
}
CRM_Mailing_BAO_Mailing::commonCompose($this);
$this->add('text', 'subject', ts('Subject'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'subject'));
$this->add('checkbox', 'is_active', $isActive);
$this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'), $this);
$this->setPageTitle(ts('Scheduled Reminder'));
}
示例3: sendMailings
/**
* @param int $mappingID
* @param $now
*
* @throws CRM_Core_Exception
*/
public static function sendMailings($mappingID, $now)
{
$mapping = CRM_Utils_Array::first(self::getMappings(array('id' => $mappingID)));
$actionSchedule = new CRM_Core_DAO_ActionSchedule();
$actionSchedule->mapping_id = $mappingID;
$actionSchedule->is_active = 1;
$actionSchedule->find(FALSE);
while ($actionSchedule->fetch()) {
$query = CRM_Core_BAO_ActionSchedule::prepareMailingQuery($mapping, $actionSchedule);
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
$multilingual = CRM_Core_I18n::isMultilingual();
while ($dao->fetch()) {
// switch language if necessary
if ($multilingual) {
$preferred_language = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contactID, 'preferred_language');
CRM_Core_BAO_ActionSchedule::setCommunicationLanguage($actionSchedule->communication_language, $preferred_language);
}
$errors = array();
try {
$tokenProcessor = self::createTokenProcessor($actionSchedule, $mapping);
$tokenProcessor->addRow()->context('contactId', $dao->contactID)->context('actionSearchResult', (object) $dao->toArray());
foreach ($tokenProcessor->evaluate()->getRows() as $tokenRow) {
if ($actionSchedule->mode == 'SMS' or $actionSchedule->mode == 'User_Preference') {
CRM_Utils_Array::extend($errors, self::sendReminderSms($tokenRow, $actionSchedule, $dao->contactID));
}
if ($actionSchedule->mode == 'Email' or $actionSchedule->mode == 'User_Preference') {
CRM_Utils_Array::extend($errors, self::sendReminderEmail($tokenRow, $actionSchedule, $dao->contactID));
}
}
} catch (\Civi\Token\TokenException $e) {
$errors['token_exception'] = $e->getMessage();
}
// update action log record
$logParams = array('id' => $dao->reminderID, 'is_error' => !empty($errors), 'message' => empty($errors) ? "null" : implode(' ', $errors), 'action_date_time' => $now);
CRM_Core_BAO_ActionLog::create($logParams);
// insert activity log record if needed
if ($actionSchedule->record_activity && empty($errors)) {
$caseID = empty($dao->case_id) ? NULL : $dao->case_id;
CRM_Core_BAO_ActionSchedule::createMailingActivity($actionSchedule, $mapping, $dao->contactID, $dao->entityID, $caseID);
}
}
$dao->free();
}
}