本文整理汇总了PHP中TemplateHandler::createQuickSearchCode方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateHandler::createQuickSearchCode方法的具体用法?PHP TemplateHandler::createQuickSearchCode怎么用?PHP TemplateHandler::createQuickSearchCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateHandler
的用法示例。
在下文中一共展示了TemplateHandler::createQuickSearchCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: count
function process_editview()
{
if (isset($this->bean->{$this->value_name}['secondaries'])) {
$this->numFields = count($this->bean->{$this->value_name}['secondaries']) + 1;
}
if (!isset($this->displayParams['readOnly'])) {
$this->displayParams['readOnly'] = '';
} else {
$this->displayParams['readOnly'] = $this->displayParams['readOnly'] == false ? '' : 'READONLY';
}
// If there is extra field to show.
if (isset($this->displayParams['collection_field_list'])) {
$relatedObject = BeanFactory::getObjectName($this->related_module);
vardefmanager::loadVardef($this->related_module, $relatedObject);
foreach ($this->displayParams['collection_field_list'] as $k => $v) {
$javascript = '';
$collection_field_vardef = $GLOBALS['dictionary'][$relatedObject]['fields'][$v['name']];
// For each extra field the params which are not displayParams will be consider as params to override the vardefs values.
foreach ($v as $k_override => $v_override) {
if ($k_override != 'displayParams') {
$collection_field_vardef[$k_override] = $v_override;
}
}
// If relate field : enable quick search by creating the sqs_object array.
if ($collection_field_vardef['type'] == 'relate') {
require_once 'include/TemplateHandler/TemplateHandler.php';
$tph = new TemplateHandler();
$javascript = $tph->createQuickSearchCode(array($collection_field_vardef['name'] => $collection_field_vardef), array($v), $this->form_name);
$javascript = str_replace('<script language="javascript">' . "if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}']=", "", $javascript);
$javascript = substr($javascript, 0, -10);
//remove ";</script>"
$javascriptPHP = $this->json->decode($javascript);
foreach ($javascriptPHP['populate_list'] as $kk => $vv) {
$javascriptPHP['populate_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
foreach ($javascriptPHP['required_list'] as $kk => $vv) {
$javascriptPHP['required_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
foreach ($javascriptPHP['field_list'] as $kk => $vv) {
if ($vv == 'id') {
$javascriptPHP['populate_list'][$kk];
}
}
$javascript = $this->json->encode($javascriptPHP);
$javascript = "<script language='javascript'>if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}_" . $this->vardef['name'] . "_collection_extra_0']=" . $javascript . ';</script>';
}
$collection_field_vardef['name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
if (isset($collection_field_vardef['id_name'])) {
$collection_field_vardef['id_name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
if (isset($this->displayParams['allow_update']) && ($this->displayParams['allow_update'] === false || $this->displayParams['allow_update'] === 'false')) {
$this->displayParams['allow_update'] = 'false';
$v['displayParams']['field']['disabled'] = '';
} else {
$this->displayParams['allow_update'] = 'true';
if (!isset($v['displayParams'])) {
$v['displayParams'] = array();
}
}
// Wireless view for Enum type because the wireless view retrieve and translate the list on real time.
if ($collection_field_vardef['type'] == 'enum') {
//TODO Change to an other view
$viewtype = 'WirelessEditView';
} else {
$viewtype = 'EditView';
}
$name = $collection_field_vardef['name'];
// Rearranging the array with name as key instaead of number. This is required for displaySmarty() to assign the good variable.
$this->displayParams['collection_field_list'][$name]['vardefName'] = $this->displayParams['collection_field_list'][$k]['name'];
$this->displayParams['collection_field_list'][$name]['name'] = $name;
if ($collection_field_vardef['type'] == 'relate') {
$this->displayParams['collection_field_list'][$name]['id_name'] = $collection_field_vardef['id_name'];
$this->displayParams['collection_field_list'][$name]['module'] = $collection_field_vardef['module'];
}
$this->displayParams['collection_field_list'][$name]['label'] = "{sugar_translate label='{$collection_field_vardef['vname']}' module='{$this->related_module}'}";
//translate($collection_field_vardef['vname'], $this->related_module);
$this->displayParams['collection_field_list'][$name]['field'] = $sfh->displaySmarty('displayParams.collection_field_list', $collection_field_vardef, $viewtype, $v['displayParams'], 1);
$this->displayParams['collection_field_list'][$name]['field'] .= '{literal}' . $javascript;
// Handle update_field array ONCHANGE
$this->displayParams['collection_field_list'][$name]['field'] .= <<<FRA
<script language='javascript'>
var oldonchange = '';
if(typeof(document.getElementById('{$collection_field_vardef['name']}').attributes.onchange) != 'undefined')
{
oldonchange=document.getElementById('{$collection_field_vardef['name']}').attributes.onchange.value;
}
FRA;
$this->displayParams['collection_field_list'][$name]['field'] .= "eval(\"document.getElementById('{$collection_field_vardef['name']}').onchange = function onchange(event){collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['name']}=true;";
if ($collection_field_vardef['type'] == 'relate') {
// If relate add the ID field to the array
$this->displayParams['collection_field_list'][$name]['field'] .= "collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['id_name']}=true;";
}
$this->displayParams['collection_field_list'][$name]['field'] .= "document.getElementById('update_fields_{$this->vardef['name']}_collection').value = YAHOO.lang.JSON.stringify(collection['{$this->vardef['name']}'].update_fields);\" + oldonchange + \"};\");</script>{/literal}";
//we need to get rid of the old value;
unset($this->displayParams['collection_field_list'][$k]);
}
}
if (!isset($this->displayParams['class'])) {
$this->displayParams['class'] = '';
}
//.........这里部分代码省略.........
示例2: action_getRelateFieldJS
public function action_getRelateFieldJS()
{
global $beanFiles, $beanList;
$fieldlist = array();
$view = "EditView";
if (!isset($focus) || !$focus instanceof SugarBean) {
require_once $beanFiles[$beanList[$_REQUEST['current_module']]];
$focus = new $beanList[$_REQUEST['current_module']]();
}
// create the dropdowns for the parent type fields
$vardefFields[$_REQUEST['field']] = $focus->field_defs[$_REQUEST['field']];
require_once "include/TemplateHandler/TemplateHandler.php";
$template_handler = new TemplateHandler();
$quicksearch_js = $template_handler->createQuickSearchCode($vardefFields, $vardefFields, $view);
$quicksearch_js = str_replace($_REQUEST['field'], $_REQUEST['field'] . '_display', $quicksearch_js);
$quicksearch_js = str_replace($vardefFields[$_REQUEST['field']]['id_name'], $_REQUEST['field'], $quicksearch_js);
echo $quicksearch_js;
}
示例3: display
//.........这里部分代码省略.........
$userTZ = $current_user->getPreference('timezone');
if (empty($userTZ)) {
$userTZ = TimeDate::userTimezone();
}
$this->ss->assign('TIMEZONE_CURRENT', $userTZ);
$this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
// get currency preference
require_once 'modules/Currencies/ListCurrency.php';
$currency = new ListCurrency();
$cur_id = $locale->getPrecedentPreference('currency', $current_user);
if ($cur_id) {
$selectCurrency = $currency->getSelectOptions($cur_id);
$this->ss->assign("CURRENCY", $selectCurrency);
} else {
$selectCurrency = $currency->getSelectOptions();
$this->ss->assign("CURRENCY", $selectCurrency);
}
$currenciesVars = "";
$i = 0;
foreach ($locale->currencies as $id => $arrVal) {
$currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
$i++;
}
$currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
document.getElementById('symbol').value = currencies[id];
}
eoq;
$this->ss->assign('currencySymbolJs', $currencySymbolsJs);
// fill significant digits dropdown
$significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
$sigDigits = '';
for ($i = 0; $i <= 6; $i++) {
if ($significantDigits == $i) {
$sigDigits .= '<option value="' . $i . '" selected="true">' . $i . '</option>';
} else {
$sigDigits .= '<option value="' . $i . '">' . $i . '</option>';
}
}
$this->ss->assign('sigDigits', $sigDigits);
$num_grp_sep = $current_user->getPreference('num_grp_sep');
$dec_sep = $current_user->getPreference('dec_sep');
$this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
$this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
$this->ss->assign('getNumberJs', $locale->getNumberJs());
// Name display format
$this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
$this->ss->assign('getNameJs', $locale->getNameJs());
// Charset
$charsetOptions = get_select_options_with_id($locale->getCharsetSelect(), $charset_for_import);
//wdong, bug 25927, here we should use the charset testing results from above.
$this->ss->assign('CHARSETOPTIONS', $charsetOptions);
// handle building index selector
global $dictionary, $current_language;
require_once "include/templates/TemplateGroupChooser.php";
$chooser_array = array();
$chooser_array[0] = array();
$idc = new ImportDuplicateCheck($this->bean);
$chooser_array[1] = $idc->getDuplicateCheckIndexes();
$chooser = new TemplateGroupChooser();
$chooser->args['id'] = 'selected_indices';
$chooser->args['values_array'] = $chooser_array;
$chooser->args['left_name'] = 'choose_index';
$chooser->args['right_name'] = 'ignore_index';
$chooser->args['left_label'] = $mod_strings['LBL_INDEX_USED'];
$chooser->args['right_label'] = $mod_strings['LBL_INDEX_NOT_USED'];
$this->ss->assign("TAB_CHOOSER", $chooser->display());
// show notes
if ($this->bean instanceof Person) {
$module_key = "LBL_CONTACTS_NOTE_";
} elseif ($this->bean instanceof Company) {
$module_key = "LBL_ACCOUNTS_NOTE_";
} else {
$module_key = "LBL_" . strtoupper($_REQUEST['import_module']) . "_NOTE_";
}
$notetext = '';
for ($i = 1; isset($mod_strings[$module_key . $i]); $i++) {
$notetext .= '<li>' . $mod_strings[$module_key . $i] . '</li>';
}
$this->ss->assign("NOTETEXT", $notetext);
$this->ss->assign("HAS_HEADER", $has_header ? 'on' : 'off');
// get list of required fields
$required = array();
foreach (array_keys($this->bean->get_import_required_fields()) as $name) {
$properties = $this->bean->getFieldDefinition($name);
if (!empty($properties['vname'])) {
$required[$name] = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
} else {
$required[$name] = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
}
}
// include anything needed for quicksearch to work
require_once "include/TemplateHandler/TemplateHandler.php";
$quicksearch_js = TemplateHandler::createQuickSearchCode($fields, $fields, 'importstep3');
$this->ss->assign("JAVASCRIPT", $quicksearch_js . "\n" . $this->_getJS($required));
$this->ss->assign('required_fields', implode(', ', $required));
$this->ss->display('modules/Import/tpls/step3.tpl');
}
示例4: getModuleField
//.........这里部分代码省略.........
$fieldlist[$name]['options'][''] = '';
}
}
// fill in function return values
if (!in_array($fieldname, array('email1', 'email2'))) {
if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') {
$function = $fieldlist[$fieldname]['function']['name'];
// include various functions required in the various vardefs
if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) {
require_once $fieldlist[$fieldname]['function']['include'];
}
$_REQUEST[$fieldname] = $value;
$value = $function($focus, $fieldname, $value, $view);
$value = str_ireplace($fieldname, $aow_field, $value);
}
}
if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link') {
$fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id';
if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) {
$relName = $fieldlist[$fieldname]['name'];
$fieldlist[$fieldname]['module'] = $focus->{$relName}->getRelatedModuleName();
}
}
if (isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')) {
$fieldlist[$fieldname]['name'] = 'aow_temp_date';
$fieldlist['aow_temp_date'] = $fieldlist[$fieldname];
$fieldname = 'aow_temp_date';
}
$quicksearch_js = '';
if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) {
$rel_value = $value;
require_once "include/TemplateHandler/TemplateHandler.php";
$template_handler = new TemplateHandler();
$quicksearch_js = $template_handler->createQuickSearchCode($fieldlist, $fieldlist, $view);
$quicksearch_js = str_replace($fieldname, $aow_field . '_display', $quicksearch_js);
$quicksearch_js = str_replace($fieldlist[$fieldname]['id_name'], $aow_field, $quicksearch_js);
echo $quicksearch_js;
if (isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users') {
$rel_value = get_assigned_user_name($value);
} else {
if (isset($fieldlist[$fieldname]['module'])) {
require_once $beanFiles[$beanList[$fieldlist[$fieldname]['module']]];
$rel_focus = new $beanList[$fieldlist[$fieldname]['module']]();
$rel_focus->retrieve($value);
if (isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != '') {
$relDisplayField = $fieldlist[$fieldname]['rname'];
} else {
$relDisplayField = 'name';
}
$rel_value = $rel_focus->{$relDisplayField};
}
}
$fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $value;
$fieldlist[$fieldname]['value'] = $rel_value;
$fieldlist[$fieldname]['id_name'] = $aow_field;
$fieldlist[$fieldlist[$fieldname]['id_name']]['name'] = $aow_field;
$fieldlist[$fieldname]['name'] = $aow_field . '_display';
} else {
if (isset($fieldlist[$fieldname]['type']) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) {
$value = $focus->convertField($value, $fieldlist[$fieldname]);
if (!empty($params['date_format']) && isset($params['date_format'])) {
$convert_format = "Y-m-d H:i:s";
if ($fieldlist[$fieldname]['type'] == 'date') {
$convert_format = "Y-m-d";
}
$fieldlist[$fieldname]['value'] = $timedate->to_display($value, $convert_format, $params['date_format']);
示例5: display
//.........这里部分代码省略.........
$rows[1][$field_count] = $locale->translateCharset($rows[1][$field_count], $charset);
}
}
$cellOneData = isset($rows[0][$field_count]) ? $rows[0][$field_count] : '';
$cellTwoData = isset($rows[1][$field_count]) ? $rows[1][$field_count] : '';
$cellThreeData = isset($rows[2][$field_count]) ? $rows[2][$field_count] : '';
$columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'cell1' => strip_tags($cellOneData), 'cell2' => strip_tags($cellTwoData), 'cell3' => strip_tags($cellThreeData), 'show_remove' => false);
}
// add in extra defaulted fields if they are in the mapping record
if (count($default_values) > 0) {
foreach ($default_values as $field_name => $default_value) {
// build string of options
$fields = $this->bean->get_importable_fields();
$options = array();
$defaultField = '';
foreach ($fields as $fieldname => $properties) {
// get field name
if (!empty($properties['vname'])) {
$displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
} else {
$displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
}
// see if this is required
$req_mark = "";
$req_class = "";
if (array_key_exists($fieldname, $this->bean->get_import_required_fields())) {
$req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
$req_class = ' class="required" ';
}
// see if we have a match
$selected = '';
if (strtolower($fieldname) == strtolower($field_name) && !in_array($fieldname, $mappedFields) && !in_array($fieldname, $ignored_fields)) {
$selected = ' selected="selected" ';
$defaultField = $fieldname;
$mappedFields[] = $fieldname;
}
// get field type information
$fieldtype = '';
if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
$fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
}
if (isset($properties['comment'])) {
$fieldtype .= ' - ' . $properties['comment'];
}
$options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . $fieldtype . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
}
// get default field value
$defaultFieldHTML = '';
if (!empty($defaultField)) {
$defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], $default_value);
}
// Bug 27046 - Sort the column name picker alphabetically
ksort($options);
$columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'show_remove' => true);
$ret_field_count++;
}
}
$this->ss->assign("COLUMNCOUNT", $ret_field_count);
$this->ss->assign("rows", $columns);
$this->ss->assign('datetimeformat', $GLOBALS['timedate']->get_cal_date_time_format());
// handle building index selector
global $dictionary, $current_language;
// show notes
if ($this->bean instanceof Person) {
$module_key = "LBL_CONTACTS_NOTE_";
} elseif ($this->bean instanceof Company) {
$module_key = "LBL_ACCOUNTS_NOTE_";
} else {
$module_key = "LBL_" . strtoupper($_REQUEST['import_module']) . "_NOTE_";
}
$notetext = '';
for ($i = 1; isset($mod_strings[$module_key . $i]); $i++) {
$notetext .= '<li>' . $mod_strings[$module_key . $i] . '</li>';
}
$this->ss->assign("NOTETEXT", $notetext);
$this->ss->assign("HAS_HEADER", $has_header ? 'on' : 'off');
// get list of required fields
$required = array();
foreach (array_keys($this->bean->get_import_required_fields()) as $name) {
$properties = $this->bean->getFieldDefinition($name);
if (!empty($properties['vname'])) {
$required[$name] = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir));
} else {
$required[$name] = str_replace(":", "", translate($properties['name'], $this->bean->module_dir));
}
}
// include anything needed for quicksearch to work
require_once "include/TemplateHandler/TemplateHandler.php";
// Bug #46879 : createQuickSearchCode() function in IBM RTC call function getQuickSearchDefaults() to get instance and then getQSDLookup() function
// if we call this function as static it replaces context and use ImportViewStep3 as $this in getQSDLookup()
$template_handler = new TemplateHandler();
$quicksearch_js = $template_handler->createQuickSearchCode($fields, $fields, 'importstep3');
$this->ss->assign("QS_JS", $quicksearch_js);
$this->ss->assign("JAVASCRIPT", $this->_getJS($required));
$this->ss->assign('required_fields', implode(', ', $required));
$this->ss->assign('CSS', $this->_getCSS());
$content = $this->ss->fetch($this->getCustomFilePathIfExists('modules/Import/tpls/step3.tpl'));
$this->ss->assign("CONTENT", $content);
$this->ss->display($this->getCustomFilePathIfExists('modules/Import/tpls/wizardWrapper.tpl'));
}
示例6: getImportForm
/**
* Renders the Import form from Smarty and returns HTML
* @param array $vars request variable global
* @param object $email Fetched email object
* @param bool $addToAddressBook
* @return array
*/
function getImportForm($vars, $email)
{
require_once "include/EditView/EditView2.php";
require_once "include/TemplateHandler/TemplateHandler.php";
global $app_strings;
global $current_user;
global $app_list_strings;
$sqsdefs = array();
$sqsdefs['parent_name'] = array('name' => 'parent_name', 'type' => 'parent', 'label' => 'LBL_EMAIL_RELATE_TO', 'relate' => 'parent_id');
$smarty = new Sugar_Smarty();
$smarty->assign("APP", $app_strings);
$showAssignTo = false;
if (!isset($vars['showAssignTo']) || $vars['showAssignTo'] == true) {
$showAssignTo = true;
}
// if
if ($showAssignTo) {
if (empty($email->assigned_user_id) && empty($email->id)) {
$email->assigned_user_id = $current_user->id;
}
if (empty($email->assigned_name) && empty($email->id)) {
$email->assigned_user_name = $current_user->user_name;
}
$sqsdefs['assigned_user_name'] = array('name' => 'assigned_user_name', 'type' => 'relate', 'module' => 'Users', 'label' => 'LBL_ASSIGNED_TO', 'relate' => 'assigned_user_id');
}
$smarty->assign("showAssignedTo", $showAssignTo);
$showDelete = false;
if (!isset($vars['showDelete']) || $vars['showDelete'] == true) {
$showDelete = true;
}
$smarty->assign("showDelete", $showDelete);
$smarty->assign("userId", $email->assigned_user_id);
$smarty->assign("userName", $email->assigned_user_name);
$parent_types = $app_list_strings['record_type_display'];
$smarty->assign('parentOptions', get_select_options_with_id($parent_types, $email->parent_type));
$sqs = TemplateHandler::createQuickSearchCode($sqsdefs, $sqsdefs);
$sqs .= '<script type="text/javascript" language="Javascript">';
foreach ($sqsdefs as $field => $def) {
$sqs .= "\n addToValidateBinaryDependency('ImportEditView', '{$field}', 'alpha', false," . "'{$app_strings['ERR_SQS_NO_MATCH_FIELD']} {$app_strings[$def['label']]}', '{$def['relate']}');";
}
$sqs .= '</script>';
$smarty->assign('SQS', $sqs);
$meta = array();
$meta['html'] = $smarty->fetch("modules/Emails/templates/importRelate.tpl");
return $meta;
}