本文整理汇总了PHP中RSFormProHelper::getTranslations方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::getTranslations方法的具体用法?PHP RSFormProHelper::getTranslations怎么用?PHP RSFormProHelper::getTranslations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSFormProHelper
的用法示例。
在下文中一共展示了RSFormProHelper::getTranslations方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptionFields
function getOptionFields()
{
$formId = $this->getFormId();
$this->_db->setQuery("SELECT p.PropertyValue, p.PropertyName, p.ComponentId, c.ComponentTypeId FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (p.ComponentId = c.ComponentId) WHERE c.FormId='" . $formId . "' AND (p.PropertyName='DEFAULTVALUE' OR p.PropertyName='ITEMS') AND c.ComponentTypeId IN (3, 4, 5, 22) ORDER BY c.Order");
$results = $this->_db->loadObjectList();
$lang = RSFormProHelper::getCurrentLanguage($formId);
$translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
foreach ($results as $i => $result) {
$reference_id = $result->ComponentId . '.' . $result->PropertyName;
if (isset($translations[$reference_id])) {
$result->PropertyValue = $translations[$reference_id];
}
$result->PropertyValue = RSFormProHelper::isCode($result->PropertyValue);
$result->PropertyValue = str_replace(array("\r\n", "\r"), "\n", $result->PropertyValue);
$result->PropertyValue = str_replace(array('[c]', '[g]'), '', $result->PropertyValue);
$result->PropertyValue = explode("\n", $result->PropertyValue);
foreach ($result->PropertyValue as $k => $v) {
$v = explode('|', $v, 2);
// paypal ?
if ($result->ComponentTypeId == 22) {
$v[0] = $v[1];
} else {
if (!isset($v[1])) {
$v[1] = $v[0];
}
}
$result->PropertyValue[$k] = $v;
}
$results[$i] = $result;
}
return $results;
}
示例2: preview
function preview()
{
$formId = JRequest::getInt('formId');
$opener = JRequest::getCmd('opener');
$db = JFactory::getDBO();
$db->setQuery("SELECT `" . $opener . "` FROM #__rsform_forms WHERE FormId='" . $formId . "'");
$value = $db->loadResult();
$model = $this->getModel('forms');
$model->getForm();
$lang = $model->getLang();
$translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
if ($translations && isset($translations[$opener])) {
$value = $translations[$opener];
}
echo $value;
}
示例3: getOptionFields
function getOptionFields()
{
$app = JFactory::getApplication();
$types = array(3, 4, 5, 22);
$formId = $this->getFormId();
$app->triggerEvent('rsfp_bk_onCreateConditionOptionFields', array(array('types' => &$types, 'formId' => $formId)));
JArrayHelper::toInteger($types);
$this->_db->setQuery("SELECT p.PropertyValue, p.PropertyName, p.ComponentId, c.ComponentTypeId FROM #__rsform_properties p LEFT JOIN #__rsform_components c ON (p.ComponentId = c.ComponentId) WHERE c.FormId='" . $formId . "' AND (p.PropertyName='DEFAULTVALUE' OR p.PropertyName='ITEMS') AND c.ComponentTypeId IN (" . implode(',', $types) . ") ORDER BY c.Order");
$results = $this->_db->loadObjectList();
$lang = RSFormProHelper::getCurrentLanguage($formId);
$translations = RSFormProHelper::getTranslations('properties', $formId, $lang);
foreach ($results as $i => $result) {
$reference_id = $result->ComponentId . '.' . $result->PropertyName;
if (isset($translations[$reference_id])) {
$result->PropertyValue = $translations[$reference_id];
}
$result->PropertyValue = RSFormProHelper::isCode($result->PropertyValue);
$result->PropertyValue = preg_replace('#\\[p(.*?)\\]#is', '', $result->PropertyValue);
$result->PropertyValue = str_replace(array("\r\n", "\r"), "\n", $result->PropertyValue);
$result->PropertyValue = str_replace(array('[c]', '[g]'), '', $result->PropertyValue);
$result->PropertyValue = explode("\n", $result->PropertyValue);
foreach ($result->PropertyValue as $k => $v) {
$v = explode('|', $v, 2);
// paypal ?
if ($result->ComponentTypeId == 22) {
$v[0] = $v[1];
} else {
if (!isset($v[1])) {
$v[1] = $v[0];
}
}
$result->PropertyValue[$k] = $v;
}
$results[$i] = $result;
}
return $results;
}
示例4: saveEmailsTranslation
function saveEmailsTranslation(&$email, $lang)
{
$jlang = JFactory::getLanguage();
if (!$email->id) {
return true;
}
if ($lang == $jlang->getDefault()) {
return true;
}
$fields = array('fromname', 'subject', 'message');
$translations = RSFormProHelper::getTranslations('emails', $email->formId, $lang, 'id');
foreach ($fields as $field) {
$reference_id = $email->id . "." . $this->_db->escape($field);
$query = array();
$query[] = "`form_id`='" . $email->formId . "'";
$query[] = "`lang_code`='" . $this->_db->escape($lang) . "'";
$query[] = "`reference`='emails'";
$query[] = "`reference_id`='" . $reference_id . "'";
$query[] = "`value`='" . $this->_db->escape($email->{$field}) . "'";
if (!isset($translations[$reference_id])) {
$this->_db->setQuery("INSERT INTO #__rsform_translations SET " . implode(", ", $query));
$this->_db->execute();
} else {
$this->_db->setQuery("UPDATE #__rsform_translations SET " . implode(", ", $query) . " WHERE id='" . (int) $translations[$reference_id] . "'");
$this->_db->execute();
}
unset($email->{$field});
}
}
示例5: saveEmailsTranslation
function saveEmailsTranslation(&$email, $lang)
{
// We're saving a new email so we need to skip translations for now
// This email is the base for future translations.
if (!$email->id) {
return false;
}
$fields = array('fromname', 'subject', 'message');
$translations = RSFormProHelper::getTranslations('emails', $email->formId, $lang, 'id');
// $translations is false when we're trying to get translations (en-GB) for the same language the form is in (en-GB)
if ($translations === false) {
return false;
}
foreach ($fields as $field) {
$reference_id = $email->id . "." . $this->_db->escape($field);
$query = array();
$query[] = "`form_id`='" . $email->formId . "'";
$query[] = "`lang_code`='" . $this->_db->escape($lang) . "'";
$query[] = "`reference`='emails'";
$query[] = "`reference_id`='" . $reference_id . "'";
$query[] = "`value`='" . $this->_db->escape($email->{$field}) . "'";
if (!isset($translations[$reference_id])) {
$this->_db->setQuery("INSERT INTO #__rsform_translations SET " . implode(", ", $query));
$this->_db->execute();
} else {
$this->_db->setQuery("UPDATE #__rsform_translations SET " . implode(", ", $query) . " WHERE id='" . (int) $translations[$reference_id] . "'");
$this->_db->execute();
}
unset($email->{$field});
}
return true;
}
示例6: getEmails
public function getEmails()
{
$formId = JRequest::getInt('formId', 0);
$session = JFactory::getSession();
$lang = JFactory::getLanguage();
if (!$formId) {
return array();
}
$emails = $this->_getList("SELECT `id`, `to`, `subject`, `formId` FROM `#__rsform_emails` WHERE `type` = 'directory' AND `formId` = " . $formId . " ");
if (!empty($emails)) {
$translations = RSFormProHelper::getTranslations('emails', $formId, $session->get('com_rsform.form.' . $formId . '.lang', $lang->getDefault()));
foreach ($emails as $id => $email) {
if (isset($translations[$email->id . '.fromname'])) {
$emails[$id]->fromname = $translations[$email->id . '.fromname'];
}
if (isset($translations[$email->id . '.subject'])) {
$emails[$id]->subject = $translations[$email->id . '.subject'];
}
if (isset($translations[$email->id . '.message'])) {
$emails[$id]->message = $translations[$email->id . '.message'];
}
}
}
return $emails;
}
示例7: processForm
public static function processForm($formId)
{
$mainframe = JFactory::getApplication();
$formId = (int) $formId;
$db = JFactory::getDBO();
$db->setQuery("SELECT `FormLayoutName`, `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
$form = $db->loadObject();
$lang = RSFormProHelper::getCurrentLanguage();
$translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
if ($translations) {
foreach ($translations as $field => $value) {
if (isset($form->{$field})) {
$form->{$field} = $value;
}
}
}
$invalid = RSFormProHelper::validateForm($formId);
$post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
//Trigger Event - onBeforeFormValidation
$mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid, 'formId' => $formId, 'post' => &$post)));
$userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
$adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
$_POST['form'] = $post;
$RSadapter = RSFormProHelper::getLegacyAdapter();
eval($form->ScriptProcess);
if (!empty($invalid)) {
return $invalid;
}
$post = $_POST['form'];
//Trigger Event - onBeforeFormProcess
$mainframe->triggerEvent('rsfp_f_onBeforeFormProcess', array(array('post' => &$post)));
if (empty($invalid)) {
// Cache enabled ?
jimport('joomla.plugin.helper');
$cache_enabled = JPluginHelper::isEnabled('system', 'cache');
if ($cache_enabled) {
RSFormProHelper::cleanCache();
}
$user = JFactory::getUser();
$confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
// Add to db (submission)
$date = JFactory::getDate();
$db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`='" . $date->toSql() . "', `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->escape($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->escape($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
$db->execute();
$SubmissionId = $db->insertid();
$files = JRequest::get('files');
if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
$names = array();
foreach ($files['form']['tmp_name'] as $fieldName => $val) {
if ($files['form']['error'][$fieldName]) {
continue;
}
$names[] = $db->escape($fieldName);
}
$componentIds = array();
if (!empty($names)) {
$db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
$results = $db->loadObjectList();
foreach ($results as $result) {
$componentIds[$result->PropertyValue] = $result->ComponentId;
}
}
$all_data = RSFormProHelper::getComponentProperties($componentIds);
jimport('joomla.filesystem.file');
foreach ($files['form']['tmp_name'] as $fieldName => $val) {
if ($files['form']['error'][$fieldName]) {
continue;
}
$data = @$all_data[$componentIds[$fieldName]];
if (empty($data)) {
continue;
}
// Prefix
$prefix = uniqid('') . '-';
if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
$prefix = RSFormProHelper::isCode($data['PREFIX']);
}
// Path
$realpath = realpath($data['DESTINATION'] . DIRECTORY_SEPARATOR);
if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
$realpath .= DIRECTORY_SEPARATOR;
}
// Filename
$file = $realpath . $prefix . $files['form']['name'][$fieldName];
// Upload File
JFile::upload($files['form']['tmp_name'][$fieldName], $file);
// Add to db (submission value)
$db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->escape($fieldName) . "', `FieldValue`='" . $db->escape($file) . "'");
$db->execute();
$emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
// Attach to user and admin email
if (in_array('useremail', $emails)) {
$userEmail['files'][] = $file;
}
if (in_array('adminemail', $emails)) {
$adminEmail['files'][] = $file;
}
}
}
// birthDay Field
//.........这里部分代码省略.........
示例8: sendEmails
public function sendEmails($formId, $SubmissionId)
{
$directory = $this->getDirectory();
$this->_db->setQuery("SELECT Lang FROM #__rsform_submissions WHERE FormId='" . $formId . "' AND SubmissionId='" . $SubmissionId . "'");
$lang = $this->_db->loadResult();
list($placeholders, $values) = RSFormProHelper::getReplacements($SubmissionId);
$this->_db->setQuery("SELECT * FROM #__rsform_emails WHERE `type` = 'directory' AND `formId` = " . $formId . " AND `from` != ''");
if ($emails = $this->_db->loadObjectList()) {
$etranslations = RSFormProHelper::getTranslations('emails', $formId, $lang);
foreach ($emails as $email) {
if (isset($etranslations[$email->id . '.fromname'])) {
$email->fromname = $etranslations[$email->id . '.fromname'];
}
if (isset($etranslations[$email->id . '.subject'])) {
$email->subject = $etranslations[$email->id . '.subject'];
}
if (isset($etranslations[$email->id . '.message'])) {
$email->message = $etranslations[$email->id . '.message'];
}
if (empty($email->fromname) || empty($email->subject) || empty($email->message)) {
continue;
}
// RSForm! Pro Scripting - Additional Email Text
// performance check
if (strpos($email->message, '{/if}') !== false) {
require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/scripting.php';
RSFormProScripting::compile($email->message, $placeholders, $values);
}
$directoryEmail = array('to' => str_replace($placeholders, $values, $email->to), 'cc' => str_replace($placeholders, $values, $email->cc), 'bcc' => str_replace($placeholders, $values, $email->bcc), 'from' => str_replace($placeholders, $values, $email->from), 'replyto' => str_replace($placeholders, $values, $email->replyto), 'fromName' => str_replace($placeholders, $values, $email->fromname), 'text' => str_replace($placeholders, $values, $email->message), 'subject' => str_replace($placeholders, $values, $email->subject), 'mode' => $email->mode, 'files' => array());
// additional cc
if (strpos($directoryEmail['cc'], ',') !== false) {
$directoryEmail['cc'] = explode(',', $directoryEmail['cc']);
}
// additional bcc
if (strpos($directoryEmail['bcc'], ',') !== false) {
$directoryEmail['bcc'] = explode(',', $directoryEmail['bcc']);
}
//Trigger Event - beforeDirectoryEmail
$this->_app->triggerEvent('rsfp_beforeDirectoryEmail', array(array('directory' => &$directory, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'directoryEmail' => &$directoryEmail)));
eval($directory->EmailsScript);
// mail users
$recipients = explode(',', $directoryEmail['to']);
if (!empty($recipients)) {
foreach ($recipients as $recipient) {
if (!empty($recipient)) {
RSFormProHelper::sendMail($directoryEmail['from'], $directoryEmail['fromName'], $recipient, $directoryEmail['subject'], $directoryEmail['text'], $directoryEmail['mode'], !empty($directoryEmail['cc']) ? $directoryEmail['cc'] : null, !empty($directoryEmail['bcc']) ? $directoryEmail['bcc'] : null, $directoryEmail['files'], !empty($directoryEmail['replyto']) ? $directoryEmail['replyto'] : '');
}
}
}
}
}
}
示例9: processForm
function processForm($formId)
{
$mainframe =& JFactory::getApplication();
$formId = (int) $formId;
$db = JFactory::getDBO();
$db->setQuery("SELECT `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
$form = $db->loadObject();
$lang = RSFormProHelper::getCurrentLanguage();
$translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
if ($translations) {
foreach ($translations as $field => $value) {
if (isset($form->{$field})) {
$form->{$field} = $value;
}
}
}
$invalid = RSFormProHelper::validateForm($formId);
//Trigger Event - onBeforeFormValidation
$mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid)));
$userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
$adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
$post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
$_POST['form'] = $post;
$RSadapter = RSFormProHelper::getLegacyAdapter();
eval($form->ScriptProcess);
if (!empty($invalid)) {
return $invalid;
}
$post = $_POST['form'];
//Trigger Event - onBeforeFormProcess
$mainframe->triggerEvent('rsfp_f_onBeforeFormProcess');
if (empty($invalid)) {
// Cache enabled ?
jimport('joomla.plugin.helper');
$cache_enabled = JPluginHelper::isEnabled('system', 'cache');
if ($cache_enabled) {
RSFormProHelper::cleanCache();
}
$user = JFactory::getUser();
$confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
// Add to db (submission)
$db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`=NOW(), `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->getEscaped($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->getEscaped($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
$db->query();
$SubmissionId = $db->insertid();
$files = JRequest::get('files');
if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
$names = array();
foreach ($files['form']['tmp_name'] as $fieldName => $val) {
if ($files['form']['error'][$fieldName]) {
continue;
}
$names[] = $db->getEscaped($fieldName);
}
$componentIds = array();
if (!empty($names)) {
$db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
$results = $db->loadObjectList();
foreach ($results as $result) {
$componentIds[$result->PropertyValue] = $result->ComponentId;
}
}
$all_data = RSFormProHelper::getComponentProperties($componentIds);
jimport('joomla.filesystem.file');
foreach ($files['form']['tmp_name'] as $fieldName => $val) {
if ($files['form']['error'][$fieldName]) {
continue;
}
$data = @$all_data[$componentIds[$fieldName]];
if (empty($data)) {
continue;
}
// Prefix
$prefix = uniqid('') . '-';
if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
$prefix = RSFormProHelper::isCode($data['PREFIX']);
}
// Path
$realpath = realpath($data['DESTINATION'] . DS);
if (substr($realpath, -1) != DS) {
$realpath .= DS;
}
// Filename
$file = $realpath . $prefix . $files['form']['name'][$fieldName];
// Upload File
JFile::upload($files['form']['tmp_name'][$fieldName], $file);
// Add to db (submission value)
$db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->getEscaped($fieldName) . "', `FieldValue`='" . $db->getEscaped($file) . "'");
$db->query();
$emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
// Attach to user and admin email
if (in_array('useremail', $emails)) {
$userEmail['files'][] = $file;
}
if (in_array('adminemail', $emails)) {
$adminEmail['files'][] = $file;
}
}
}
//Trigger Event - onBeforeStoreSubmissions
$mainframe->triggerEvent('rsfp_f_onBeforeStoreSubmissions', array(array('formId' => $formId, 'post' => &$post, 'SubmissionId' => $SubmissionId)));
//.........这里部分代码省略.........